Skip to main content
Module

x/uuid/lib/lib.deno_runtime.d.ts>Deno.Reader

Deprecated! UUID is part of the deno standard library
Latest
interface Deno.Reader
import { type Deno } from "https://deno.land/x/uuid@v0.1.2/lib/lib.deno_runtime.d.ts";
const { Reader } = Deno;

Methods

read(p: Uint8Array): Promise<ReadResult>

Reads up to p.byteLength bytes into p. It resolves to the number of bytes read (0 <= n <= p.byteLength) and 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 an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == null. The next read() should return 0, EOF.

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 of read() are discouraged from returning a zero byte count with a null error, except when p.byteLength == 0. Callers should treat a return of 0 and null as indicating that nothing happened; in particular it does not indicate EOF.

Implementations must not retain p.