pull-stream
Advanced tools
Comparing version 2.23.1 to 2.24.0
{ | ||
"name": "pull-stream", | ||
"description": "minimal pull stream", | ||
"version": "2.23.1", | ||
"version": "2.24.0", | ||
"homepage": "https://github.com/dominictarr/pull-stream", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -90,7 +90,13 @@ var u = require('pull-core') | ||
return function next (end, cb) { | ||
read(end, function (end, data) { | ||
if(!end && !test(data)) | ||
return next(end, cb) | ||
cb(end, data) | ||
}) | ||
var sync, loop = true | ||
while(loop) { | ||
loop = false | ||
sync = true | ||
read(end, function (end, data) { | ||
if(!end && !test(data)) | ||
return sync ? loop = true : next(end, cb) | ||
cb(end, data) | ||
}) | ||
sync = false | ||
} | ||
} | ||
@@ -300,3 +306,25 @@ } | ||
var flatMap = exports.flatMap = | ||
function (read, mapper) { | ||
mapper = mapper || id | ||
var queue = [], ended | ||
return function (abort, cb) { | ||
if(queue.length) return cb(null, queue.shift()) | ||
else if(ended) return cb(ended) | ||
read(abort, function next (end, data) { | ||
if(end) ended = end | ||
else { | ||
var add = mapper(data) | ||
while(add && add.length) | ||
queue.push(add.shift()) | ||
} | ||
if(queue.length) cb(null, queue.shift()) | ||
else if(ended) cb(ended) | ||
else read(null, next) | ||
}) | ||
} | ||
} | ||
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
47883
33
1350