sorted-union-stream
Advanced tools
Comparing version 3.2.1 to 3.2.2
42
index.js
@@ -16,3 +16,3 @@ const { Readable } = require('streamx') | ||
this._onclose = null | ||
this._both = opts && opts.both | ||
this._both = !!(opts && opts.both) | ||
this._map = (opts && opts.map) || defaultMap | ||
@@ -41,11 +41,10 @@ | ||
} | ||
if (l === null) { | ||
this._mapAndPush(null, r) | ||
this.right.consume() | ||
return cb(null) | ||
this._push(null, r, cb) | ||
return | ||
} | ||
if (r === null) { | ||
this._mapAndPush(l, null) | ||
this.left.consume() | ||
return cb(null) | ||
this._push(l, null, cb) | ||
return | ||
} | ||
@@ -56,22 +55,21 @@ | ||
if (cmp === 0) { | ||
this._mapAndPush(l, r) | ||
if (this._both) this._mapAndPush(l, r) | ||
this.left.consume() | ||
this.right.consume() | ||
return cb(null) | ||
this._push(l, r, cb) | ||
return | ||
} | ||
if (cmp < 0) { | ||
this._mapAndPush(l, null) | ||
this.left.consume() | ||
return cb(null) | ||
} | ||
this._mapAndPush(null, r) | ||
this.right.consume() | ||
cb(null) | ||
if (cmp < 0) this._push(l, null, cb) | ||
else this._push(null, r, cb) | ||
} | ||
_mapAndPush (l, r) { | ||
_push (l, r, cb) { | ||
const data = this._map(l, r) | ||
if (data !== null) this.push(data) | ||
const pushed = this.push(data) | ||
if (this._both && l && r) this.push(data) | ||
if (l !== null) this.left.consume() | ||
if (r !== null) this.right.consume() | ||
if (pushed) cb(null) | ||
else this._read(cb) | ||
} | ||
@@ -78,0 +76,0 @@ |
{ | ||
"name": "sorted-union-stream", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
9252
205