Code Monkey home page Code Monkey logo

Comments (4)

 avatar commented on June 25, 2024
  • cb(err, data) is annoying if there isn't ever an error. Why not just omit that parameter like it presently is?

I'm -1 on the .pipe(cat.string()) and .pipe(cat.buffer()) features but agree that getBody is too complex.

browserify v3 uses a typed array backed data structure for Buffer now, so you should just always get back a buffer or if the stream has been set to objectMode, you should get an array of objects. That would greatly simplify the getBody decoding.

Promises and generators would just add clutter to this relatively simple API.

from concat-stream.

jeromew avatar jeromew commented on June 25, 2024

should this library be able to concatenate streams - a bit like what https://github.com/felixge/node-combined-stream ?

if yes, I don't understand "concat-stream should never have any errors" because shouln't concat-stream handle the errors of the underlying streams to report via cb(err, data) ?

from concat-stream.

q2dg avatar q2dg commented on June 25, 2024

What about streams2 implementation??

from concat-stream.

zenflow avatar zenflow commented on June 25, 2024

@jeromew this library is able to concatenate all the data within a single stream into a single datum (string, buffer, etc).

For the record, regarding error-catching ... (since I had to test this to find out)

If you pipe a readable stream to this or any other writable stream (with Readable.protototype.pipe), errors will not be piped downstream along with the data.

When using this library, you must handle upstream errors yourself

function getSomething (cb) {
  var readable = getReadableStream();
  readable.on('error', end); // <--- handle upstream errors
  readable.pipe(concat(function(data){
    end(null, data);
  }));

  var ended = false;
  function end (error, data) {
    if (ended) return;
    ended = true; 
    cb(error, data); 
  }
}

Besides any upstream errors, there are no other errors to expect.

from concat-stream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.