-
-
Save rightfold/370f1b72df132c4ea0bd to your computer and use it in GitHub Desktop.
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
function flatMap<T, U, V>(inputStream: Stream<T>, fn: (T) => Stream<U>) { | |
var outputStream = new Stream<U>(); | |
inputStream.addEventListener((event) => { | |
fn(event).addEventListener((event) => { | |
outputStream.emitEvent(event); | |
}); | |
}); | |
return outputStream; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment