Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(readme): clean up api/usage syntax #90

Merged
merged 1 commit into from Jan 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 23 additions & 4 deletions README.md
Expand Up @@ -4,8 +4,14 @@ write-file-atomic
This is an extension for node's `fs.writeFile` that makes its operation
atomic and allows you set ownership (uid/gid of the file).

### var writeFileAtomic = require('write-file-atomic')<br>writeFileAtomic(filename, data, [options], [callback])
### `writeFileAtomic(filename, data, [options], [callback])`

#### Description:

Atomically and asynchronously writes data to a file, replacing the file if it already
exists. data can be a string or a buffer.

#### Options:
* filename **String**
* data **String** | **Buffer**
* options **Object** | **String**
Expand All @@ -18,8 +24,12 @@ atomic and allows you set ownership (uid/gid of the file).
* tmpfileCreated **Function** called when the tmpfile is created
* callback **Function**

Atomically and asynchronously writes data to a file, replacing the file if it already
exists. data can be a string or a buffer.
#### Usage:

```js
var writeFileAtomic = require('write-file-atomic')
writeFileAtomic(filename, data, [options], [callback])
```

The file is initially named `filename + "." + murmurhex(__filename, process.pid, ++invocations)`.
Note that `require('worker_threads').threadId` is used in addition to `process.pid` if running inside of a worker thread.
Expand Down Expand Up @@ -67,6 +77,15 @@ This function also supports async/await:
})();
```

### var writeFileAtomicSync = require('write-file-atomic').sync<br>writeFileAtomicSync(filename, data, [options])
### `writeFileAtomicSync(filename, data, [options])`

#### Description:

The synchronous version of **writeFileAtomic**.

#### Usage:
```js
var writeFileAtomicSync = require('write-file-atomic').sync
writeFileAtomicSync(filename, data, [options])
```