Is there any way to get generators into node.js?
I\'m currently faking them with callbacks, but I have to remember to check the response of the callback inside of my gen
We are using gnode
for generators in node < 0.11.3 - https://github.com/TooTallNate/gnode
The issue proposing generatiors in v8 has recently been accepted by v8 project member.
Please vote there to make yield
come true.
Yes, since version 0.11. Enjoy!
http://wingolog.org/archives/2013/05/08/generators-in-v8
http://jlongster.com/A-Study-on-Solving-Callbacks-with-JavaScript-Generators
You can use generators in Node.js, but only in 0.11+. Node.js 0.12 (stable) is now available. Add --harmony_generators
or --harmony
to the command line parameters of node to enable it.
With Traceur, you can compile advanced JavaScript to vanilla JavaScript. You could make a loader for node.js that does this on-the-fly. Since it runs on, and compiles to vanilla JavaScript, it runs in node.js < 0.11 as well as in the browser.
Facebook has developed a lighter version that only supports generators, called Regenerator. It works similarly to Traceur.