I have a collection of functions similar to this here:

https://github.com/dominictarr/event-stream

you need to add `destroy`, and should add `pause` and `resume`.

this may be helpful: https://gist.github.com/2850882

it's my best effort at defining the correct behaviour for streams,
such that pipe will work correctly.
it's not official of course, its just constructed from
reading node/lib/stream.js and so on, and figuring it out.

cheers, Dominic

On Sat, Jun 23, 2012 at 10:23 PM, dolphin 278 <[email protected]> wrote:
> Good day
>
> I did not found any modules to easily wrap any function to stream interface,
> so i made my own. Point is to have an option to pipe streams to different
> filters and transformations, without describing stream interface from
> scratch every time.
>
> Usage:
>>
>> var FuncWrapper = require('pipemaster').FuncWrapper,
>>     streamFunc;
>> function asyncExample(x, callback) {
>>    callback(null, x * x); // first argument is an optional error.
>> }
>> streamFunc = new FuncWrapper(asyncExample);
>> streamFunc.write(2);  // streamFunc emits '4'
>> streamFunc.write(6);  // streamFunc emits '36'
>
>
> There is another class for easy filtering, called StreamFilter for em, easy
> filtering :)
>>
>> var StreamFilter = require('pipemaster').StreamFilter,
>>     streamFunc;
>> function filterAsync(item, callback) {
>>     callback(null, item === 4);
>> }
>> streamFunc = new StreamFilter(filterAsync, true);
>> streamFunc.write(1);
>> streamFunc.write(4);
>> streamFunc.write(2);
>> // streamFunc emits only '4'
>
>
> Installation, as always - npm install pipemaster, github link
> - https://github.com/dolphin278/pipemaster/
>
> Hope it would be helpful for someone :)
> ------
> Boris Egorov
> skype/gtalk/nickname: dolphin278
> mobile: +7 905 728 1543
>
> --
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to