Skip to content

Commit

Permalink
docs(readme): clean up API/usage syntax (#90)
Browse files Browse the repository at this point in the history
fixes readme syntax
  • Loading branch information
darcyclarke committed Jan 18, 2022
1 parent d4d0f3c commit 22c6990
Showing 1 changed file with 23 additions and 4 deletions.
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])
```

0 comments on commit 22c6990

Please sign in to comment.