capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.4k stars 205 forks source link

Support `Uint8Array` in TextDecoder: decode() method #1259

Closed aralroca closed 9 months ago

aralroca commented 9 months ago

Reading an stream and decoding Uint8Array (a valid ArrayBuffer), is throwing an error. However in the browser it works fine because Uint8Array is an ArrayBuffer

const text = new TextDecoder().decode(value);
               ^
TypeError: TextDecoder.decode expects an ArrayBuffer or TypedArray
 code: "ERR_INVALID_ARG_TYPE"
aralroca commented 9 months ago

I closed it, it was my problem that was not well mocked and returned a string instead of Uint8Array