pull-stream
Advanced tools
Comparing version 2.13.0 to 2.14.0
{ | ||
"name": "pull-stream", | ||
"description": "minimal pull stream", | ||
"version": "2.13.0", | ||
"version": "2.14.0", | ||
"homepage": "https://github.com/dominictarr/pull-stream", | ||
@@ -6,0 +6,0 @@ "repository": { |
var u = require('./util') | ||
var sources = require('./sources') | ||
var prop = u.prop | ||
@@ -144,3 +145,29 @@ var id = u.id | ||
var flatten = exports.flatten = function (read) { | ||
var chunk | ||
var _read | ||
return function (abort, cb) { | ||
if(_read) nextChunk() | ||
else nextStream() | ||
function nextChunk () { | ||
_read(null, function (end, data) { | ||
if(end) nextStream() | ||
else cb(null, data) | ||
}) | ||
} | ||
function nextStream () { | ||
read(null, function (end, stream) { | ||
if(end) | ||
return cb(end) | ||
if(Array.isArray(stream)) | ||
stream = sources.values(stream) | ||
else if('function' != typeof stream) | ||
throw new Error('expected stream of streams') | ||
_read = stream | ||
nextChunk() | ||
}) | ||
} | ||
} | ||
/* var chunk | ||
return function (end, cb) { | ||
@@ -160,3 +187,3 @@ //this means that the upstream is sending an error. | ||
}) | ||
} | ||
}*/ | ||
} | ||
@@ -163,0 +190,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
34854
25
938