Skip to content

Instantly share code, notes, and snippets.

@jfet97
Last active December 7, 2018 21:22
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 jfet97/9972b627608f25949f5042df12eb85a9 to your computer and use it in GitHub Desktop.
Save jfet97/9972b627608f25949f5042df12eb85a9 to your computer and use it in GitHub Desktop.
ex2
async function * onlyOddPlease(input) {
for await(const n of input) {
// assuming that each chunk is a number
if(n%2) yield n;
}
}
async function * plusOne(input) {
for await(const n of input) {
yield n+1;
}
}
(async function IIAFE(){
for await(const n of plusOne(onlyOddPlease(misteriousStream))) {
process.stdout.write(n);
}
// do other stuff
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment