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

x/ayonli_jsext/fs.ts>readFile

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

Reads the content of the given file in bytes.

NOTE: This function can also be used in Cloudflare Workers.

Examples

Example 1

// with the default storage
import { readFile } from "@ayonli/jsext/fs";

const bytes = await readFile("/path/to/file.txt");

Example 2

// with a user-selected directory as root (Chromium only)
import { readFile } from "@ayonli/jsext/fs";

const root = await window.showDirectoryPicker();
const bytes = await readFile("/path/to/file.txt", { root });

Parameters

target: string | FileSystemFileHandle
optional
options: ReadFileOptions = [UNSUPPORTED]

Returns

Promise<Uint8Array>