js-base64

  • Version 3.7.2
  • Published
  • 34.9 kB
  • No dependencies
  • BSD-3-Clause license

Install

npm i js-base64
yarn add js-base64
pnpm add js-base64

Overview

Yet another Base64 transcoder in pure-JS

Index

Variables

variable Base64

const Base64: {
version: string;
VERSION: string;
atob: (asc: string) => string;
atobPolyfill: (asc: string) => string;
btoa: (bin: string) => string;
btoaPolyfill: (bin: string) => string;
fromBase64: (src: string) => string;
toBase64: (src: string, urlsafe?: boolean) => string;
encode: (src: string, urlsafe?: boolean) => string;
encodeURI: (src: string) => string;
encodeURL: (src: string) => string;
utob: (u: string) => string;
btou: (b: string) => string;
decode: (src: string) => string;
isValid: (src: any) => boolean;
fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string;
toUint8Array: (a: string) => Uint8Array;
extendString: () => void;
extendUint8Array: () => void;
extendBuiltins: () => void;
};

    variable version

    const version: string;
    • base64.ts

      Licensed under the BSD 3-Clause License. http://opensource.org/licenses/BSD-3-Clause

      References: http://en.wikipedia.org/wiki/Base64

      Dan Kogai (https://github.com/dankogai)

    variable VERSION

    const VERSION: string;
    • Deprecated

      use lowercase version.

    Functions

    function atob

    atob: (asc: string) => string;
    • does what window.atob of web browsers do.

      Parameter asc

      Base64-encoded string

      Returns

      {string} binary string

    function atobPolyfill

    atobPolyfill: (asc: string) => string;
    • polyfill version of atob

    function btoa

    btoa: (bin: string) => string;
    • does what window.btoa of web browsers do.

      Parameter bin

      binary string

      Returns

      {string} Base64-encoded string

    function btoaPolyfill

    btoaPolyfill: (bin: string) => string;
    • polyfill version of btoa

    function btou

    btou: (b: string) => string;
    • Parameter src

      UTF-16 string

      Returns

      {string} UTF-8 string

      Deprecated

      should have been internal use only.

    function decode

    decode: (src: string) => string;
    • converts a Base64 string to a UTF-8 string.

      Parameter src

      Base64 string. Both normal and URL-safe are supported

      Returns

      {string} UTF-8 string

    function encode

    encode: (src: string, urlsafe?: boolean) => string;
    • converts a UTF-8-encoded string to a Base64 string.

      Parameter urlsafe

      if true make the result URL-safe

      Returns

      {string} Base64 string

    function encodeURI

    encodeURI: (src: string) => string;
    • converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.

      Returns

      {string} Base64 string

    function encodeURL

    encodeURL: (src: string) => string;
    • converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.

      Returns

      {string} Base64 string

    function extendBuiltins

    extendBuiltins: () => void;
    • extend Builtin prototypes with relevant methods

    function extendString

    extendString: () => void;
    • extend String.prototype with relevant methods

    function extendUint8Array

    extendUint8Array: () => void;
    • extend Uint8Array.prototype with relevant methods

    function fromBase64

    fromBase64: (src: string) => string;
    • converts a Base64 string to a UTF-8 string.

      Parameter src

      Base64 string. Both normal and URL-safe are supported

      Returns

      {string} UTF-8 string

    function fromUint8Array

    fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string;
    • converts a Uint8Array to a Base64 string.

      Parameter urlsafe

      URL-and-filename-safe a la RFC4648 §5

      Returns

      {string} Base64 string

    function isValid

    isValid: (src: any) => boolean;
    • check if a value is a valid Base64 string

      Parameter src

      a value to check

    function toBase64

    toBase64: (src: string, urlsafe?: boolean) => string;
    • converts a UTF-8-encoded string to a Base64 string.

      Parameter urlsafe

      if true make the result URL-safe

      Returns

      {string} Base64 string

    function toUint8Array

    toUint8Array: (a: string) => Uint8Array;
    • converts a Base64 string to a Uint8Array.

    function utob

    utob: (u: string) => string;
    • Parameter src

      UTF-8 string

      Returns

      {string} UTF-16 string

      Deprecated

      should have been internal use only.

    Package Files (1)

    Dependencies (0)

    No dependencies.

    Dev Dependencies (4)

    Peer Dependencies (0)

    No peer dependencies.

    Badge

    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/js-base64.

    • Markdown
      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/js-base64)
    • HTML
      <a href="https://www.jsdocs.io/package/js-base64"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>