-
Notifications
You must be signed in to change notification settings - Fork 41
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
Offer a SonicBoomWritableStream class that can be pipelined with other streams #144
Comments
what errors are you getting? can you add a simple snippet to repro? |
import {pipeline} from "stream/promises"
const sonicBoom = new SonicBoom({dest:`${outDir}/base_amounts.xml`})
await pipeline(aReadStream, transform1, transform2, sonicBoom);
It's a Typescript error, but the node docs for pipeline() don't indicate one can use an EventEmitter as a destination. https://nodejs.org/api/stream.html#streampipelinestreams-callback |
My understanding is that it should work |
it's just a TS issue, would you like to send a PR? |
This works on Node 16, so it might be a @types/node issue: const { pipeline, Readable } = require("node:stream")
const SonicBoom = require("sonic-boom")
// works
Readable.from("Hello pipe()!")
.pipe(new SonicBoom({dest: "./pipe.txt"}))
// works
pipeline(
Readable.from("Hello pipeline()!"),
new SonicBoom({dest: "./pipeline.txt"}),
() => console.log("done")) It might not be a typing issue however, as the pipe/pipeline code calls utils.isWritableNodeStream() and a SonicBoom instance looks like one: So I'm not sure how to file an issue with @types/node to fix this, since |
I concur with your analysis. What's missing in |
Would you like to send a PR to document this in the README? So at least other people will know they have to cast. |
I think I'll try creating a |
It looks less-disruptive to expand SonicBoom and add the WritableStream methods instead of making a separate class. Any objections? |
I don't think there is a need for any code change, a cast is totally ok and not bad. |
I want to use SonicBoom with nodes' pipe() and pipeline() functions, but as an EventEmitter, it cannot play directly. A SonicBoomWritableStream would have the extra methods to make it a pipeline able data sink.
Perhaps an easy node wrapper exists that I'm not aware of?
The text was updated successfully, but these errors were encountered: