Skip to content

Instantly share code, notes, and snippets.

@Nomon
Created April 27, 2011 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nomon/944626 to your computer and use it in GitHub Desktop.
Save Nomon/944626 to your computer and use it in GitHub Desktop.
kek
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);
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;
}
};
@jalava
Copy link

jalava commented Apr 27, 2011

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;
}

};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment