Created
November 14, 2011 17:23
-
-
Save willconant/1364503 to your computer and use it in GitHub Desktop.
Tim Caswell's Fiber idea implemented with Mozilla Javascript 1.7 generators
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
/* in this case, there is no explicit wait() function, instead, fiberized functions use the yield keyword */ | |
module.exports = function(generatorFunction) { | |
var iterator; | |
function resume() { | |
iterator.send(arguments); | |
} | |
iterator = generatorFunction(resume); | |
iterator.next(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment