Open dmitrizagidulin opened 3 years ago
See also the performance discussion over at https://github.com/digitalbazaar/base64url-universal/issues/4
"Buffer instances are also JavaScript Uint8Array and TypedArray instances. All TypedArray methods are available on Buffers." -- https://nodejs.org/api/buffer.html#buffer_buffers_and_typedarrays
There are small incompatibilities... don't know if that affects this library or the tests? What concrete issue is this type difference resulting in?
@msporny - right, Buffers are instances. But there's still small differences in behavior that masked a bug downstream (in our jsigs libs). Now, I've fixed the bug downstream, so for the moment, we don't have to fix this issue.
However, I would at very least like to spell it out explicitly in the README - that in the browser, decode()
returns a Uint8Array, and in Node.js, it returns a Buffer, which is technically also a Uint8Array, but there may be some behavior differences.
The
decode()
function is returning a different type based on environment.In Node.js:
In the browser:
Need to fix it so that it returns Uint8Array in Node.js too.
Also, I did NOT know that
JSON.parse()
works on a Buffer without throwing an error. (But not on a Uint8Array, turns out).