Skip to main content
Go to Latest
method BufReader.prototype.readSlice
import { BufReader } from "https://deno.land/std@0.114.0/io/buffer.ts";

readSlice() reads until the first occurrence of delim in the input, returning a slice pointing at the bytes in the buffer. The bytes stop being valid at the next read.

If readSlice() encounters an error before finding a delimiter, or the buffer fills without finding a delimiter, it throws an error with a partial property that contains the entire buffer.

If readSlice() encounters the end of the underlying stream and there are any bytes left in the buffer, the rest of the buffer is returned. In other words, EOF is always treated as a delimiter. Once the buffer is empty, it returns null.

Because the data returned from readSlice() will be overwritten by the next I/O operation, most clients should use readString() instead.

Parameters

delim: number

Returns

Promise<Uint8Array | null>