<commit_before>var http=require("http");
var unmon={};

/* Your default stack */
var routes=unmon.routes=[];

var debug=unmon.debug=true;

var plugin=unmon.plugin=function(name){
    var mod;
    
    if(unmon.debug){
        console.log("Loading %s plugin",name);
    }

    try{
        mod=require("./lib/"+name);
    }catch(err){
        if(unmon.debug){
            console.error("Error loading %s",name);
            console.error(err);
        }
    }
    return mod;
};

/* route produces new routes, and pushes them to a stack */
var route=unmon.route=function(patt,f,opts){
    opts=opts||{}; // you don't have to provide options
    // make sure the discriminator is defined
    opts.disc=opts.disc||'url'; // your router parses by url by default
    opts.stack=opts.stack||routes; // you can provide an alternate stack

    // push your new route to the stack in question
    opts.stack.push(function(req,res,Next){
        // encapsulate Next so that we don't always have to pass req and res
        var next=function(){Next(req,res);};
        if(patt.test(req[opts.disc])){
            f(req,res,next);
        }else{
            next();
        }
    });
};

/*    makeRouter accepts a stack of routes and collapses it into a single function
        which is compatible with the NodeJS http api
        of the form function(request,response)    */
var makeRouter=unmon.makeRouter=function(stack){
    return stack.reduceRight(function(b,a,i,z){
        return function(req,res){
            a(req,res,b);<commit_msg>unmon.js : ignore unmon.route if second argument is not a function. closes #8<commit_after>var http=require("http");
var unmon={};

/* Your default stack */
var routes=unmon.routes=[];

var debug=unmon.debug=true;

var plugin=unmon.plugin=function(name){
    var mod;
    
    if(unmon.debug){
        console.log("Loading %s plugin",name);
    }

    try{
        mod=require("./lib/"+name);
    }catch(err){
        if(unmon.debug){
            console.error("Error loading %s",name);
            console.error(err);
        }
    }
    return mod;
};

/* route produces new routes, and pushes them to a stack */
var route=unmon.route=function(patt,f,opts){
    opts=opts||{}; // you don't have to provide options
    // make sure the discriminator is defined
    opts.disc=opts.disc||'url'; // your router parses by url by default
    opts.stack=opts.stack||routes; // you can provide an alternate stack

    if(typeof f !== 'function'){
        console.error("[ROUTE ERROR]: Second argument provided to unmon.route (%s) is not a function. ignoring...\n",f);
        return;
    }

    // push your new route to the stack in question
    opts.stack.push(function(req,res,Next){
        // encapsulate Next so that we don't always have to pass req and res
        var next=function(){Next(req,res);};
        if(patt.test(req[opts.disc])){
            f(req,res,next);
        }else{
            next();
        }
    });
};

/*    makeRouter accepts a stack of routes and collapses it into a single function
        which is compatible with the NodeJS http api
        of the form function(request,response)    */
var makeRouter=unmon.makeRouter=function(stack){
    return stack.reduceRight(function(b,a,i,z){
        return function(req,res){
            a(req,res,b);
{'fraction_non_alphanumeric': 0.13313161875945537, 'fraction_numerical': 0.000302571860816944, 'mean_word_length': 2.6289791437980243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '151899', 'n_tokens_mistral': 1014, 'n_tokens_neox': 994, 'n_words': 287}