Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created Feb 8, 2018
Embed
What would you like to do?
function* gen(i) {
let m = yield {o: i, n: ++i};
m = yield {o: m, n: ++m};
m = yield {o: m, n: ++m};
}
let g = gen(3);
let {o, n} = g.next().value;
console.log(o, n);
-> 3, 4
let {o: a, n: b} = g.next(n).value;
console.log(a, b);
-> 4, 5
let {o: c, n: d} = g.next(n).value;
console.log(c, d);
-> 5, 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment