ConstPure-JavaScript base64 decoder, exported for benchmarking and for
environments where the native TC39 Uint8Array.fromBase64 intrinsic
(proposal-arraybuffer-base64) is unavailable or has been removed.
See decodeBase64 below for the dispatched default.
XSnap, a JavaScript engine based on Moddable/XS, runs this polyfill
orders of magnitude slower than V8.
Older XS builds expose a native globalThis.Base64 binding that the
dispatched decodeBase64 uses ahead of the polyfill on legacy
Agoric chain XS; going forward, XS is expected to favor the standard
Uint8Array.fromBase64.
This function is exported from this file for use in benchmarking, but is not part of the module's public API.
Base64-encoded string
Optionalname: string = '<unknown>'The name of the string as it will appear in error messages.
decoded bytes
Decodes a Base64 string into bytes, as specified in https://tools.ietf.org/html/rfc4648#section-4.
Dispatches to the native
Uint8Array.fromBase64intrinsic when available (stage-4 TC39 proposal-arraybuffer-base64). Otherwise falls through to the legacyglobalThis.Base64.decodeXS binding, and finally to the pure-JavaScriptjsDecodeBase64.On any native throw, the polyfill is re-run to surface a diagnostic that embeds
nameand the failing offset; native error messages are implementation-defined and do neither.