Skip to content

Instantly share code, notes, and snippets.

@mightyguava
Created March 12, 2017 18:50
Show Gist options
  • Save mightyguava/8e8b5153a321be9517976bdfe9437a95 to your computer and use it in GitHub Desktop.
Save mightyguava/8e8b5153a321be9517976bdfe9437a95 to your computer and use it in GitHub Desktop.
Demystifying Async Programming in Javascript - Generator internals adder
function* adder(initialValue) {
let sum = initialValue;
while (true) {
sum += yield sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment