@@ -4,8 +4,14 @@ write-file-atomic
4
4
This is an extension for node's ` fs.writeFile ` that makes its operation
5
5
atomic and allows you set ownership (uid/gid of the file).
6
6
7
- ### var writeFileAtomic = require('write-file-atomic')< br >writeFileAtomic( filename, data, [ options] , [ callback] )
7
+ ### ` writeFileAtomic( filename, data, [options], [callback]) `
8
8
9
+ #### Description:
10
+
11
+ Atomically and asynchronously writes data to a file, replacing the file if it already
12
+ exists. data can be a string or a buffer.
13
+
14
+ #### Options:
9
15
* filename ** String**
10
16
* data ** String** | ** Buffer**
11
17
* options ** Object** | ** String**
@@ -18,8 +24,12 @@ atomic and allows you set ownership (uid/gid of the file).
18
24
* tmpfileCreated ** Function** called when the tmpfile is created
19
25
* callback ** Function**
20
26
21
- Atomically and asynchronously writes data to a file, replacing the file if it already
22
- exists. data can be a string or a buffer.
27
+ #### Usage:
28
+
29
+ ``` js
30
+ var writeFileAtomic = require (' write-file-atomic' )
31
+ writeFileAtomic (filename, data, [options], [callback])
32
+ ```
23
33
24
34
The file is initially named ` filename + "." + murmurhex(__filename, process.pid, ++invocations) ` .
25
35
Note that ` require('worker_threads').threadId ` is used in addition to ` process.pid ` if running inside of a worker thread.
@@ -67,6 +77,15 @@ This function also supports async/await:
67
77
})();
68
78
```
69
79
70
- ### var writeFileAtomicSync = require('write-file-atomic').sync<br >writeFileAtomicSync(filename, data, [ options] )
80
+ ### ` writeFileAtomicSync(filename, data, [options]) `
81
+
82
+ #### Description:
71
83
72
84
The synchronous version of ** writeFileAtomic** .
85
+
86
+ #### Usage:
87
+ ``` js
88
+ var writeFileAtomicSync = require (' write-file-atomic' ).sync
89
+ writeFileAtomicSync (filename, data, [options])
90
+ ```
91
+
0 commit comments