Skip to content

Instantly share code, notes, and snippets.

@yelouafi
Created July 17, 2015 02:11
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/720db06a07319c2be36b to your computer and use it in GitHub Desktop.
Save yelouafi/720db06a07319c2be36b to your computer and use it in GitHub Desktop.
// any : ( Stream a, a -> aBoolean ) -> Promise Boolean
Stream.prototype.any = function(pred) {
return this.isEmpty ? Promise.resolve(false)
: this.isAbort ? Promise.reject(this.err)
: this.isCons ?
(pred(this.head) ? Promise.resolve(true) : this.tail.any(pred) )
: /* isFuture */
this.promise.then( s => s.any(pred) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment