Skip to content

Instantly share code, notes, and snippets.

@shigeki
Created September 6, 2012 00:36
Show Gist options
  • Save shigeki/3648816 to your computer and use it in GitHub Desktop.
Save shigeki/3648816 to your computer and use it in GitHub Desktop.
domain bind with closure
// domain.bind with closure
var domain = require('domain');
var d = domain.create();
var f = (function() {
var i = 0;
return function () {
return i++;
};
}());
var g = d.bind(f);
console.log(g()); // 0
console.log(f()); // 1
console.log(g()); // 2
console.log(f()); // 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment