"not sure if useful though"

haha, I wrote that, tested it. (although not with stream interface,
but I could add that easy)

...but never used it.

https://github.com/dominictarr/reducer

I was wanting to make it continuous, so that you could update an item
later, and it would reupdate the total... and have it periodically
emit the result, so that each update you emit the new total.

of course that does require you to remember all the inputs.

maybe it would be useful for aggregating stats out of logs, something
like that...

On Sun, Jun 24, 2012 at 9:08 AM, José F. Romaniello
<jfromanie...@gmail.com> wrote:
> Excellent Dominic, yes! The idea of reduce ( idea, 0 code) was to make a
> readable/writeable stream. For each chunk passed to the reduce, it will
> execute the reduce function, when the input stream ends it will the reduce
> stream will emit one and only one data event with the value of the
> accumulator and it will ends. The example i wrote is totally wrong and
> should be
>
>
> var aFileStream = fs.createReadStream("foo.txt");
> aFileStream.pipe(funs.reduce( function (prev, chunk) { return prev +
> chunk.match(/o/g).length; }))
>              .pipe(funs.map( function (total) { return " total amoun of 'o':
> " + total; }))
>              .pipe(process.stdout);
>
> Not sure if is useful though
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to