concat-stream icon indicating copy to clipboard operation
concat-stream copied to clipboard

concat-stream - buffer object in callback is empty.

Open sharmalalit opened this issue 11 years ago • 4 comments

See the following piece of code.

   var  concat = require('concat-stream');
   var src = // some stream which contains non-utf-8 content for ex : shift_jis
   var dest = // it is destination stream
   var concatStream = concat(function(buffer)) {
     // buffer is empty string here. It is not readable while debugging as well.
    // I want to do some modifications in this buffer.
    dest.write(buffer);
    dest.close();
   }

On browser I see response is coming back but none of the modifications were made to the content. If I try to debug buffer is empty string in callback.

sharmalalit avatar Oct 11 '14 05:10 sharmalalit

you have to do src.pipe(concatStream). Also I am not sure what dest is in your example, concatStream should be the destination

max-mapper avatar Oct 11 '14 06:10 max-mapper

Yes I missed mentioning I am doing src.pipe(concatStream) . dest is some other final stream or destination where I want to write the data back,

sharmalalit avatar Oct 11 '14 06:10 sharmalalit

Oh I see. It seems your code should be working, without a test case that reproduces the problem I am not sure I can help any further.

max-mapper avatar Oct 11 '14 06:10 max-mapper

Thanks. Will get back to you with a test code.

sharmalalit avatar Oct 11 '14 06:10 sharmalalit