Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
UNSTABLE: The utilities for advanced I/O operations using Reader and Writer interfaces.
Classes
A variable-sized buffer of bytes with read() and write() methods.
- bytes(options?: { copy: boolean; }): Uint8Array
Returns a slice holding the unread portion of the buffer.
- capacity(): number
The read only capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data.
- empty(): boolean
Returns whether the unread portion of the buffer is empty.
- grow(n: number): void
Grows the buffer's capacity, if necessary, to guarantee space for another
nbytes. After.grow(n), at leastnbytes can be written to the buffer without another allocation. Ifnis negative,.grow()will throw. If the buffer can't grow it will throw an error. - length(): number
A read only number of bytes of the unread portion of the buffer.
- read(p: Uint8Array): Promise<number | null>
Reads the next
p.lengthbytes from the buffer or until the buffer is drained. Resolves to the number of bytes read. If the buffer has no data to return, resolves to EOF (null). - readFrom(r: Reader): Promise<number>
Reads data from
runtil EOF (null) and appends it to the buffer, growing the buffer as needed. It resolves to the number of bytes read. If the buffer becomes too large,.readFrom()will reject with an error. - readFromSync(r: ReaderSync): number
Reads data from
runtil EOF (null) and appends it to the buffer, growing the buffer as needed. It returns the number of bytes read. If the buffer becomes too large,.readFromSync()will throw an error. - readSync(p: Uint8Array): number | null
Reads the next
p.lengthbytes from the buffer or until the buffer is drained. Returns the number of bytes read. If the buffer has no data to return, the return is EOF (null). - reset(): void
Resets the contents
- truncate(n: number): void
Discards all but the first
nunread bytes from the buffer but continues to use the same allocated storage. It throws ifnis negative or greater than the length of the buffer. - write(p: Uint8Array): Promise<number>
Writes the given data to the buffer. Resolves to the number of bytes written.
- writeSync(p: Uint8Array): number
Writes the given data to the buffer.