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

write-file-atomic

Package Overview
Dependencies
Maintainers
6
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

write-file-atomic

Write files in an atomic fashion w/configurable ownership

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is write-file-atomic?

The write-file-atomic npm package is designed to write files to disk atomically, meaning that it ensures that the file contents are either fully written or not written at all, preventing partial writes that can occur in crash scenarios. It also allows for setting file mode and ownership atomically with the file write.

What are write-file-atomic's main functionalities?

Atomic file writing

This feature ensures that the file is either completely written or not written at all, which is useful for preventing data corruption during write operations.

const writeFileAtomic = require('write-file-atomic');
writeFileAtomic('message.txt', 'Hello, World!', function (err) {
  if (err) throw err;
  console.log('The file has been saved!');
});

Setting file mode

This feature allows the user to set the file mode (permissions) at the time of writing the file atomically.

const writeFileAtomic = require('write-file-atomic');
writeFileAtomic('message.txt', 'Hello, World!', { mode: 0o755 }, function (err) {
  if (err) throw err;
  console.log('The file has been saved with the specified mode!');
});

Setting file ownership

This feature allows the user to set the file ownership (user ID and group ID) atomically with the file write operation.

const writeFileAtomic = require('write-file-atomic');
writeFileAtomic('message.txt', 'Hello, World!', { chown: { uid: 1000, gid: 50 } }, function (err) {
  if (err) throw err;
  console.log('The file has been saved with the specified ownership!');
});

Other packages similar to write-file-atomic

Keywords

FAQs

Package last updated on 25 Sep 2024

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