pull-stream
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -15,7 +15,10 @@ # Sources | ||
## readArray (array) | ||
## values (array | object) | ||
create a SourceStream that from an array and then stops. | ||
create a SourceStream that reads the values from an array or object and then stops. | ||
## keys (array | object) | ||
stream the key names from an object (or array) | ||
## count (max) | ||
@@ -22,0 +25,0 @@ |
@@ -60,2 +60,9 @@ # Throughs | ||
## group (len) | ||
chunk incoming data into arrays of max length `len`, | ||
(the last item may be shorter than len) | ||
Useful for items you can handle in batches. | ||
## highWaterMark (n) | ||
@@ -62,0 +69,0 @@ |
{ | ||
"name": "pull-stream", | ||
"description": "minimal pull stream", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"homepage": "https://github.com/dominictarr/pull-stream", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -22,3 +22,4 @@ | ||
var count = function (max) { | ||
var count = exports.count = | ||
function (max) { | ||
var i = 0; max = max || Infinity | ||
@@ -25,0 +26,0 @@ return function (end, cb) { |
@@ -96,2 +96,31 @@ function prop (map) { | ||
var group = exports.group = | ||
function (read, size) { | ||
var ended; size = size || 5 | ||
var queue = [] | ||
return function (end, cb) { | ||
//this means that the upstream is sending an error. | ||
if(end) return read(ended = end, cb) | ||
//this means that we read an end before. | ||
if(ended) return cb(ended) | ||
read(null, function next(end, data) { | ||
if(ended = ended || end) { | ||
if(!queue.length) | ||
return cb(ended) | ||
var _queue = queue; queue = [] | ||
return cb(null, _queue) | ||
} | ||
queue.push(data) | ||
if(queue.length < size) | ||
return read(null, next) | ||
var _queue = queue; queue = [] | ||
cb(null, _queue) | ||
}) | ||
} | ||
} | ||
var nextTick = process.nextTick | ||
@@ -98,0 +127,0 @@ |
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
27247
19
642