fs-write-stream-atomic
Like `fs.createWriteStream(...)`, but atomic.
Last updated 9 years ago by iarna .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install fs-write-stream-atomic 
SYNC missed versions from official npm registry.

fs-write-stream-atomic

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.

USAGE

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])

  • filename {String} The file we want to write to
  • options {Object}
    • chown {Object} User and group to set ownership after write
      • uid {Number}
      • gid {Number}
    • encoding {String} default = 'utf8'
    • mode {Number} default = 0666
    • flags {String} default = 'w'

Current Tags

  • 1.0.10                                ...           latest (8 years ago)

11 Versions

  • 1.0.10                                ...           8 years ago
  • 1.0.9                                ...           8 years ago
  • 1.0.8                                ...           9 years ago
  • 1.0.7 [deprecated]           ...           9 years ago
  • 1.0.6 [deprecated]           ...           9 years ago
  • 1.0.5                                ...           9 years ago
  • 1.0.4                                ...           9 years ago
  • 1.0.3                                ...           10 years ago
  • 1.0.2                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (3)

Copyright 2013 - present © cnpmjs.org | Home |