Skip to content

Instantly share code, notes, and snippets.

@lanwin
Created August 6, 2013 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanwin/6162964 to your computer and use it in GitHub Desktop.
Save lanwin/6162964 to your computer and use it in GitHub Desktop.
Nodejs merging object streams. Here is my current working example. But I dont like it. A MergeStream with one 'end' event would be much better. A sidenode: FeedParser implements node TransformStream and set its objectmode to true so that in the end we stream objects instead buffers. This could be better solved with RxJS. But what I currently don…
var data = [];
exampleFeeds.forEach(function(feedFile) {
fs.createReadStream(feedFile)
.pipe(new FeedParser())
.on('meta', function(meta) {
data.push(meta);
if(data.length===exampleFeeds.length){
console.log('done '+data.length);
// do something
}
});
});
@dominictarr
Copy link

I think plenty of people have written merging streams, this one looks right https://npmjs.org/package/merge-stream

@goloroden
Copy link

@dominictarr Thanks for pointing this out, looks great :-)

@MikeBild
Copy link

MikeBild commented Aug 6, 2013

+1

@lanwin
Copy link
Author

lanwin commented Aug 6, 2013

Thx that works like I expect. I dont know why I dont got this. Ive tried this one https://github.com/felixge/node-combined-stream which dose not work like I am expecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment