Created
July 17, 2015 02:36
-
-
Save yelouafi/b31c3002b3be42490bbb 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
// 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