@@ -14,24 +14,20 @@ way modeled on standard POSIX functions.
14
14
To use the promise-based APIs:
15
15
16
16
``` mjs
17
- // Using ESM Module syntax:
18
17
import * as fs from ' fs/promises' ;
19
18
```
20
19
21
20
``` cjs
22
- // Using CommonJS syntax:
23
21
const fs = require (' fs/promises' );
24
22
```
25
23
26
24
To use the callback and sync APIs:
27
25
28
26
``` mjs
29
- // Using ESM Module syntax:
30
27
import * as fs from ' fs' ;
31
28
```
32
29
33
30
``` cjs
34
- // Using CommonJS syntax:
35
31
const fs = require (' fs' );
36
32
```
37
33
@@ -44,7 +40,6 @@ Promise-based operations return a promise that is fulfilled when the
44
40
asynchronous operation is complete.
45
41
46
42
``` mjs
47
- // Using ESM Module syntax:
48
43
import { unlink } from ' fs/promises' ;
49
44
50
45
try {
56
51
```
57
52
58
53
``` cjs
59
- // Using CommonJS syntax
60
54
const { unlink } = require (' fs/promises' );
61
55
62
56
(async function (path ) {
@@ -78,7 +72,6 @@ reserved for an exception. If the operation is completed successfully, then
78
72
the first argument is ` null ` or ` undefined ` .
79
73
80
74
``` mjs
81
- // Using ESM syntax
82
75
import { unlink } from ' fs' ;
83
76
84
77
unlink (' /tmp/hello' , (err ) => {
@@ -88,7 +81,6 @@ unlink('/tmp/hello', (err) => {
88
81
```
89
82
90
83
``` cjs
91
- // Using CommonJS syntax
92
84
const { unlink } = require (' fs' );
93
85
94
86
unlink (' /tmp/hello' , (err ) => {
@@ -108,7 +100,6 @@ execution until the operation is complete. Exceptions are thrown immediately
108
100
and can be handled using ` try…catch ` , or can be allowed to bubble up.
109
101
110
102
``` mjs
111
- // Using ESM syntax
112
103
import { unlinkSync } from ' fs' ;
113
104
114
105
try {
@@ -120,7 +111,6 @@ try {
120
111
```
121
112
122
113
``` cjs
123
- // Using CommonJS syntax
124
114
const { unlinkSync } = require (' fs' );
125
115
126
116
try {
@@ -6316,7 +6306,6 @@ It is important to correctly order the operations by awaiting the results
6316
6306
of one before invoking the other:
6317
6307
6318
6308
` ` ` mjs
6319
- // Using ESM syntax
6320
6309
import { rename , stat } from ' fs/promises' ;
6321
6310
6322
6311
const from = ' /tmp/hello' ;
@@ -6332,7 +6321,6 @@ try {
6332
6321
` ` `
6333
6322
6334
6323
` ` ` cjs
6335
- // Using CommonJS syntax
6336
6324
const { rename , stat } = require (' fs/promises' );
6337
6325
6338
6326
(async function (from , to ) {
0 commit comments