{"name":"sorted-union-stream","version":"3.2.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":"bba7eedc71b7327dd46d12282fbee04e6ed06628","_id":"sorted-union-stream@3.2.0","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-Z7PM2tKh0XVK0+PfaLwZ5qlgNfi8vnv1KLVxXFTcujk4MhN+m77WoyqTNP08F1mhd8HNo2181HpXTJ2JeUiTiw==","shasum":"816132c99c9c6e902a0c3d2687e2409a7dec56fe","tarball":"http://registry-npm.ywwl.com/sorted-union-stream/download/sorted-union-stream-3.2.0.tgz","fileCount":7,"unpackedSize":9281,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH+EflKTgQKj3Hxkf+vX5maY6Qt3ZSXPDsN1TDbod9bNAiBWthyCzh2wclfhJ0qmYoFhz+chsTvzbr+kt1gjDeuXZQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkAKESACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqkOBAAoMCv/PBP+Pj7QidDSBc7nYk1TnykUULZUq4xTSNokh35d6F3\r\nto3y6anu5C6sBxDCsEpVsfItBNx0V2WLTXRTjs3uNd6LIwopYu3cUors7CT9\r\nsXoMHTvKqeeei7UhGkSXLL4oGfenuS4L85JqJbgIe9aJHDOxoefLCbV9W84P\r\nGOPnxl0SaexcycdtIJCsxMNqXlTj6HA5BcaXvQvI+B8AkWffs7tkpOD/fdd6\r\nACuo1q1K/XTrpHr9KQB2MIF7JPC8g9HcKyrRSvZpw6v1licsJzdKtrXmS2er\r\nS5f8mbLV4ypaXYdQ2LVuqoFH0bByfQjkKEf+qNr590VaZjXyTvT7wYi5fE8f\r\n7zoSuvRIuc3TPndYcNUKsLSkTTV8+PidtN2dt7+knDAVnEohY02EddSmOKx0\r\n38zNQhFRJyh1zEVqd6QnEm4N3lnhz3yXJR3CrS/YPR11SSadbbrnSsF1B6+Y\r\n6lA8+Pi7XNPdDeMQPNKm10alvHALnRfXAECQN1q6f9MoNBUVy+YSepYHQp0P\r\nV9wPzw5YdoyJvVJeQSEge0jj99ZAAGpaRvdRv+zcbsEbPgA0ZHeDd8OvC+m1\r\nI2V584BfP2kN/LbdGtY3y/lfaCy4FyHCyxcEWzfxHXVKVdZW19DmQPOxr2cX\r\nmtx+JLd+q8JypCCa2wdG5zbErXVQ9WgQY8s=\r\n=kOxd\r\n-----END PGP SIGNATURE-----\r\n","size":3029,"noattachment":false,"key":"/sorted-union-stream/-/sorted-union-stream-3.2.0.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.0_1677762833879_0.961305593106033"},"_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":1677762834052,"_cnpm_publish_time":1677762834052,"dist-tags":{"latest":"3.2.3"}}