microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.23k stars 12.52k forks source link

base64/hex methods missing from `Uint8Array` #60612

Open printfn opened 15 hours ago

printfn commented 15 hours ago

⚙ Compilation target

ESNext

⚙ Library

ESNext

Missing / Incorrect Definition

Uint8Array.fromBase64() Uint8Array.fromHex() Uint8Array.prototype.setFromBase64() Uint8Array.prototype.setFromHex() Uint8Array.prototype.toBase64() Uint8Array.prototype.toHex()

These functions are implemented in stable Firefox and in the Safari Technology Preview.

Sample Code

new TextEncoder().encode('Hello World').toBase64()
// "SGVsbG8gV29ybGQ="

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toBase64

https://github.com/tc39/proposal-arraybuffer-base64

xiBread commented 14 hours ago

I would argue that support in a beta version does not fully count as "two or more major browser engines."