Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/reader.ts>readAsDataURL

A JavaScript extension package for building strong and modern applications.
Latest
function readAsDataURL
import { readAsDataURL } from "https://deno.land/x/ayonli_jsext@v0.9.72/reader.ts";

Reads all data from the given source to a data URL.

Examples

Example 1

import { readAsDataURL } from "@ayonli/jsext/reader";

const file = new File(["Hello, World!"], "hello.txt", { type: "text/plain" });
const dataURL = await readAsDataURL(file, file.type);

console.log(dataURL); // data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==

Parameters

source:
| Blob
| ArrayBuffer
| ArrayBufferView
| AsyncIterable<Uint8Array>
| ReadableStream<Uint8Array>
type: string

Returns

Promise<string>