{"name":"sorted-union-stream","version":"2.1.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":{"from2":"^1.3.0","stream-iterate":"^1.1.0"},"devDependencies":{"standard":"^3.3.0","tape":"^3.0.0"},"bugs":{"url":"https://github.com/mafintosh/sorted-union-stream/issues"},"homepage":"https://github.com/mafintosh/sorted-union-stream","main":"index.js","gitHead":"43d0e2666bd97c0ab835fc4d1710204a9fda1573","_id":"sorted-union-stream@2.1.1","_shasum":"55f3facf6e18a2555797639546fc535e5cd99049","_from":".","_npmVersion":"2.7.5","_nodeVersion":"1.6.4","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"dist":{"shasum":"55f3facf6e18a2555797639546fc535e5cd99049","tarball":"http://registry-npm.ywwl.com/sorted-union-stream/download/sorted-union-stream-2.1.1.tgz","integrity":"sha512-XuaNn7ltriLCEqB/FKaUu8SqEMfY2tJFv+k64WbVsXwoQadkkT3A7Ma0QToMw1GAwnwifjZ1YtJ4n5oDiM3xpw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAcE7lvxlADY4orVk7K1C+xgZqKV5fg7YVH9EwZOONNpAiEA4abgc/bjB+/Pb5YVOjPT/Qk7XBhNp8SNhx1EGYh/7u8="}],"size":2738,"noattachment":false,"key":"/sorted-union-stream/-/sorted-union-stream-2.1.1.tgz"},"directories":{},"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":1428527789634,"_cnpm_publish_time":1428527789634,"dist-tags":{"latest":"3.2.3"}}