Skip to content

Instantly share code, notes, and snippets.

@kimmobrunfeldt
Created February 29, 2016 21:02
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 kimmobrunfeldt/0630cfd210d43183eb10 to your computer and use it in GitHub Desktop.
Save kimmobrunfeldt/0630cfd210d43183eb10 to your computer and use it in GitHub Desktop.
Small example of a generator
function* uniqueId() {
var i = 0;
while (true) {
yield i;
++i;
}
}
var idGenerator = uniqueId();
function getUniqueId() {
return idGenerator.next().value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment