motion
Version:
motion - moving development forward
66 lines (65 loc) • 3.72 kB
JSON
{
"_args": [
[
"unique-stream@https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz",
"/Users/nw/flint/packages/flint"
]
],
"_from": "unique-stream@>=1.0.0 <2.0.0",
"_id": "unique-stream@1.0.0",
"_inCache": true,
"_location": "/unique-stream",
"_phantomChildren": {},
"_requested": {
"name": "unique-stream",
"raw": "unique-stream@https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz",
"rawSpec": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz",
"scope": null,
"spec": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz",
"type": "remote"
},
"_requiredBy": [
"/glob-stream"
],
"_resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz",
"_shasum": "d59a4a75427447d9aa6c91e70263f8d26a4b104b",
"_shrinkwrap": null,
"_spec": "unique-stream@https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz",
"_where": "/Users/nw/flint/packages/flint",
"author": {
"email": "eugene@noblesamurai.com",
"name": "Eugene Ware"
},
"bugs": {
"url": "https://github.com/eugeneware/unique-stream/issues"
},
"dependencies": {},
"description": "node.js through stream that emits a unique stream of objects based on criteria",
"devDependencies": {
"after": "~0.8.1",
"chai": "~1.7.2",
"mocha": "^1.18.2"
},
"homepage": "https://github.com/eugeneware/unique-stream#readme",
"keywords": [
"stream",
"streaming",
"streams",
"unique",
"unique-stream"
],
"license": "BSD",
"main": "index.js",
"name": "unique-stream",
"optionalDependencies": {},
"readme": "# unique-stream\n\nnode.js through stream that emits a unique stream of objects based on criteria\n\n[](http://travis-ci.org/eugeneware/unique-stream)\n\n## Installation\n\nInstall via npm:\n\n```\n$ npm install unique-stream\n```\n\n## Examples\n\n### Dedupe a ReadStream based on JSON.stringify:\n\n``` js\nvar unique = require('unique-stream')\n , Stream = require('stream');\n\n// return a stream of 3 identical objects\nfunction makeStreamOfObjects() {\n var s = new Stream;\n s.readable = true;\n var count = 3;\n for (var i = 0; i < 3; i++) {\n setImmediate(function () {\n s.emit('data', { name: 'Bob', number: 123 });\n --count && end();\n });\n }\n\n function end() {\n s.emit('end');\n }\n\n return s;\n}\n\n// Will only print out one object as the rest are dupes. (Uses JSON.stringify)\nmakeStreamOfObjects()\n .pipe(unique())\n .on('data', console.log);\n\n```\n\n### Dedupe a ReadStream based on an object property:\n\n``` js\n// Use name as the key field to dedupe on. Will only print one object\nmakeStreamOfObjects()\n .pipe(unique('name'))\n .on('data', console.log);\n```\n\n### Dedupe a ReadStream based on a custom function:\n\n``` js\n// Use a custom function to dedupe on. Use the 'number' field. Will only print one object.\nmakeStreamOfObjects()\n .pipe(function (data) {\n return data.number;\n })\n .on('data', console.log);\n```\n\n## Dedupe multiple streams\n\nThe reason I wrote this was to dedupe multiple object streams:\n\n``` js\nvar aggregator = unique();\n\n// Stream 1\nmakeStreamOfObjects()\n .pipe(aggregator);\n\n// Stream 2\nmakeStreamOfObjects()\n .pipe(aggregator);\n\n// Stream 3\nmakeStreamOfObjects()\n .pipe(aggregator);\n\naggregator.on('data', console.log);\n```\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/eugeneware/unique-stream.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.0.0"
}