pull-stream
Advanced tools
Comparing version 2.10.2 to 2.11.0
@@ -16,4 +16,14 @@ | ||
## writeArray(cb) | ||
## drain (op?, done?) | ||
Drain the stream, calling `op` on each `data`. | ||
call `done` when stream is finished. | ||
If op returns `===false`, abort the stream. | ||
## reduce (reduce, initial, cb) | ||
reduce stream into single value, then callback. | ||
## collect(cb) | ||
Read the stream into an array, then callback. | ||
@@ -25,6 +35,2 @@ | ||
## drain (op?) | ||
Drain the stream, calling `op` on each `data`. | ||
## log | ||
@@ -31,0 +37,0 @@ |
{ | ||
"name": "pull-stream", | ||
"description": "minimal pull stream", | ||
"version": "2.10.2", | ||
"version": "2.11.0", | ||
"homepage": "https://github.com/dominictarr/pull-stream", | ||
@@ -6,0 +6,0 @@ "repository": { |
24
sinks.js
@@ -14,4 +14,9 @@ var drain = exports.drain = function (read, op, done) { | ||
op && op(data) | ||
if(op) { | ||
//return false to abort! | ||
if(false === op(data)) { | ||
loop = false | ||
read(true, done || function () {}) | ||
} | ||
} | ||
if(!sync) next() | ||
@@ -25,2 +30,17 @@ }) | ||
var find = | ||
exports.find = function (read, test, cb) { | ||
var ended = false | ||
drain(read, function (data) { | ||
if(test(data)) { | ||
ended = true | ||
cb(null, data) | ||
return false | ||
} | ||
}, function (err) { | ||
if(ended) return //already called back | ||
cb(err === true ? null : err, null) | ||
}) | ||
} | ||
var reduce = exports.reduce = | ||
@@ -27,0 +47,0 @@ function (read, reduce, acc, cb) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32187
23
831