zloirock / core-js

Standard Library
MIT License
24.56k stars 1.65k forks source link

`TextEncoder` and `TextDecoder` #926

Open kvanbere opened 3 years ago

kvanbere commented 3 years ago

There is already good browser support for these, but Node.js does not have these at all, so testing code that uses them is an issue if you're using jest w/ babel or something like that.

Having a polyfill for these that just 'works out of the box' would be great. There's a very good polyfill at the page below.

https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder

zloirock commented 3 years ago

It's not a part of ES, however, it's something that could be useful on each platform. I'll think about it.

zloirock commented 3 years ago

Adding support of legacy encodings is too expensive https://github.com/idiocc/text-decoding/blob/master/src/encoding-indexes.js.

kvanbere commented 3 years ago

Only UTF8 is required by spec now. The best implementation that we've found is the lightweight one linked on MDN.

aleen42 commented 2 years ago

There are some alternatives:

aleen42 commented 2 years ago

I have created https://github.com/aleen42/core-web to try to eliminate different behaviours of Web APIs through different browsers and is there any suggestion or lists of collected polyfill? @zloirock

zloirock commented 2 years ago

@aleen42 you could take a look at the project with the same name from @romainmenke.