sorted-union-stream
Advanced tools
Comparing version 3.0.1 to 3.1.0
const { Readable } = require('streamx') | ||
module.exports = class SortedUnionStream extends Readable { | ||
constructor (left, right, compare) { | ||
constructor (left, right, opts) { | ||
super() | ||
if (typeof opts === 'function') opts = { compare: opts } | ||
if (!left.destroy || !right.destroy) throw new Error('Only modern stream supported') | ||
@@ -11,5 +12,8 @@ | ||
this.right = new Peaker(right) | ||
this.compare = compare || defaultCompare | ||
this.compare = (opts && opts.compare) || defaultCompare | ||
this._missing = 2 | ||
this._onclose = null | ||
this._both = opts && opts.both | ||
this._track(left) | ||
@@ -51,2 +55,3 @@ this._track(right) | ||
this.push(l) | ||
if (this._both) this.push(r) | ||
this.left.consume() | ||
@@ -53,0 +58,0 @@ this.right.consume() |
{ | ||
"name": "sorted-union-stream", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
18
test.js
@@ -91,1 +91,19 @@ const { Readable } = require('streamx') | ||
}) | ||
tape('both option', function (t) { | ||
const a = Readable.from([4, 6, 10, 14, 15, 20, 22]) | ||
const b = Readable.from([6, 11, 20]) | ||
const u = new Union(a, b, { both: true }) | ||
const expected = [4, 6, 6, 10, 11, 14, 15, 20, 20, 22] | ||
u.on('data', function (data) { | ||
t.same(data, expected.shift()) | ||
}) | ||
u.on('end', function () { | ||
t.same(expected.length, 0, 'no more data') | ||
t.end() | ||
}) | ||
}) |
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
9076
203