-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
pass Array Buffer to constructor #39
Conversation
t.equal(b1[1], 1) | ||
t.equal(b1[2], 2) | ||
t.equal(b1[3], 3) | ||
t.equal(b1[4], undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't actually checking the right buffer, b2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do'h all I checked was that it failed without this patch
Hi, thanks for the PR! I don't think this is a good idea (aside from the issues I mention inline) because it would make this module diverge from the node.js buffer API. An ArrayBuffer is not array-like: it lacks a If you have an ArrayBuffer, just wrap it in a Uint8Array before passing it to the constructor and you'll be good. |
so the impetus for this was a bug using level-js (Level/level-js#34) caused by array buffers being turned into zero length Uint8Array objects, there is some code that made me think that you intended to support array buffers, but if you don't would you accept a pull to throw or print a warning if array buffers are given to the constructor (yes strictly speaking a divergence from node, but your more likely to get a typed array in browserified contexts) |
The code you linked is there to support TypedArrayViews like Uint8Array, etc. which have a If level-js claims to support ArrayBuffers here (I don't know if it does), then this is a bug in how it's using this module. It should check if it's an ArrayBuffer and wrap it in a Uint8Array. |
right forgot the typed arrays had both On Fri, Aug 1, 2014 at 8:16 PM, Feross Aboukhadijeh <
-Calvin W. Metcalf |
We can add support for this feature now that node.js#next has support! nodejs/node#2002 |
ArrayBuffer can be passed into the constructor as of buffer 3.4.0. |
vindicated! thanks @feross |
@calvinmetcalf Yeah :) I agreed it's a great idea but want to keep this module exactly in sync with node. I argued to support this - happy it finally landed!! |
No description provided.