"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/fs-write-stream-atomic/README.md" (17 Oct 2016, 1033 Bytes) of archive /windows/misc/atom-windows.zip:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.


Like fs.createWriteStream(...), but atomic.

Writes to a tmp file and does an atomic fs.rename to move it into place when it’s done.

First rule of debugging: It’s always a race condition.


```javascript var fsWriteStreamAtomic = require(‘fs-write-stream-atomic’) // options are optional. var write = fsWriteStreamAtomic(‘output.txt’, options) var read = fs.createReadStream(‘input.txt’) read.pipe(write)

// When the write stream emits a ‘finish’ or ‘close’ event, // you can be sure that it is moved into place, and contains // all the bytes that were written to it, even if something else // was writing to output.txt at the same time. ```

fsWriteStreamAtomic(filename, [options])