add generators support via regenerator

This commit is contained in:
Sebastian McKenzie
2014-10-14 10:11:51 +11:00
parent 7db9abb9dd
commit 73b8daf370
12 changed files with 77 additions and 14 deletions

View File

@@ -0,0 +1,19 @@
function *range(max, step) {
var count = 0;
step = step || 1;
for (var i = 0; i < max; i += step) {
count++;
yield i;
}
return count;
}
var gen = range(20, 3), info;
while (!(info = gen.next()).done) {
info.value;
}
assert(info.value, 7);