gulpjs/vinyl

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?

cc @contra @sindresorhus

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.

I'd like to get @contra's thoughts though.

Yeah, checking for .pipe is good enough for me - instanceof sucks.

Done