fast-base64-decode is a JavaScript library providing a high-performance, low-level Base64 decoder. Its current stable version is 2.0.0, released in October 2022. The library differentiates itself by offering a direct, byte-array-oriented API, requiring the user to pre-allocate `Uint8Array` buffers and specify the exact output length. This approach is optimized for speed and memory efficiency, contrasting with higher-level alternatives like `base64-js` which handle buffer allocation automatically. It is primarily used for decoding Base64 strings where performance is critical and granular control over the output buffer is desired. The package has a moderate release cadence, with major versions aligning with significant architectural shifts like its recent conversion to an ECMAScript module.
npm install fast-base64-decodeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use `base64Decode` to decode a Base64 string into a pre-allocated `Uint8Array` buffer.
Refactor `require()` statements to `import` statements. For CommonJS environments, consider using dynamic `import()` or sticking to `fast-base64-decode@1.x`.
Ensure Node.js version is `^12.20.0 || ^14.13.1 || >=16.0.0` or newer.
You must know the exact decoded length of the Base64 string beforehand and create a `new Uint8Array(decodedLength)` to pass as the second argument. Incorrect length will lead to truncated or padded data.
Change `const base64Decode = require('fast-base64-decode');` to `import base64Decode from 'fast-base64-decode';` and ensure your project is configured for ESM.If using ESM, ensure `import base64Decode from 'fast-base64-decode';`. If forced to use CommonJS for older Node or project setup, use `fast-base64-decode@1.x` or dynamic `import()`.
Calculate the exact required length for the decoded Base64 string and initialize the `Uint8Array` with that size. Base64 strings are generally 4 characters for every 3 bytes, plus padding, so roughly `(string.length / 4) * 3` for estimation.
No dependency data recorded yet.