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

x/ayonli_jsext/lib.deno.d.ts>Deno.readFile

A JavaScript extension package for building strong and modern applications.
Latest
function Deno.readFile
allow-read
import { Deno } from "https://deno.land/x/ayonli_jsext@v0.9.72/lib.deno.d.ts";
const { readFile } = Deno;

Reads and resolves to the entire contents of a file as an array of bytes. TextDecoder can be used to transform the bytes to string if required. Reading a directory returns an empty data array.

const decoder = new TextDecoder("utf-8");
const data = await Deno.readFile("hello.txt");
console.log(decoder.decode(data));

Requires allow-read permission.

Parameters

path: string | URL
optional
options: ReadFileOptions

Returns

Promise<Uint8Array>