UNPKG

@thi.ng/file-io

Version:

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

39 lines 1.32 kB
import type { ILogger } from "@thi.ng/logger"; /** * Reads text from given file `path`, optionally with custom encoding (default: * UTF-8). * * @param path * @param logger * @param encoding */ export declare const readText: (path: string, logger?: ILogger, encoding?: Extract<BufferEncoding, "ascii" | "latin1" | "utf-8" | "utf-16le" | "ucs-2">) => string; /** * Async version of {@link readText}. * * @param path * @param logger * @param encoding */ export declare const readTextAsync: (path: string, logger?: ILogger, encoding?: Extract<BufferEncoding, "ascii" | "latin1" | "utf-8" | "utf-16le" | "ucs-2">) => Promise<string>; /** * Writes `body` as UTF-8 file to given `path`. If `dryRun` is true (default: * false), the file WON'T be written, however if a `logger` is provided then at * least a dry-run log message will be emitted. * * @param path * @param body * @param logger * @param dryRun */ export declare const writeText: (path: string, body: string | string[], logger?: ILogger, dryRun?: boolean) => void; /** * Async version of {@link writeText}. * * @param path * @param body * @param logger * @param dryRun */ export declare const writeTextAsync: (path: string, body: string | string[], logger?: ILogger, dryRun?: boolean) => Promise<void>; //# sourceMappingURL=text.d.ts.map