@jossmac/lil-libs
    Preparing search index...

    Function base64Encode

    • Encodes a UTF-8 string to raw base64 text. Supports Unicode input.

      Uses the fastest available method:

      1. Buffer (Node.js)
      2. Uint8Array.toBase64 (modern browsers)
      3. TextEncoder + btoa (legacy fallback)
      • value: string

        UTF-8 string to encode.

      Base64 representation of value.

      base64Encode("hello"); // "aGVsbG8="
      
    • Encodes a UTF-8 string as a data: URI with the given MIME type.

      Minifies SVG whitespace when mimeType is "image/svg+xml".

      • M extends MimeType
      • value: string

        UTF-8 string to encode.

      • mimeType: M

        MIME type for the resulting data URI; SVG payloads are whitespace-minified first.

      A data:${mimeType};base64,... URI.

      base64Encode("hello", "text/plain"); // "data:text/plain;base64,aGVsbG8="
      base64Encode("<svg> </svg>", "image/svg+xml"); // SVG whitespace minified before encoding