New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v2 ideas #15
Comments
I'm 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 Promises and generators would just add clutter to this relatively simple API. |
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) ? |
What about streams2 implementation?? |
@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. |
you asked to help maintain this library, so here are some thoughts:
readable-stream
.getBody
. prefer if it were like.pipe(cat.string())
,.pipe(cat.buffer())
, etc. by default,.pipe(cat())
should just return an array of all the things. developers should know the type of source stream and how they wish to consume the data.cat(stream, callback)
, basically juststream.pipe(this)
callback(err, data)
- it's a callback, not an event listener, so imo it should haveerr
as the first argument. however,err
should always benull
since concat-stream should never have any errors (i get How to handle errors without err callback argument #6 (comment)) unless we decide to throw errors when there are crazy typing issues. we can do crazy stuff like checklistener.length
but i'm not a fan of that either.cat-stream
and the final stream.yield stream.pipe(cat())
support. not sure how to do that yet - maybe duck type it into a promise.The text was updated successfully, but these errors were encountered: