UNPKG

@thi.ng/buffers

Version:

General purpose and generic read/write buffer implementations with different behaviors/orderings

34 lines 971 B
import type { Maybe } from "@thi.ng/api"; import type { IReadWriteBuffer } from "./api.js"; /** * Returns a {@link FIFOBuffer} ring buffer with given max. capacity and * first-in first-out (i.e. queue) behavior. * * @remarks * With this implementation, new writes will be ignored whilst the buffer's * capacity is reached. * * Also see {@link lifo}. * * @param cap */ export declare const fifo: <T>(cap: number) => FIFOBuffer<T>; /** * First-in, first-out ring buffer implementation. See {@link fifo}. */ export declare class FIFOBuffer<T> implements IReadWriteBuffer<T> { protected buf: Maybe<T>[]; protected rpos: number; protected wpos: number; protected len: number; constructor(cap?: number); get length(): number; clear(): void; copy(): FIFOBuffer<T>; readable(): boolean; read(): NonNullable<T>; peek(): NonNullable<T>; writable(): boolean; write(x: T): boolean; } //# sourceMappingURL=fifo.d.ts.map