<commit_before>(function () {
    var url  = require('url'),
        util = require('util'),
        ee   = require('eventemitter2').EventEmitter2;

    function defaultCheckRoute(route, path) {
        if (typeof(route) === 'function') {
            try {
                var match = route(path);
                if (match) {
                    return true;
                }
            } catch(error) {
                this.emit('route.fatal', error);
            }
        } else if (typeof(route) === 'object') {
            throw new Exceptin("RegExp as function has been depricated as of Node.js 0.5");
        } else {
            if ((typeof(route) === 'string') && path.match(route)) {
                return true;
            }
        }

        return false;
    }
    

    function Response (response, request, routes) {
        ee.call(this);

        this.length      = 0;

        this.buffers     = [ ];
        this._routes     = routes;
        this._actual     = { response: response, request: request };

        this._croute     = 0;
        this._cpos       = 0;
        this._headers    = { };
        this._code       = 200;
        this._ended      = false;

        var parsed       = url.parse(request.url, true);
        this._pathname   = parsed.pathname;
        this.socket      = response.socket;
        
        this.checkRoute  = defaultCheckRoute;
    }

    util.inherits(Response, ee);
    

    Response.prototype.next = function () {
        if (this._croute >= this._routes.length) {
            // done running the routes
            return;
        }

        if (this._cpos >= this._routes[this._croute].length) {
            // done running the current route
            this.end();
            return;
        }

        var next = this._routes[this._croute][this._cpos];
        this._cpos++;
        
        var route = next.path;
        if (this.checkRoute(next.path, this._pathname)) {
            try {
                next.call(this._actual.request, this, next);
            } catch (error) {
                this.emit('run.fatal', error);
            }
        }

        this.next();
    };
    
    Response.prototype.end = function () {
        switch (this._croute) {<commit_msg>adds ability to completely override route checks<commit_after>(function () {
    var url  = require('url'),
        util = require('util'),
        ee   = require('eventemitter2').EventEmitter2;

    function defaultCheckRoute(route, path, request) {
        if (typeof(route) === 'function') {
            try {
                var match = route(path);
                if (match) {
                    return true;
                }
            } catch(error) {
                this.emit('route.fatal', error);
            }
        } else if (typeof(route) === 'object') {
            throw new Exceptin("RegExp as function has been depricated as of Node.js 0.5");
        } else {
            if ((typeof(route) === 'string') && path.match(route)) {
                return true;
            }
        }

        return false;
    }
    

    function Response (response, request, routes) {
        ee.call(this);

        this.length      = 0;

        this.buffers     = [ ];
        this._routes     = routes;
        this._actual     = { response: response, request: request };

        this._croute     = 0;
        this._cpos       = 0;
        this._headers    = { };
        this._code       = 200;
        this._ended      = false;

        var parsed       = url.parse(request.url, true);
        this._pathname   = parsed.pathname;
        this.socket      = response.socket;
        
        this.checkRoute  = defaultCheckRoute;
    }

    util.inherits(Response, ee);
    

    Response.prototype.next = function () {
        if (this._croute >= this._routes.length) {
            // done running the routes
            return;
        }

        if (this._cpos >= this._routes[this._croute].length) {
            // done running the current route
            this.end();
            return;
        }

        var next = this._routes[this._croute][this._cpos];
        this._cpos++;
        
        var route = next.path;
        if (this.checkRoute(next.path, this._pathname, this._actual.request)) {
            try {
                next.call(this._actual.request, this, next);
            } catch (error) {
                this.emit('run.fatal', error);
            }
        }

        this.next();
    };
    
    Response.prototype.end = function () {
        switch (this._croute) {
{'fraction_non_alphanumeric': 0.12175824175824176, 'fraction_numerical': 0.004395604395604396, 'mean_word_length': 1.3814756671899528, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1303526', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1235, 'n_words': 268}