-
Notifications
You must be signed in to change notification settings - Fork 124
RFC: Support ArrayBuffer as an alternative to Buffer input argument #404
Comments
We've had multiple issues opened about this. People expect to be able to use them, are confused when they cannot and also, do not understand the difference between them and |
I'm in favour of it. Side note: It's also something that came to my mind. I'm thinking about using |
@vmx I think the discussion about outputs is more complex and interesting, especially if you account for things that could land in the future eg. "zero-copy" ArrayBuffer pass from JS-land to WebAssembly-land etc. If you think IPLD will need to tackle that decision soon, please create a separate issue for discussing ArrayBuffer in outputs. I feel we don't want to block input improvements by pending decision on outputs. :) |
How about expanding what's accepted to array-like objects? |
@achingbrain are you able to unpack that idea by providing an example? Do you mean objects with length and indexed items being |
Sort of - I was thinking anything you can use in a for-of. We’d have to handle strings as a special case where node should interpret them as paths though, obvs. |
This has been implemented - if there are more formats to support, please open a PR against js-IPFS with a failing test for the |
Status
Right now we accept
cid
,multihash
anddata
asBuffer
in various places across entire JS API. It makes sense for Node.js and there was no better alternative for use in browsers at a time.The landscape changed and we now have native vendor support for
ArrayBuffer
in web browsers:Proposed API Improvement
Short and sweet:
ArrayBuffer
as input in every API that acceptsBuffer
right now.Why?
Buffer
support remains)ArrayBuffer
toBuffer
for now)Buffer
polyfilRefs
ArrayBuffer
(browser compatibility)TypedArray
(browser compatibility)cc @alanshaw
The text was updated successfully, but these errors were encountered: