Skip to content

Instantly share code, notes, and snippets.

@kunigami
Last active July 1, 2019 01:15
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/5132ac24d4fcdf0661cbd24aedf54115 to your computer and use it in GitHub Desktop.
Save kunigami/5132ac24d4fcdf0661cbd24aedf54115 to your computer and use it in GitHub Desktop.
function makeGenerator(n) {
return {
*[Symbol.iterator]() {
for(cnt = n - 1; cnt >= 0; cnt--) {
yield cnt;
}
},
};
}
it = makeGenerator(30);
for (value of it) {
console.log(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment