{"name":"sorted-union-stream","version":"3.2.3","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":"4cad321f8847920b7e9cdf63902ed2fd574f913d","_id":"sorted-union-stream@3.2.3","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-8wbehFBja6u/eVlrn87J9ybABl+BUcpG/Om/uu9yYQcHOzhPi779wkRX61OpgAy1Y9/smkGtlOW/m7oyfAhv+g==","shasum":"c47a0b8f16c4674aac6b786bc43e29c8d2d40c16","tarball":"http://registry-npm.ywwl.com/sorted-union-stream/download/sorted-union-stream-3.2.3.tgz","fileCount":7,"unpackedSize":9830,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFXWybwnwxS4zcjcTagGuH/i5O4T3D/Rjzogj1XWb5ghAiAu4ac9TvQyRHKuMnSGwBFV+zAU5OtGg5T53LOK7QsTJg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkCbfRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpFeg//fn/eD1nlJ+9MtAyae60QntnXwt5M8mSmy+CyAmHI3uLHktP8\r\n6OC7l7kZA2/eQiNVWeFCPh093ab7ZE26EfV3OqmehkaECiKtA0uOMxrhW6I7\r\ngT9AJcNyTQomHVi82RSbOVEmJkp3m9YLSgtjBq1RBcwbez023fFEm53wUstT\r\nU51WWB4CtVTSNyTQMuQeDWlK8p4nyAIWy0oX9A8gs7d/J+hVXjCk8hx645tE\r\n3zUN+nC10Sdf7qSXWKw0sIblokxhDFZf7UhZYw6RcpGFwPdOVxkT4OHC1Rkz\r\nUFzNtTe57OMYnyZcwkeqclKoaNF9TKfJ/VKacB4HOYeE5O46+yRrbPq6arat\r\nH2yV6KgQjBHUT4rZJg+uGTgYEt8U+H30p4lzc5+x4xJEzKJoEQpB++yG5sGm\r\njO//QPAr5DfkuYApVat49CeziDOVvVa1TKuVbMwClYle/wAIbsp5Vp8f9zko\r\nEi97uq1LPMguNXGJJLyxR8JfJgItTdHxTz6mkJxbLUreQdRLyrdM5/PpK2O1\r\nFAwye4Xa7vbj+hPWaszsE+R5h/Rt0XJb5OtJG3oWA0pCBUi775QIs+M6woT4\r\n2PIMh25MdCeepn6t9cwJoRMdR2rEw/u+uVCacBeOYkYCAfLpg7XoYoYoju+2\r\nwch5rhXDRKgq4F+l4pOiMFck2hutr1L3Ufo=\r\n=9kJX\r\n-----END PGP SIGNATURE-----\r\n","size":3173,"noattachment":false,"key":"/sorted-union-stream/-/sorted-union-stream-3.2.3.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.3_1678358480726_0.12984994063072364"},"_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":1678358480969,"_cnpm_publish_time":1678358480969,"dist-tags":{"latest":"3.2.3"}}