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

x/proc/legacy/deps.ts>BufReader#peek

A high-level way to run child processes that is easy, flexible, powerful, and prevents resource leaks.
Go to Latest
method BufReader.prototype.peek
Re-export
import { BufReader } from "https://deno.land/x/proc@0.20.17/legacy/deps.ts";

peek() returns the next n bytes without advancing the reader. The bytes stop being valid at the next read call.

When the end of the underlying stream is reached, but there are unread bytes left in the buffer, those bytes are returned. If there are no bytes left in the buffer, it returns null.

If an error is encountered before n bytes are available, peek() throws an error with the partial property set to a slice of the buffer that contains the bytes that were available before the error occurred.

Parameters

n: number

Returns

Promise<Uint8Array | null>