Minima.js API / @minimajs/disk / plugins / atomicWrite
Function: atomicWrite()
ts
function atomicWrite(options?): (disk) => void;Atomic write plugin — writes to a temp file first, then renames to the final path. Prevents partial or corrupted files from ever being visible to readers.
The original path is tracked via a Symbol key in the put options metadata — no in-memory Map is needed, so there is no risk of a memory leak.
Parameters
options?
AtomicWriteOptions = {}
Returns
ts
(disk): void;Parameters
disk
Returns
void
Example
ts
const disk = createDisk(fsDriver, atomicWrite())
await disk.put('important.json', data) // written atomically