Unable to create chain with StreamProxy (duplexify)
rhodgkins opened this issue · 6 comments
Hi,
I'm trying to use this library in relation to a streamed Google gRPC response that uses StreamProxy
(and duplexify
), but there the below check when creating a chain that prevents this...
Lines 97 to 105 in 49b851f
Any ideas on a way around this? (Currently wrapping a pointless PassThrough
with the StreamProxy
in a NodeJS.pipeline
to get around it but this isn't ideal obviously!)
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.