Look at the implementation of pipe. Rewrite it so that it reads from multiple inputs.
The key points here is calling read with a fixed n and then calling write on the output with a list of buffers. If any readable stream returns less then n keep the chunks around until that stream is readable then alter your read(n) calls to get up to your n again and then call write. Pipe's default logic is to end the writable when the first readable ends. You may want to change that. On Tue, Dec 18, 2012 at 7:10 PM, Alex <[email protected]> wrote: > Hi all, > > I am trying to synchronize multiple read Streams so that I can process > equivalent bytes from them. For example, if there are multiple input > streams created with fs.createReadStream(), I need to process bytes from > the same position in all the files into a new value that is written to an > output write Stream. I'm trying not to use Buffers, because I want to > handle a potentially large amount of data. I could use fs.read() for the > case of input files and just read from the same position in each file, but > I want this to be general and operate on generic streams that are not > necessarily formed from a file. > > Is this possible? Are there any solutions out there that have the same or > similar functionality? > > Thanks in advance for any help. > > > -- > 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
