-
Notifications
You must be signed in to change notification settings - Fork 8
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
Inclusion on Uint8Array #10
Comments
I agree on this, usually we work with Uint8Array for binary data |
... However, yes, |
Not necessarily, that could end up encoding more data than you want since the underlying buffer can be larger than the view. |
Right, I forgot this use case. |
Agreed, especially in light of #13 - you can "walk" I'm not sure if it should go on |
Starting out with just |
It feels pretty off to me for this to live on Uint8Array specifically given (a) the existence of Uint8ClampedArray as a “sibling” class that’s no less appropriate and (b) the fact that these string codings don’t imply anything about the interpretation of the binary data. A base64 string could as readily encode variable-size-element structured data that only makes sense to read using DataView, say (a real world example of such data people do sometimes transfer using base64: fonts). |
Uint8ClampedArray is definitely less appropriate - it's only for very niche cases where you want to have special behavior on assignment. Uint8Array is the canonical "sequence of bytes" typed array.
Right, which is what makes Uint8Array an appropriate type - it's represents a sequence of bytes. The only difference between Uint8Array and ArrayBuffer is that Uint8Array is a view, which makes it strictly more useful - it lets you read decoded bytes directly, in those cases where that's appropriate, and it lets you encode only a part of a block of memory without doing a copy. |
Closing as settled; this will be on Uint8Array. |
How about also including it on
Uint8Array
? To me, the primary benefit would be to get encodings of subarrays without copying, since TAs are already views.The text was updated successfully, but these errors were encountered: