fast-write-atomic
Fast way to write a file atomically, for Node.js
Last updated 7 years ago by matteo.collina .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fast-write-atomic 
SYNC missed versions from official npm registry.

fast-write-atomic

CI npm version

Fast way to write a file atomically, for Node.js.

Requirements

  • Node.js 20+

Install

npm i fast-write-atomic

Example

const writeFile = require('fast-write-atomic')

const data = Buffer.from('hello world')

writeFile('./hello', data, function (err) {
  if (err) {
    console.log(err)
    return
  }

  console.log('file written')
})

Promise API

writeFile.promise(path, content) returns a Promise and keeps the same atomicity behavior.

const writeFile = require('fast-write-atomic')

await writeFile.promise('./hello', Buffer.from('hello world'))

Development

npm install
npm test
npm run cov
node bench.js

Benchmarks

Those benchmarks write a 1 MB file a thousand times:

benchWriteFileAtomic*1000: 9830.501ms
benchFastWriteAtomic*1000: 8848.916ms
benchWriteFileAtomic*1000: 9944.722ms
benchFastWriteAtomic*1000: 8997.108ms

License

MIT

Current Tags

  • 0.4.0                                ...           latest (2 months ago)

5 Versions

  • 0.4.0                                ...           2 months ago
  • 0.2.1                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (8)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |