{"name":"sorted-union-stream","version":"3.2.1","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":"642ef975b94167ec823185f6c1d193344de19e9a","_id":"sorted-union-stream@3.2.1","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-lM566Be6nsLBJGD4wkt57NtOIueOCAF4pA5bgyCsz8ApverQJips/APK8N02ClCPgKY4n6RRTSiG7spFLJp9fw==","shasum":"98705bf217d444a8a939ecdcd374fe88ab1a8626","tarball":"http://registry-npm.ywwl.com/sorted-union-stream/download/sorted-union-stream-3.2.1.tgz","fileCount":7,"unpackedSize":9357,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCV267MMdoGi7SrWl8cAypc7oP7zUQeJXbzIrKBo/jXawIhAIpMIp2uLPFNY+HyU77T7DP7KgaNb9+PTCenba+ssA0p"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkAKPpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrivxAAgMGiMqC4NRZc29Z2p3JmN317+S0tLFtGfmfb95hp6jyr9Tni\r\nS6eb4yU3CxIqJqGfFjuPfVqh2FfRbnECpjAD6f55D8JbNmeUp80V683JF8JW\r\npVv8I9zG4rTAipVzp81AZIp0PyJpJxVEtccnKRtberiQIg63y+kjTNpiLD8X\r\ny7i/bi0xxw24oeTju6jU+5ADLeF+pHT3DPR4ijMOHvU3aZNb20Y3oFW8YUa7\r\n3c6crGFLXGwFxDOAfT4QeWZ+Pcry46lR3lgOz9U4dIHNvTgTGT2NfJYk/Uu+\r\nNk+9H+d9NUarfcbo2NAoA+xbkV+s3NkwY5HmyHDe881Eh5l40nt00u71IYPX\r\nIfKQJVjGHVtPVaCU+l6uxodjF96oUpWePLthh2SNDN2Ic0qktwM0echQxgYU\r\n3KN78IVby963BteJ20xsUrqibLrVA5Ck5qoWi1zLqhz7F9LOdH1XZSEXHm6F\r\nIRdxhoB4FcOApOlbFUCWpJCYLfz4yJIBU00mOWYTfS3urNXkGH/JpbqedAgJ\r\nQ6AqR0kUiosEF1BTYIalrnSA5Y/W5xLqeQQDxj/WOuj/heyeO4SsAVG8dlO5\r\nvwqqYzhSmfMdwfo21obMTXqLuhaT6Jp4d/67OP+yKArPO45a4pRrKBeNkypH\r\nieFiCeBui1bE31+Z/ywnJyeZe1IcPG7Rc5c=\r\n=Lvgt\r\n-----END PGP SIGNATURE-----\r\n","size":3056,"noattachment":false,"key":"/sorted-union-stream/-/sorted-union-stream-3.2.1.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sorted-union-stream_3.2.1_1677763561376_0.5468291587790768"},"_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":1677763561544,"_cnpm_publish_time":1677763561544,"dist-tags":{"latest":"3.2.3"}}