/** * Atomic Write Utilities * * Provides atomic file write operations that ensure data integrity: * - Creates parent directories if needed * - Writes to a temp file first, then renames (atomic on most filesystems) * - Cleans up temp files on any error * - Uses PID and timestamp in temp filename to prevent collisions */ /** * Atomically write content to a file. * * This function ensures that writes are atomic: * 1. Creates parent directories if they don't exist * 2. Writes content to a temporary file * 3. Renames the temp file to the target (atomic on most filesystems) * 4. Cleans up the temp file on any error * * The temp file name includes timestamp and PID to prevent collisions * between concurrent writes and different processes. * * @param targetPath - Absolute path to the target file * @param content - Content to write to the file * @param encoding - Character encoding (default: 'utf-8') * * @example * ```typescript * await atomicWrite('/path/to/file.txt', 'Hello, World!'); * ``` */ export declare function atomicWrite(targetPath: string, content: string, encoding?: BufferEncoding): Promise; /** * Atomically write JSON content to a file. * * This is a convenience wrapper around atomicWrite that handles * JSON serialization with optional pretty-printing. * * @param targetPath - Absolute path to the target file * @param data - Data to serialize and write * @param pretty - Whether to pretty-print the JSON (default: true) * * @example * ```typescript * await atomicWriteJson('/path/to/data.json', { key: 'value' }); * // Creates: { "key": "value" } * * await atomicWriteJson('/path/to/data.json', { key: 'value' }, false); * // Creates: {"key":"value"} * ``` */ export declare function atomicWriteJson(targetPath: string, data: unknown, pretty?: boolean): Promise; //# sourceMappingURL=atomicWrite.d.ts.map