Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Node Generators
"use strict";
//natural numbers.
function* naturalNumbers(){
var n = 1;
while (true){
yield n++;
}
}
var numbers = naturalNumbers();
console.log(numbers.next());
console.log(numbers.next());
console.log(numbers.next());
console.log(numbers.next());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.