{"name":"sorted-union-stream","version":"3.1.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":"dc4d64ab1d3bbc19607d65435a327822f5e89339","_id":"sorted-union-stream@3.1.0","_nodeVersion":"16.1.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-9oiw1iiuBIo0sCMEnS1pfiEs7GP+K5u9Wam+S3aUw1fEQikXlkxwJOSPN4VlBW4Pjv1ZSsE8TtTlOkZCtVS7Lg==","shasum":"f7ebf5ab49161047aa2ac4dd68df2ae0c1eb0567","tarball":"http://registry-npm.ywwl.com/sorted-union-stream/download/sorted-union-stream-3.1.0.tgz","fileCount":7,"unpackedSize":9076,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhL045CRA9TVsSAnZWagAAuH4P/3wj4iCzuqJtlXWmDWEE\n34BdMUndNAQw2Mj8G4IutapTiuFxr5lTjgezPh+CC3qoQecSacUVRyR+yZcj\nbT7ACIO4EDmmHWP+toTyFRtW0r/E2NSpk+hUjB63KSGzYkEHRRC6LgIlqKrf\nNt3raVVsVWideabcZs+w90HU/AoN1GPPJyKGk56iLbv6srplbO7LCZ6xdTey\noblVRP/XS9lah90D+HQY3Z5f22rJHJelPYWWdLkvfBjIkFeC5fpNUeL5rJv9\nDULiwtPz100dg4XVteiN/MlaKSiZLUfDFCP7lez/Im2ojF0/pZ/t+5SnTpFA\nA9K01p0egX/YsITc+DrXo3mz5jct6qL1CMzgZyWYvmZG1F5n92a30lTL+bOq\nn7nZseWKJmxe7br9FcolFOBUykVjOG4Pf3KGdJpchGi8igr2+xjDuZD8HUGF\n9AisTn4KmwXl6lN4arndUWNg+Jd7+nFxkj74IbU8Xt8F2BIjn9rqT7ODx7y+\nSMf6hyLZk9AM04CXSdQ9NB/oeq6neY8oo1G7wQNazA7c4n6uqNR7aCHy04N6\nuqSFCyprs/b8d0jEzyLAfsH3fjpHgo266/e8StK+T4GHFj/tWGA4KqLL1wWu\nI8wEnSeyNv7MI61OkLjsOM3dh936x6p1tWyTHUISL+n9iu2+mInXDSzg19p0\nUOUL\r\n=nvY2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF2y0olRN4DEYvQuMfNdn2gUiEazYZj+pSkE8+3P1WuwAiEA8hV3AqGsy8zz1q8Yz9MFY5mmWSMancZVgZ9J/JCEXHQ="}],"size":3019,"noattachment":false,"key":"/sorted-union-stream/-/sorted-union-stream-3.1.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.1.0_1630490168940_0.5580082798705677"},"_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":1630490169267,"_cnpm_publish_time":1630490169267,"dist-tags":{"latest":"3.2.3"}}