UNPKG

@stryke/fs

Version:

A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.

31 lines (30 loc) 1.13 kB
import type { Abortable } from "node:events"; import type { WriteFileOptions as FSWriteFileOptions, Mode, ObjectEncodingOptions, OpenMode } from "node:fs"; import type { Encoding } from "./constants"; export interface WriteFileOptions { /** * Whether to create the directory if it does not exist * * @defaultValue true */ createDirectory?: boolean; } /** * Write the given content to the given file path * * @param filePath - The file path to write to * @param content - The content to write to the file */ export declare const writeFileSync: (filePath: string, content?: string, options?: WriteFileOptions & FSWriteFileOptions) => void; /** * Read the given content to the given file path * * @param filePath - The file path to read to * @param content - The content to write to the file * @returns The content of the file */ export declare const writeFile: (filePath: string, content?: string, options?: WriteFileOptions & ((ObjectEncodingOptions & { mode?: Mode | undefined; flag?: OpenMode | undefined; flush?: boolean | undefined; } & Abortable) | Encoding)) => Promise<void>;