Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created February 8, 2018 06:26
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 goofmint/5f10068ff712688ba39ffefe8d5e4d8b to your computer and use it in GitHub Desktop.
Save goofmint/5f10068ff712688ba39ffefe8d5e4d8b to your computer and use it in GitHub Desktop.
function* gen(i) {
yield {o: i, n: ++i};
yield {o: i, n: ++i};
yield {o: i, n: ++i};
}
let g = gen(3);
for (let {o, n} of g) {
console.log(o, n);
-> 3, 4
-> 4, 5
-> 5, 6
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment