apaleslimghost / atomic-write-stream

stream to a file atomically

Home Page:https://github.com/quarterto/atomic-write-stream

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

atomic-write-stream

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.

npm install atomic-write-stream

works by redirecting your writes to a unique temporary file then renameing it to the target

how do atomic-write-stream

var fs = require('fs')
  , atomicWriteStream = require('atomic-write-stream')

fs.createReadStream('a.txt').pipe(atomicWriteStream('a.txt', optionsWotGetPassedToFs))

cheers

inspired by atomic-write except streaming because what is this 2011?

MIT licence, © MMXIV mb

About

stream to a file atomically

https://github.com/quarterto/atomic-write-stream


Languages

Language:LiveScript 100.0%