Reputation: 4628
Are generator functions supported in Node? I keep reading that they are since v 0.11.
Tried to run this snippet in node 0.12
function* range(max, step) {
var count = 0;
step = step || 1;
for (var i = 0; i < max; i += step) {
count++;
yield i;
}
return count;
}
but no luck. Do I need to call npm start with a custom parameter?
Upvotes: 0
Views: 572
Reputation: 48555
You need to run node with --harmony
flag to enable generators in node (0.11.x and 0.12.x versions):
$ node --harmony your_script.js
Upvotes: 1