/** * Pull Stream * * A stream that allows pulling data from internal buffer with pattern matching. * Works identically in both browser and Node.js environments. */ import type { PullStreamOptions } from "./types.js"; import { EventEmitter } from "../../utils/event-emitter.js"; export type { PullStreamOptions } from "./types.js"; /** * Browser-compatible Pull Stream - Read data from buffer on demand with pattern matching */ export declare class PullStream extends EventEmitter { private _buffer; private _bufferReadIndex; private _bufferWriteIndex; protected finished: boolean; protected _match?: number; private _destroyed; private _highWaterMark; private _needsDrain; constructor(options?: PullStreamOptions); /** Reset the internal buffer to empty. */ private _resetBuffer; protected get buffer(): Uint8Array; protected set buffer(buf: Uint8Array); /** * Write data to the stream. * * Returns `false` when the buffer's readable size exceeds `highWaterMark` * (backpressure signal). Producers should pause and resume on the next * `'drain'` event. */ write(chunk: Uint8Array): boolean; /** * Set `_needsDrain` based on current buffer size, return whether the * producer should keep writing (true) or pause (false). */ private _evaluateBackpressure; /** * Internal: subclasses or pull paths must call this after consuming bytes * (advancing `_bufferReadIndex`) to potentially emit `'drain'`. Idempotent * and free when no backpressure is in effect. */ protected _maybeEmitDrain(): void; /** * Signal end of input */ end(chunk?: Uint8Array): void; /** * Destroy the stream */ destroy(error?: Error): void; /** * Pull exactly N bytes from buffer, or pull until pattern is found */ pull(size: number): Promise; pull(pattern: Uint8Array, includePattern?: boolean): Promise; /** * Pull until pattern is found (alias for pull(pattern, includePattern)) */ pullUntil(pattern: Uint8Array, includePattern?: boolean): Promise; private _pullSize; private _pullPattern; /** * Get the match position from last pattern match */ get matchPosition(): number | undefined; /** * Get remaining buffer length */ get length(): number; /** * Check if stream is finished */ get isFinished(): boolean; /** * Check if stream is destroyed */ get destroyed(): boolean; }