Last active
August 29, 2015 14:25
-
-
Save yelouafi/0098255b15ce8a2cae37 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
const noop = () => {} | |
Stream.prototype.forEach = function(onNext, onError=noop, onComplete=noop) { | |
return this.isEmpty ? onComplete() | |
: this.isAbort ? onError(this.error) : | |
: this.isCons ? ( | |
onNext(this.head), | |
this.tail.forEach(onNext, onError, onComplete)) | |
: this.promise.then( | |
stream => stream.forEach(onNext, onError, onComplete), | |
onError); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment