UNPKG

1.15 kBTypeScriptView Raw
1/**
2 * Slightly modernized version of [`base64-js`][1].
3 * Performance is slightly improved due to pre-allocating arrays.
4 *
5 * This version drops support for platforms that don't provide
6 * `Uint8Array` and `DataView`. Use the original in those cases.
7 *
8 * [1]: https://github.com/beatgammit/base64-js
9 * [2]: https://tools.ietf.org/html/rfc3986#section-2.3
10 */
11/**
12 * Takes a base 64 string and converts it to an array buffer.
13 * Accepts both regular Base64 and the URL-friendly variant,
14 * where `+` => `-`, `/` => `_`, and the padding character is omitted.
15 *
16 * @param str A Base64 string in either regular or URL-friendly representation.
17 * @returns The binary data as `Uint8Array`.
18 */
19export declare function toByteArray(str: string): Uint8Array;
20/**
21 * Encodes binary data provided in an array buffer as a Base64 string.
22 * @param bufferSource The raw data to encode.
23 * @param urlFriendly Set to true to encode in a URL-friendly way.
24 * @returns The contents a Base64 string.
25 */
26export declare function fromByteArray(bufferSource: BufferSource, urlFriendly?: boolean): string;
27export { fromByteArray as encode, toByteArray as decode, };