Skip to main content
Module

x/deno/js/io.ts>Reader

A modern runtime for JavaScript and TypeScript.
Go to Latest
interface Reader
import { type Reader } from "https://deno.land/x/deno@v0.14.0/js/io.ts";

Methods

read(p: Uint8Array): Promise<number | EOF>

Reads up to p.byteLength bytes into p. It resolves to the number of bytes read (0 < n <= p.byteLength) and rejects if any error encountered. Even if read() returns n < p.byteLength, it may use all of p as scratch space during the call. If some data is available but not p.byteLength bytes, read() conventionally returns what is available instead of waiting for more.

When read() encounters end-of-file condition, it returns EOF symbol.

When read() encounters an error, it rejects with an error.

Callers should always process the n > 0 bytes returned before considering the EOF. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.

Implementations must not retain p.