Function toDataURL

  • Synchronously converts data to a Base64 Data URL.

    This function is truly synchronous and works in both Node.js and browser environments.

    Parameters

    • data: string | ArrayBuffer | Uint8Array<ArrayBufferLike>

      The input data. Can be a UTF-8 string, a Uint8Array, or an ArrayBuffer.

    • mimeType: string = 'application/octet-stream'

      The MIME type for the Data URL.

    Returns string

    A fully formed Base64 Data URL string.