Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 16, 2024 via pnpm

write-file-atomic 1.2.0

Write files in an atomic fashion w/configurable ownership
Package summary
Share
0
issues
2
licenses
3
ISC
1
MIT
Package created
10 Sep 2014
Version published
18 Aug 2016
Maintainers
5
Total deps
4
Direct deps
3
License
ISC

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
3 Packages, Including:
graceful-fs@4.2.11
slide@1.1.6
write-file-atomic@1.2.0

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
imurmurhash@0.1.4
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

3
All Dependencies CSV
β“˜ This is a list of write-file-atomic 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
graceful-fs4.2.119.57 kBISC
prod
imurmurhash0.1.44.21 kBMIT
prod
slide1.1.64.29 kBISC
prod

Visualizations

Frequently Asked Questions

What does write-file-atomic do?

The npm package "write-file-atomic" works as an extension to Node.js' fs.writeFile and introduces the ability to write data to a file atomically, with configurable file ownership. The way it functions is by writing data to a temporary file and then renaming it to the desired file name once the operation is complete. This ensures the operation is atomic and improves data integrity by guaranteeing that the file will not be in a corrupted or incomplete state even if an error or process interruption occurs during writing. It also allows for setting user and group ownership (UID/GID) of the file.

How do you use write-file-atomic?

To use write-file-atomic, start by installing it using npm. Once installed, it can be required at the top of your JavaScript file using the following syntax: var writeFileAtomic = require('write-file-atomic'). Now, to write data to a file atomically, use the following syntax:

writeFileAtomic('filename.txt', 'Data to write', {chown:{uid:100,gid:50}}, function (err) {
  if (err) throw err;
  console.log('File has been saved!');
});

Alternatively, this package also supports the async/await syntax. The equivalent async/await code would be:

(async () => {
  try {
    await writeFileAtomic('filename.txt', 'Data to write', {chown:{uid:100,gid:50}});
    console.log('File has been saved!');
  } catch (err) {
    console.error(err);
    process.exit(1);
  }
})();

It also exposes a synchronous version of the writeFileAtomic function which can be used as follows:

var writeFileAtomicSync = require('write-file-atomic').sync;
writeFileAtomicSync('filename.txt', 'Data to write', {chown:{uid:100,gid:50}});

Where are the write-file-atomic docs?

The documentation for write-file-atomic isn't separate and presented elsewhere, but can be found within the README.md file on the package's GitHub repository here. It includes descriptions of its functionality, usage, and a list of configurable options.