You should just pipe to them all. reader.pipe(writer1); reader.pipe(writer2);
This takes care of all the drain/pause/resume stuff for you, and is future-portable. In v0.10, streams change quite a lot, and instead of trying to resume on ANY drain, it will only resume once ALL false-returning writers have drained. Also, there are configurable high and low water marks for the writable buffers, so you can decide how much data causes a false write() return, and how little data causes a drain event. If you want more fine-grained control, well, use programming :) On Fri, Feb 1, 2013 at 4:40 AM, Zoid <[email protected]> wrote: > Hi all, > > I convert a single input file into many output files using node.js. How do I > respond to writes returning false and 'drain' events? > > A simple flow control policy is to pause the input stream when any write > buffer overflows and resume when all write buffers are drained. But I can > imagine other policies, such as limiting total size or total count of > outstanding writes. > > My question is: Are there any high-level libraries for such flow control > policies? npmjs.org searches return only synchronization primitives > libraries not designed specifically for multi-stream flow control. > > Andy > > -- > -- > 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 > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- 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 --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
