You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow ArrayBuffer in uint8ArrayToString() or add a similar method #14
I naively replaced new TextDecoder(data).decode() with uint8ArrayToString(data), in hopes of making use of the decoder cache and keeping my code concise and consistent (i.e. always use the library's decoder or always my own, not mix and match).
However, I immediately ran into an error:
error: Uncaught (in promise) TypeError: Expected `Uint8Array`, got `object
This was caused by the fact that data was not a Uint8Array but rather an ArrayBuffer, as returned by the Web Crypto API encrypt() / decrypt() methods.
Given the function name, I suppose I should've anticipated this, but because TextDecoder handles ArrayBuffers, I thought it would be fine.
How necessary is the assertion in that function? Maybe there could be a new method or option for bypassing that assertion?
changed the title [-]Allow ArrayBuffer in uint8ArrayToString or add a similar method[/-][+]Allow ArrayBuffer in uint8ArrayToString() or add a similar method[/+]on Jul 16, 2024
Activity
[-]uint8ArrayToString is too strict[/-][+]Allow ArrayBuffer in uint8ArrayToString or add a similar method[/+][-]Allow ArrayBuffer in uint8ArrayToString or add a similar method[/-][+]Allow ArrayBuffer in uint8ArrayToString() or add a similar method[/+]