@thi.ng/buffers
Version:
General purpose and generic read/write buffer implementations with different behaviors/orderings
26 lines • 794 B
TypeScript
import type { IReadWriteBuffer } from "./api.js";
/**
* Returns a {@link LIFOBuffer} with given max. capacity.
*
* @remarks
* Read/write behavior is mostly the same as with {@link fifo}, with the
* important difference, that (as the name indicates), the last value written
* will be the first value read (i.e. stack behavior).
*
* @param cap
*/
export declare const lifo: <T>(cap: number) => LIFOBuffer<T>;
export declare class LIFOBuffer<T> implements IReadWriteBuffer<T> {
protected cap: number;
protected buf: T[];
constructor(cap?: number);
get length(): number;
clear(): void;
copy(): LIFOBuffer<T>;
readable(): boolean;
read(): NonNullable<T>;
peek(): T;
writable(): boolean;
write(x: T): boolean;
}
//# sourceMappingURL=lifo.d.ts.map