-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Don't treat buffer any specially #40
Comments
This would be a breaking change. Going by the implementation, I think the Although the comment is confusing: Lines 119 to 122 in abab085
In modern browsers, isBuffer(new Uint8Array()) // => false
isBuffer(new Uint8Array().buffer) // => false I'm not familiar with the history of Safari - I can't say if it actually had a What I can say, is that buffers in the browser are represented by the Futhermore, types such as To illustrate that point: new Uint8Array() instanceof ArrayBuffer // => false
new Uint8Array().buffer instanceof ArrayBuffer // => true These view-types aren't compatible either - describing them as broadly as "buffers" would likely be confusing more than useful. Note that the browser provides a standard API for type-checking those: ArrayBuffer.isView(new Uint8Array()) // => true I would vote to close this issue. |
Unless there's a good explanation for it, I would also suggest that the mentioned comment be removed. |
On that same note, I think a mistake was made here: Lines 12 to 14 in abab085
This has all the same problems I described above - if someone doesn't know this implementation detail, and wants to check if something is a function, they might write a condition like If someone did want to check specifically for generator functions, you do of course have this function: Lines 96 to 98 in abab085
However, this is also unreliable, for the same reasons described above - if you needed to check if something is a generator (or more likely an iterable/iterator) the only reliable way to implement that, is to check the returned value after calling, so it's probably not even a feature that should exist. Of course, this would be a breaking change, which is unfortunate - on the other hand, if someone had to upgrade, they would be made aware of a likely source of bugs in their programs, so it might be for the better. |
My plot was that it's bad to encourage user to rely on If I where to treat i don't want to give node:buffer any special treatment |
kind-of/index.js
Line 124 in abab085
Uint8Array works better cross Deno & browsers, really think you should make a
instanceof
check instead...The text was updated successfully, but these errors were encountered: