-
-
Save Nomon/944626 to your computer and use it in GitHub Desktop.
kek
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ar t = require('./test'); | |
// a returns print function "b" increment function | |
var a = t("a"); | |
var b = t("b"); | |
a(); | |
b(); | |
setTimeout(a,100); | |
setTimeout(a,200); | |
setTimeout(b,150); | |
setTimeout(b,300); | |
setTimeout(a,350); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(which) { | |
var self = this; | |
this.i = 0; | |
var a = function() { | |
console.log("i: "+self.i); | |
} | |
var b = function() { | |
self.i++; | |
} | |
if(which == "a") { | |
return a; | |
} else { | |
return b; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
module.exports = function(which) {
console.log("Init:"+which);
var self = this;
this.from = which;
this.i = 0;
var a = function() {
console.log("i: "+self.i+" which:"+self.from);
}
var b = function() {
self.i++;
}
if(which == "a") {
return a;
} else {
return b;
}
};