ever tried fs.createReadStream('a.txt').pipe(fs.createWriteStream('a.txt'))
and ended up with an empty file? yeah, don't do that. use atomic-write-stream
.
works by redirecting your writes to a unique temporary file then rename
ing it to the target
var fs = require('fs')
, atomicWriteStream = require('atomic-write-stream')
fs.createReadStream('a.txt').pipe(atomicWriteStream('a.txt', optionsWotGetPassedToFs))
inspired by atomic-write except streaming because what is this 2011?
MIT licence, © MMXIV mb