{"name":"sorted-union-stream","version":"3.0.0","repository":{"type":"git","url":"git://github.com/mafintosh/sorted-union-stream.git"},"license":"MIT","description":"Get the union of two sorted streams","keywords":["union","sorted","stream"],"author":{"name":"Mathias Buus Madsen","email":"mathiasbuus@gmail.com"},"scripts":{"test":"tape test.js"},"dependencies":{"streamx":"^2.6.0"},"devDependencies":{"standard":"^14.3.1","tape":"^4.13.0"},"bugs":{"url":"https://github.com/mafintosh/sorted-union-stream/issues"},"homepage":"https://github.com/mafintosh/sorted-union-stream","main":"index.js","gitHead":"a203e43ee3f20c4d97446ff138b9d051021df65d","_id":"sorted-union-stream@3.0.0","_nodeVersion":"12.14.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-4biohDKWczvAdvOXoXiE6tDVMXvHhKh5x88S/H9XsZQK77zn1jNFmy8F4fW5C0NwPag+WLNlbDXJqZl1QDKqAA==","shasum":"6292315d5bf3e517681a1862d2e6137a4cf4ba1d","tarball":"http://registry-npm.ywwl.com/sorted-union-stream/download/sorted-union-stream-3.0.0.tgz","fileCount":7,"unpackedSize":8538,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeHwupCRA9TVsSAnZWagAAAacP/AvZPgQsGJVle0jF6y+a\nBoFhIoSQ2Pse/grRdtOOXuhGN7AEloUOkf90emkTgxmYaP7zdzwxD9qTtMHr\nCzmvIF0R6/zCf7hDV1/wVkwAO/a4mZjadkBxgV9H2zcvdXdfQnEdn6Xmw5CM\nYd1Cfu69wAL7ZWNmZGNtoDaBKLZsHYa0aP6FfuouhZKpGb3EV3FOD10OY1dY\nPcq92r43nP7yQ6vgu+V2R9cL9nlOyozvjW26ijLEtPwgbwa5mDv9jdYfzcAX\nkK5vgp89X+8e8eJaVV6K5z2TUBzOJnFPbVd3Ewn/1OeoiBv/H+QD3LE0OYID\nmIGF9TZ9/bj1y2oo5BIAAq+8j8RAaYp4ImEBP4GifSW4vUlduCMOKA4HUIwu\nFJiFVbgqkdcPbd81QlsjavSB+SdbfPYp163ZaVmB1dY/yaARfXsO15Nbt+rr\nM6M3fZLtOOophu6aMtPTN8uWzAsffTogBNCq6tEbO3t+pwz82taSla9tONHE\nqNMxp+Qddhpbi/Oqbe6UCWXr4hN2Rax9CQwfK+xAtOARJ6vA5WLX6vsHMEsm\n4eEaz9tKiy/1bClvLOh7lq89YRkH8XUtgJ4xqMj4gvjz2cZOJUoT1SPQsctU\n6DoEad+p60Y9/Jy3dD4qlUXlKMDdNhJNRnE3rKPOMJR2TAAiorMQmC1/Ak6N\n+WUw\r\n=qo2z\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA9Al2wK1N0MbGBMv32PSkPnUK7DRhMLjkoIydAmMQW/AiEAlGcttkwzkey03fPhAWZtgQnPnL6BoyIpRyMlT1mgRVI="}],"size":2946,"noattachment":false,"key":"/sorted-union-stream/-/sorted-union-stream-3.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sorted-union-stream_3.0.0_1579092904973_0.22174428289675818"},"_hasShrinkwrap":false,"readme":"# sorted-union-stream\n\nGet the union of two sorted streams\n\n```\nnpm install sorted-union-stream\n```\n\n[![build status](https://secure.travis-ci.org/mafintosh/sorted-union-stream.png)](http://travis-ci.org/mafintosh/sorted-union-stream)\n\n## Usage\n\n``` js\nconst union = require('sorted-union-stream')\nconst { Readable } = require('streamx')\n\n// from converts an array into a stream\nconst sorted1 = Readable.from([1, 10, 24, 42, 43, 50, 55])\nconst sorted2 = Readable.from([10, 42, 53, 55, 60])\n\n// combine the two streams into a single sorted stream\nconst u = new Union(sorted1, sorted2)\n\nu.on('data', function(data) {\n  console.log(data)\n})\nu.on('end', function() {\n  console.log('no more data')\n})\n```\n\nRunning the above example will print\n\n```\n1\n10\n24\n42\n43\n50\n53\n55\n60\nno more data\n```\n\n## Streaming objects\n\nIf you are streaming objects sorting is based on the compare function you can pass as the 3rd argument.\n\n``` js\nconst sorted1 = Readable.from([{ foo:'a' }, { foo:'b' }, { foo:'c' }])\nconst sorted2 = Readable.from([{ foo:'b' }, { foo:'d' }])\n\nconst u = new Union(sorted1, sorted2, function(a, b) {\n  return a.foo < b.foo ? -1 : a.foo > b.foo ? 1 : 0 \n})\n\nunion.on('data', function(data) {\n  console.log(data)\n})\n```\n\nRunning the above will print\n\n``` js\n{ foo: 'a' }\n{ foo: 'b' }\n{ foo: 'c' }\n{ foo: 'd' }\n```\n\n## License\n\nMIT\n","publish_time":1579092905122,"_cnpm_publish_time":1579092905122,"dist-tags":{"latest":"3.2.3"}}