Skip to main content

@std/io@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)

Classes

c
Buffer(ab?: ArrayBufferLike | ArrayLike<number>)

A variable-sized buffer of bytes with read() and write() methods.

  • bytes(options?): 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 n bytes. After .grow(n), at least n bytes can be written to the buffer without another allocation. If n is 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.length bytes 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 r until 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 r until 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.length bytes 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
    No documentation available
  • truncate(n: number): void

    Discards all but the first n unread bytes from the buffer but continues to use the same allocated storage. It throws if n is negative or greater than the length of the buffer.

  • write(p: Uint8Array): Promise<number>

    NOTE: This methods writes bytes synchronously; it's provided for compatibility with Writer interface.

  • writeSync(p: Uint8Array): number
    No documentation available

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/io

Import symbol

import * as mod from "@std/io/buffer";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/io/buffer";