collect-transform-stream
Advanced tools
Comparing version 0.0.1 to 0.0.2
11
index.js
@@ -17,9 +17,10 @@ var through = require('through2') | ||
var that = this | ||
done = once(done) | ||
elements = fn(elements, done) | ||
if (elements) done(null, elements) | ||
function done (err, elements) { | ||
elements.forEach(function (elm) { | ||
var res = fn(elements, done) | ||
if (res) done(null, res) | ||
function done (err, elms) { | ||
// TODO: do something meaningful with err | ||
elms.forEach(function (elm) { | ||
that.push(elm) | ||
@@ -26,0 +27,0 @@ }) |
@@ -5,3 +5,3 @@ { | ||
"author": "Stephen Whitmore <sww@eight.net>", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": { | ||
@@ -23,6 +23,9 @@ "url": "git://github.com/noffle/collect-transform-stream.git" | ||
"devDependencies": { | ||
"concat-stream": "^1.6.0", | ||
"from2": "^2.3.0", | ||
"standard": "~8.3.0", | ||
"tape": "~4.6.2", | ||
"standard": "~8.3.0" | ||
"uniq": "^1.0.1" | ||
}, | ||
"license": "ISC" | ||
} |
@@ -24,19 +24,18 @@ # collect-transform-stream | ||
```js | ||
var collect = require('collect-transform-stream') | ||
var uniq = require('uniq') | ||
var from = require('from2') | ||
var collect = require('concat-stream') | ||
var collectTransform = require('collect-transform-stream') | ||
var source = from.obj(new Array(100).fill(0).map(function () { | ||
var source = from.obj(new Array(500).fill(0).map(function () { | ||
return Math.floor(Math.random() * 10) | ||
})) | ||
var dedupe = collect(function (nums) { | ||
var dedupe = collectTransform(function (nums) { | ||
return uniq(nums) | ||
}) | ||
source.pipe(dedupe) | ||
var dest = collect({encoding:'object'}, console.log) | ||
dedupe.on('data', function (n) { | ||
console.log(n) | ||
}) | ||
source.pipe(dedupe).pipe(dest) | ||
``` | ||
@@ -43,0 +42,0 @@ |
3502
44
5
84