Skip to content

Instantly share code, notes, and snippets.

@kunigami
Created July 1, 2019 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunigami/85823340ed225aa9b39c4fd20c3b92a8 to your computer and use it in GitHub Desktop.
Save kunigami/85823340ed225aa9b39c4fd20c3b92a8 to your computer and use it in GitHub Desktop.
function* makeGenerator(n) {
for(cnt = n - 1; cnt >= 0; cnt--) {
yield cnt;
}
}
it = makeGenerator(30);
while (true) {
const {value, done} = it.next();
if (done) {
break;
}
console.log(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment