Skip to content

Instantly share code, notes, and snippets.

@yelouafi yelouafi/stream-map.js
Last active Aug 29, 2015

Embed
What would you like to do?
// map : (Stream a, a -> b) -> Stream b
Stream.prototype.map = function(f) {
return this.isEmpty || this.isAbort ? this
: this.isCons ? Stream.Cons(f(this.head), this.tail.map(f))
: Stream.Future(
this.promise.then(
s => s.map(f),
err => Stream.Abort(err)))
Stream.seq([1,2,3], 0, 1000).map(x => x+1).log('seq')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.