pull-flat-merge
Advanced tools
Comparing version 1.0.1 to 1.1.0
10
index.js
var S = require('pull-stream/pull') | ||
var once = require('pull-stream/sources/once') | ||
S.drain = require('pull-stream/sinks/drain') | ||
var many = require('pull-many') | ||
module.exports = function flatMerge () { | ||
module.exports = function flatMerge (onErr) { | ||
return function sink (source) { | ||
var m = many() | ||
S(source, S.drain(function onEvent (s) { | ||
if (typeof s !== 'function') { | ||
return m.add(once(s)) | ||
} | ||
m.add(s) | ||
}, function onEnd (err) { | ||
m.cap() | ||
if (err) { | ||
if (onErr) onErr(err) | ||
else throw err | ||
} | ||
})) | ||
@@ -13,0 +21,0 @@ return m |
{ | ||
"name": "pull-flat-merge", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Flat map for pull streams", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,2 +5,19 @@ var test = require('tape') | ||
test('pass through non streams', function (t) { | ||
t.plan(2) | ||
var source = S.values([ | ||
S.values([1,2]), | ||
3 | ||
]) | ||
S( | ||
source, | ||
flatMerge(), | ||
S.collect(function (err, evs) { | ||
t.error(err) | ||
t.deepEqual(evs, [1,3,2], 'should pass through non streams') | ||
}) | ||
) | ||
}) | ||
test('flat merge', function (t) { | ||
@@ -7,0 +24,0 @@ t.plan(2) |
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
5019
55