javascript - Node Require with two Parenthesis -
Try to read code codes recently and find this line of code:
< Code> var debug = requirement ('debug') ('co-root');
What does this mean? Why use ('debug') and then ('Co-root')? You can find the code and I say that I get this line of code in the KoA-Root Medium Ware definition
Module looks basically something like this:
function to run () {// do stuff} module.exports = toRun;
Then your script code does the following:
var ran = require ('torun') ();
This is a convenient way to expose some of the frequently used items, but it is also useful if you have some methods on directly exported functions
Want to expose. For example:
toun () {// do stuff} toRun.morestuff = function () {// and then}; Module.exports = toRun;
Then you can catch the whole thing to gain access to additional tasks:
var toRun = require ('torun'); Var ran = toRun (); Var accessories = toRun.moreStuff ();
Comments
Post a Comment