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

x/deno/cli/js/lib.deno_runtime.d.ts>Deno.read

A modern runtime for JavaScript and TypeScript.
Go to Latest
function Deno.read
import { Deno } from "https://deno.land/x/deno@v0.28.0/cli/js/lib.deno_runtime.d.ts";
const { read } = Deno;

Read from a file ID into an array buffer.

Resolves with the number | EOF for the operation.

  (async () => {
    const file = await Deno.open("/foo/bar.txt");
    const buf = new Uint8Array(100);
    const nread = await Deno.read(file.rid, buf);
    const text = new TextDecoder().decode(buf);
  })();

Parameters

rid: number
p: Uint8Array

Returns

Promise<number | EOF>