Skip to content

Instantly share code, notes, and snippets.

@yelouafi
Last active August 29, 2015 14:25
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/0098255b15ce8a2cae37 to your computer and use it in GitHub Desktop.
Save yelouafi/0098255b15ce8a2cae37 to your computer and use it in GitHub Desktop.
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