Reputation: 7919
Recently im try to read codes of koajs and find this line of code:
var debug = require('debug')('koa-route');
What this mean ? why use ('debug') and then ('koa-route') ? you can find the code here . and i say that i find this line of code in koa-route middle ware defination
Upvotes: 2
Views: 215
Reputation: 21119
The module basically looks something like this:
function toRun() {
// do stuff
}
module.exports = toRun;
Then your script code does the following:
var ran = require('torun')();
This is a convenient way to expose something most often used, but also usable if you want to expose some methods directly on the exported Function
. For example:
function toRun() {
// do stuff
}
toRun.moreStuff = function() {
// and again
};
module.exports = toRun;
Then to get access to the additional functions you can just grab the entire thing:
var toRun = require('torun');
var ran = toRun();
var stuff = toRun.moreStuff();
Upvotes: 1