/** * @packageDocumentation In-memory IOStream backed by a ByteVector. */ import { ByteVector } from "../byteVector.js"; import { type offset_t, Position } from "./types.js"; import { IOStream } from "./ioStream.js"; /** * An in-memory {@link IOStream} backed by a {@link ByteVector}. Useful for * reading and writing tag metadata without touching the filesystem, or for * constructing binary payloads in memory. * * All operations are synchronous under the hood; the async signatures exist * solely to satisfy the {@link IOStream} contract. */ export declare class ByteVectorStream extends IOStream { /** The underlying buffer. */ private _data; /** Current read/write position (bytes from the start). */ private _position; /** * Creates a new ByteVectorStream. * * @param data - Initial content. If a `Uint8Array` is provided it is * wrapped in a new {@link ByteVector}. If a {@link ByteVector} is * provided a copy is made. Defaults to an empty buffer. */ constructor(data?: ByteVector | Uint8Array); /** * Returns an empty string — in-memory streams have no meaningful name. */ name(): string; /** * Reads up to `length` bytes from the current position and advances the * position by the number of bytes actually read. * * @param length - Maximum number of bytes to read. * @returns Resolves with a {@link ByteVector} containing the bytes read. */ readBlock(length: number): Promise; /** * Writes `data` at the current position, extending the buffer if necessary, * and advances the position by `data.length`. * * @param data - The bytes to write. */ writeBlock(data: ByteVector): Promise; /** * Inserts `data` at byte offset `start`, optionally replacing `replace` * bytes of existing content. * * @param data - The bytes to insert. * @param start - Byte offset at which to begin the insertion. * @param replace - Number of existing bytes to overwrite. Defaults to 0. */ insert(data: ByteVector, start: offset_t, replace?: number): Promise; /** * Removes `length` bytes beginning at byte offset `start`. * * @param start - Byte offset of the first byte to remove. * @param length - Number of bytes to remove. */ removeBlock(start: offset_t, length: number): Promise; /** Returns `false` — ByteVectorStream is always writable. */ readOnly(): boolean; /** Returns `true` — ByteVectorStream is always open. */ isOpen(): boolean; /** * Moves the read/write position. * * @param offset - Number of bytes to move. * @param position - Reference point. Defaults to {@link Position.Beginning}. */ seek(offset: offset_t, position?: Position): Promise; /** Resets the stream position to the beginning. */ clear(): Promise; /** Returns the current read/write position in bytes. */ tell(): Promise; /** Returns the total number of bytes in the stream. */ length(): Promise; /** * Truncates or zero-extends the stream to exactly `length` bytes. If the * current position exceeds the new length, it is clamped. * * @param length - The desired stream length in bytes. */ truncate(length: offset_t): Promise; /** Returns a copy of the underlying {@link ByteVector}. */ data(): ByteVector; } //# sourceMappingURL=byteVectorStream.d.ts.map