UNPKG

@thi.ng/file-io

Version:

Assorted file I/O utils (w/ logging support) for NodeJS/Bun

43 lines 956 B
import type { ILogger } from "@thi.ng/logger"; export interface FileChunkOpts { /** * Optional logger instance */ logger: ILogger; /** * Chunk size (in bytes). * * @defaultValue 1024 */ size: number; /** * Read start position (in bytes) * * @defaultValue 0 */ start: number; /** * Read end position (in bytes) * * @defaultValue Infinity */ end: number; } /** * Async iterator. Yields chunks of byte buffers from given file. User * configurable size and byte ranges. * * @example * ```ts * import { fileChunks } from "@thi.ng/file-io"; * * for await(let buf of fileChunks("file.bin", { start: 16*1024*1024 })) { * // ... * } * ``` * * @param path * @param opts */ export declare function fileChunks(path: string, opts?: Partial<FileChunkOpts>): AsyncGenerator<Buffer<ArrayBuffer>, void, unknown>; //# sourceMappingURL=file-chunks.d.ts.map