Closed rhodgkins closed 2 years ago
The check in question is to make sure that arguments are functions, arrays, or streams. As far as I can tell StreamProxy
(and duplexify
) are objects, which do not implement stream protocols and are not based on any standard Node stream.
duplexity
uses readable-stream
which is a package mirroring the standard Node streams implementing all the stream protocols based on the standard Node stream.
Mirroring is not "the same". Obviously, I cannot include all possible class names of all possible third-party packages in my code for practical reasons. Alternatively, you can ask the developers of the third-party streams to base their classes on Node streams.
If you have another reasonable solution, I would love to hear it.
I'd disagree its third party as its ported from NodeJS, anyway what about matching NodeJS checks for streams?
There's no need for the instanceof Transform
if its a Duplex
stream, so check could just become:
if (
isDuplexNodeStream(fn) ||
(!index && isReadableNodeStream(fn)) ||
(index === fns.length - 1 && isWritableNodeStream(fn))
) {
return fn;
}
throw Error('Arguments should be functions, arrays or streams.');
Sounds like a plan. I'll add it to the next release.
Released as 2.2.5.
Hi,
I'm trying to use this library in relation to a streamed Google gRPC response that uses
StreamProxy
(andduplexify
), but there the below check when creating a chain that prevents this...https://github.com/uhop/stream-chain/blob/49b851fa38c0a53f6c62fa3859a0bfbb4f7008be/index.js#L97-L105
Any ideas on a way around this? (Currently wrapping a pointless
PassThrough
with theStreamProxy
in aNodeJS.pipeline
to get around it but this isn't ideal obviously!)