Created
October 9, 2017 13:26
-
-
Save vidhill/5947a435d53d868783b3220703ca9e2a to your computer and use it in GitHub Desktop.
Function to automatically call .next on creation of a generator function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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