Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atomic-file-rw

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atomic-file-rw

<!-- SPDX-FileCopyrightText: 2021 Anders Rune Jensen

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31
decreased by-50.79%
Maintainers
1
Weekly downloads
 
Created
Source

Atomic-file-rw

This module is meant as a replacement for atomic-file as it has better error handling on node and is faster in the browser.

The library is written to handle writing to a few number of files in a safe manner. Concurrent writes to the same file are completed in the order they are started. A temporary file with the same filename as the original — with a suffix ~ — is employed to ensure atomicity.

Example

Write a buffer to file and read it again:

const atomic = require('atomic-file-rw')

atomic.writeFile("test.txt", Buffer.from('GREETINGS'), (err, x) => {
  atomic.readFile("test.txt", (err, buf) => {
    console.log(buf.toString())
  })
})

API

atomic.readFile(path[, options], callback)

Same arguments as Node.js's fs.readFile, but in the browser the options is ignored.

atomic.writeFile(file, data[, options], callback)

Same arguments as Node.js's fs.writeFile, but in the browser the options is ignored.

atomic.deleteFile(file, callback)

Same arguments as Node.js's fs.unlink.

FAQs

Package last updated on 01 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc