@alwatr/node-fs
Version:
Enhanced file system operations in Node.js with asynchronous queue to prevent parallel writes.
33 lines • 1.04 kB
TypeScript
/**
* Enhanced write file (Synchronous).
*
* - If directory not exists, create it recursively.
* - Write file to `path.tmp` before write success.
* - If file exists, renamed (keep) to `path.bak`.
* - If write failed, original file will not be changed.
*
* @param path - file path
* @param content - file content
* @example
* ```typescript
* writeFileSync('./file.txt', 'Hello World!');
* ```
*/
export declare function writeFileSync(path: string, content: Buffer | string): void;
/**
* Enhanced write file (Asynchronous).
*
* - If directory not exists, create it recursively.
* - Write file to `path.tmp` before write success.
* - If file exists, renamed (keep) to `path.bak`.
* - If write failed, original file will not be changed.
*
* @param path - file path
* @param content - file content
* @example
* ```typescript
* await writeFile('./file.txt', 'Hello World!');
* ```
*/
export declare function writeFile(path: string, content: Buffer | string): Promise<void>;
//# sourceMappingURL=write-file.d.ts.map