Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

ArrayBuffer views should be recognized as binary data and treated respectively #128

Closed
Gozala opened this issue Jun 9, 2020 · 3 comments

Comments

@Gozala
Copy link
Contributor

Gozala commented Jun 9, 2020

At the moment Uint8Array (or any other view of ArrayBuffer seems to be treated as array of numbers)

function transform (obj) {
if (!obj || Buffer.isBuffer(obj) || typeof obj === 'string') {
return obj
}
if (Array.isArray(obj)) {
return obj.map(transform)
}
if (CID.isCID(obj)) {
return tagCID(obj)
}

This causes issues when things are moved across the message channel, because even fields that were Buffer's come up as Uint8Arrays on the other end. For this reason I would like to propose a change which would treat Uint8Array (and I'm inclined to suggest other ArrayBuffer views as well) as a binary data instead (same as Buffers is treated today).

It is worth pointing out that ArrayBuffer itself will appear as {byteLength:number} which I don't think is ideal, but probably out of scope.

@vmx
Copy link
Member

vmx commented Jun 10, 2020

Fixed by #129.

@vmx vmx closed this as completed Jun 10, 2020
@Gozala
Copy link
Contributor Author

Gozala commented Jun 10, 2020

@vmx who's going to publish to npm ? I need to propagate thes into js-ipfs to be able to integrate into ipfs/js-ipfs#3081.

Would you mind posting here or in the mentioned pull once it's makes to npm so I can propagate ?

@vmx
Copy link
Member

vmx commented Jun 12, 2020

I already published it right away, it's v0.15.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants