Skip to content

Instantly share code, notes, and snippets.

@alexserver
Created June 2, 2015 23:09
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 alexserver/84045bc66c278875a735 to your computer and use it in GitHub Desktop.
Save alexserver/84045bc66c278875a735 to your computer and use it in GitHub Desktop.
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