/** * Windowed file access, ported from less's ch.c: the file is read in * fixed blocks kept in an LRU pool, so any position of an arbitrarily * large file is reachable without loading it. Positions are byte * offsets (less's POSITION), safe as JS numbers up to 2^53. */ /** Block size, like less's LBUFSIZE. */ export declare const BLOCK_SIZE = 8192; export declare class BlockFile { private fd; /** Resident blocks by block index, in LRU order (oldest first). */ private blocks; /** File length at open (or last refresh), like ch_length. */ size: number; readonly path: string; constructor(path: string); /** Re-checks the file length, for F follow and growing files. */ refreshSize(): number; /** * Whether a read at `pos` really has nothing left, like less's ch_get * reaching the cached length: "Apparently at end of file. Double-check * the file size in case it has changed" (ch.c:236), and only then * returning EOI. * * This is why less needs no command to follow a growing file - an * ordinary forward scroll past the old end picks up whatever has * been appended. The stat costs nothing until a read is already at * the end, which is exactly when less pays for it too. */ atEnd(pos: number): boolean; /** * The maximum resident blocks: -b caps the pool like less's bufspace * (in KB); -B off pins the cap, on lets it grow to a sane ceiling. */ private maxBlocks; /** Evicts blocks beyond the -b cap, like less's ch_setbufspace * releasing excess buffers as soon as the option changes. */ trim(): void; /** Returns one block's bytes, reading and pooling it on demand. */ private blockAt; /** * Reads a byte range, assembled from pooled blocks; clipped at the * ends of the file. */ readRange(pos: number, len: number): Buffer; /** * The next newline at or after `pos`, or -1 within the searched * span; scans block by block like ch_forw_get. */ findNewline(pos: number, limit: number): number; /** * The last newline strictly before `pos`, or -1 within the span; * scans backward like ch_back_get. */ findNewlineBack(pos: number, limit: number): number; close(): void; }