Fix Stream Detection#214
Open
kierangraham wants to merge 5 commits into
Open
Conversation
Author
|
@jimhigson would you be able to give this a review? 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an issue where
oboewould fail to correctly detect that an object was a stream.Previously,
o instanceof Objectwas used to do object detection. Based in the info from this StackOverflow post it's more reliable to do something likeobject !== null && typeof object === "object".That's the change that this PR makes as in a TypeScript project I'm working on for some reason the
isStreammethod returned false when reading a file from S3 and unzipping it, which returned aDuplexWrapperstream object.I've tried to create a test case for this but couldn't quite reproduce it properly; even when I create a simple test to check if my stream object is an
instanceof Objectit turns out to be true. So I'm not entirely sure what's going on specific to this project that makes the streams in Node (12) not an instance ofObject.In any case, this change still fixes my issue even though I don't completely understand why a stream wouldn't be
instanceof Objectand the method of checking that is improved and causes no other side effects, with the full suite passing.Maybe someone with more insights can explain what could be happening.