Skip to content
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

detect .pipe instead of using instanceof #1

Closed
wants to merge 1 commit into from
Closed

detect .pipe instead of using instanceof #1

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 7, 2014

Using instanceof is problematic since it means that any compatible alt streams implementations that would interface cleanly with core streams won't be properly detected.

In a browser context, importing stream just to check instanceof is especially problematic since you end up with multiple different copies of stream implementations, duplicating many bytes over the wire.

Instead, I propose just making sure that obj is an object and that it has a pipe method that is a function. Where I have written this functionality elsewhere, that approach has proved plenty adequate.

@mifi
Copy link

mifi commented Jan 29, 2021

sindresorhus' is-stream has the duck typing pipe check approach:
https://github.com/sindresorhus/is-stream/blob/23a6c15f83866c3c59f509d7515ab43ed8e6e367/index.js#L6

Repository owner closed this by deleting the head repository Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants