emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.84k stars 3.31k forks source link

Simplify decodeBase64 polyfill if drop IE9? #15518

Open MaxGraey opened 3 years ago

MaxGraey commented 3 years ago

As I understand this original part of decodeBase64 polyfill was written 11 years ago: https://github.com/emscripten-core/emscripten/blob/4a9d5ab94f66b629b99c1104663bedbc80f799c1/src/base64Utils.js#L11

Nowadays it could be simplify to this:

var decodeBase64 = typeof window !== 'undefined' && typeof atob === 'function' ? atob : function (input) {
  return Buffer.from(input, 'base64').toString('binary');
}

It always forces to use Buffer for node.js where atob didn't exist before v16.0.0 but still not recommend. For the rest platforms: all browsers and Deno atob present for a long time. Only exception is IE 6, 7, 8 and 9. And here the question is, are you still going to support IE9?

kripken commented 3 years ago

Good point, thanks. I opened #15526 - we don't support any IE version by default, and can ifdef this out.