atomicWrite
Writes data to a file atomically by first writing to a unique temporary file in the target directory and then replacing the target. This prevents partial writes in case of failure and works when the target already exists on Windows, macOS, and Linux.
Signature
atomicWrite(path: string, data: string): Result<void, FsError>Example
tyrus
import { FsError, atomicWrite } from "tyrus:fs";
match (atomicWrite("./config.json", '{"version": 2}')) {
Ok(_) => { print("configuration written"); } // configuration written
Err(error) => { printError(error.code); } // ERR_FS_WRITE_FAILED
}