Created
September 6, 2012 00:36
-
-
Save shigeki/3648816 to your computer and use it in GitHub Desktop.
domain bind with closure
This file contains hidden or 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
// 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