-
Notifications
You must be signed in to change notification settings - Fork 8
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
helpers: introduce Stream() #31
Conversation
Are you sure you want to implement a thenable ? What about adding a method that returns a promise like stream.wait() |
Ok, a little more complexity and this is now capable of this kind of thing: const streamSource = new Stream(fileSource, zlibTransform)
const streamSink = new Stream(passThrough, fileSink)
const stream = new Stream(streamSource, new PassThrough(), streamSink)
await stream.start() In which I also tried to get rid of @Raynos Is there anything wrong with it being thenable? I guess |
PR for the |
I'm not sure if it impacts debugging. For example, a thenable will not play well with The other issue with thenable is that someone might refactor
To
And then be confused |
I think that |
👍 for adding to |
1a8251b
to
ab44b7c
Compare
Simplified a lot. Also stuff like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks nice to me.
sink = null | ||
|
||
constructor (...components) { | ||
const last = components.length - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider checking for components.length >= 2 here with some kind of assertion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could do more typechecking, but for now that will just make things needlessly more work to read.
Is there an issue with doing Stream(<single component>)
though? Maybe there's a use case for that. But also I suppose we could only expand to that later if necessary.
ab44b7c
to
c9d74ba
Compare
Introduces `Stream()`, a much more user friendly way of composing streaming operations out of bob components. `Stream()`s also act as a bare passthrough to their subcomponents and can be use as a component when composing higher-order `Stream()`s. Relys on the newly added `start(exitCb)` to keep things nice. Refs: #26 PR-URL: #31
landed as 5a460b4 |
To be clear, const stream = new Stream(streamSource, new PassThrough(), streamSink)
await util.promisify(stream.start.bind(stream)) |
Refs: #26
This turned out quite reasonable, I think. I might just like it. (It was pretty easy to implement, worked first try??)