Skip to content

Instantly share code, notes, and snippets.

@yelouafi
Created July 17, 2015 02:36
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 yelouafi/b31c3002b3be42490bbb to your computer and use it in GitHub Desktop.
Save yelouafi/b31c3002b3be42490bbb to your computer and use it in GitHub Desktop.
// concat : (Stream a, Stream a) => Stream a
Stream.prototype.concat = function(s2) {
return this.isEmpty ? s2
: this.isAbort ? this
: this.isCons ? Stream.Cons( this.head, this.tail.concat(s2) )
: Stream.Future(this.promise.then(s => s.concat(s2), Stream.Abort))
}
Stream.seq([1,2,3,4,5], 2000, 1000) // 1st stream will yields normally
.concat(Stream.seq([6,7,8], 0, 500)) // 2nd will holds until the first ends
.log()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment