Should we use is-stream package?
phated opened this issue · 6 comments
We currently use instanceof
to check if something is a stream. However, the is-stream
module on npm uses stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function'
; should we switch to the external module?
Not all compatible streams inherit from Stream
, and even if they do, instanceof
doesn't work across realms (vm
module contexts).
Yes, definitely ducktype it. instanceof
causes issues in so many places.
On the other hand, people stick pipe
onto things that aren't fully streams compatible (see merge
in event-stream). We've had to de-support libraries like event-stream because of that.
I do agree that instanceof
is generally bad.
Yeah, checking for .pipe is good enough for me - instanceof sucks.
Done