Socket
Socket
Sign inDemoInstall

sorted-union-stream

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sorted-union-stream - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

9

index.js
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",

@@ -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()
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc