Last active
December 7, 2018 21:22
-
-
Save jfet97/9972b627608f25949f5042df12eb85a9 to your computer and use it in GitHub Desktop.
ex2
This file contains 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
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