Skip to content

Instantly share code, notes, and snippets.

@vidhill
Created October 9, 2017 13:26
Show Gist options
  • Save vidhill/5947a435d53d868783b3220703ca9e2a to your computer and use it in GitHub Desktop.
Save vidhill/5947a435d53d868783b3220703ca9e2a to your computer and use it in GitHub Desktop.
Function to automatically call .next on creation of a generator function
const wrapGen = myGenerator => {
return function(...passedArgs){
const iter = myGenerator(...passedArgs);
iter.next(); // the black hole call
return iter;
}
}
export default wrapGen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment