Appending one more chunk to the end of a stream.

53 views
Skip to first unread message

Scott Corgan

unread,
Jul 31, 2013, 1:54:44 PM7/31/13
to nod...@googlegroups.com
Been sitting on this one for awhile and can't seem to figure it out or find anyone that has a solution.

I just need to append one more chunk to the end of a stream. At first, I thought I was successful using the "through" module, but for some reason, it kept appending the new chunk in the middle of the stream.

Any direction would be helpful, thanks.

Michael Ryan

unread,
Jul 31, 2013, 2:01:51 PM7/31/13
to nod...@googlegroups.com
Couldn't you override the end() method to push your last chunk, then call the original end?


Date: Wed, 31 Jul 2013 10:54:44 -0700
From: scott...@gmail.com
To: nod...@googlegroups.com
Subject: [nodejs] Appending one more chunk to the end of a stream.


Been sitting on this one for awhile and can't seem to figure it out or find anyone that has a solution.

I just need to append one more chunk to the end of a stream. At first, I thought I was successful using the "through" module, but for some reason, it kept appending the new chunk in the middle of the stream.

Any direction would be helpful, thanks.

--
--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
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 nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michael Ryan

unread,
Jul 31, 2013, 2:07:24 PM7/31/13
to nod...@googlegroups.com
premature send...

//assume var originalOutputStream
var originalEnd = originalOutputStream.end
originalOutputStream.end = function(data) {
  originalOutputStream.write(data);
  originalOutputStream.write(finalData);
  originalEnd.call(originalOutputStream);
}


From: mygr...@tracker1.info
To: nod...@googlegroups.com
Subject: RE: [nodejs] Appending one more chunk to the end of a stream.
Date: Wed, 31 Jul 2013 18:01:51 +0000

Scott Corgan

unread,
Jul 31, 2013, 2:12:34 PM7/31/13
to nod...@googlegroups.com
That looks like it would work. Tried it, and I'm getting my chunk put into the middle of stream, instead of the end. I'm using the "node-trumpet" module to parse html.

I filed an issue for the module, so I'm not sure if it's the module or my code.


You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/P-ZA-iJts2E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
- Scott

Floby

unread,
Aug 1, 2013, 4:16:35 AM8/1/13
to nod...@googlegroups.com
mySource.pipe(myDestination, {end: false});
mySource.on('end', myDestination.write.bind(myDestination, myChunkIdLikeToAppend));


or

var StreamStream = require('stream-stream');
var chunkStream = new require('stream').PassThrough();

var ss = new StreamStream();
ss.write(mySource);
ss.write(chunkStream);
ss.pipe(myDestination);
chunkStream.end(myChunkIdLikeToAppend);

Floby

unread,
Aug 1, 2013, 4:17:23 AM8/1/13
to nod...@googlegroups.com
Sorry, the second line should look like
mySource.on('end', myDestination.end.bind(myDestination, myChunkIdLikeToAppend));


On Wednesday, 31 July 2013 19:54:44 UTC+2, Scott Corgan wrote:

Scott Corgan

unread,
Aug 1, 2013, 1:03:04 PM8/1/13
to nod...@googlegroups.com
Thanks!


--
--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
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 a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/P-ZA-iJts2E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
- Scott
Reply all
Reply to author
Forward
0 new messages