@@ -1044,16 +1044,14 @@ changes:
1044
1044
Asynchronously append data to a file, creating the file if it does not yet
1045
1045
exist. ` data ` can be a string or a [ ` Buffer ` ] [ ] .
1046
1046
1047
- Example:
1048
-
1049
1047
``` js
1050
1048
fs .appendFile (' message.txt' , ' data to append' , (err ) => {
1051
1049
if (err) throw err;
1052
1050
console .log (' The "data to append" was appended to file!' );
1053
1051
});
1054
1052
```
1055
1053
1056
- If ` options ` is a string, then it specifies the encoding. Example :
1054
+ If ` options ` is a string, then it specifies the encoding:
1057
1055
1058
1056
``` js
1059
1057
fs .appendFile (' message.txt' , ' data to append' , ' utf8' , callback);
@@ -1097,8 +1095,6 @@ changes:
1097
1095
Synchronously append data to a file, creating the file if it does not yet
1098
1096
exist. ` data ` can be a string or a [ ` Buffer ` ] [ ] .
1099
1097
1100
- Example:
1101
-
1102
1098
``` js
1103
1099
try {
1104
1100
fs .appendFileSync (' message.txt' , ' data to append' );
@@ -1108,7 +1104,7 @@ try {
1108
1104
}
1109
1105
```
1110
1106
1111
- If ` options ` is a string, then it specifies the encoding. Example :
1107
+ If ` options ` is a string, then it specifies the encoding:
1112
1108
1113
1109
``` js
1114
1110
fs .appendFileSync (' message.txt' , ' data to append' , ' utf8' );
@@ -1344,8 +1340,6 @@ fallback copy mechanism is used.
1344
1340
create a copy-on-write reflink. If the platform does not support copy-on-write,
1345
1341
then the operation will fail.
1346
1342
1347
- Example:
1348
-
1349
1343
``` js
1350
1344
const fs = require (' fs' );
1351
1345
@@ -1356,8 +1350,7 @@ fs.copyFile('source.txt', 'destination.txt', (err) => {
1356
1350
});
1357
1351
```
1358
1352
1359
- If the third argument is a number, then it specifies ` flags ` , as shown in the
1360
- following example.
1353
+ If the third argument is a number, then it specifies ` flags ` :
1361
1354
1362
1355
``` js
1363
1356
const fs = require (' fs' );
@@ -1395,8 +1388,6 @@ fallback copy mechanism is used.
1395
1388
create a copy-on-write reflink. If the platform does not support copy-on-write,
1396
1389
then the operation will fail.
1397
1390
1398
- Example:
1399
-
1400
1391
``` js
1401
1392
const fs = require (' fs' );
1402
1393
@@ -1405,8 +1396,7 @@ fs.copyFileSync('source.txt', 'destination.txt');
1405
1396
console .log (' source.txt was copied to destination.txt' );
1406
1397
```
1407
1398
1408
- If the third argument is a number, then it specifies ` flags ` , as shown in the
1409
- following example.
1399
+ If the third argument is a number, then it specifies ` flags ` :
1410
1400
1411
1401
``` js
1412
1402
const fs = require (' fs' );
@@ -1568,7 +1558,7 @@ deprecated: v1.0.0
1568
1558
* ` exists ` {boolean}
1569
1559
1570
1560
Test whether or not the given path exists by checking with the file system.
1571
- Then call the ` callback ` argument with either true or false. Example :
1561
+ Then call the ` callback ` argument with either true or false:
1572
1562
1573
1563
``` js
1574
1564
fs .exists (' /etc/passwd' , (exists ) => {
@@ -1901,7 +1891,7 @@ fs.ftruncate(fd, 4, (err) => {
1901
1891
```
1902
1892
1903
1893
If the file previously was shorter than ` len ` bytes, it is extended, and the
1904
- extended part is filled with null bytes (` '\0' ` ). For example,
1894
+ extended part is filled with null bytes (` '\0' ` ):
1905
1895
1906
1896
``` js
1907
1897
console .log (fs .readFileSync (' temp.txt' , ' utf8' ));
@@ -2505,7 +2495,7 @@ changes:
2505
2495
* ` err ` {Error}
2506
2496
* ` data ` {string|Buffer}
2507
2497
2508
- Asynchronously reads the entire contents of a file. Example:
2498
+ Asynchronously reads the entire contents of a file.
2509
2499
2510
2500
``` js
2511
2501
fs .readFile (' /etc/passwd' , (err , data ) => {
@@ -2519,7 +2509,7 @@ contents of the file.
2519
2509
2520
2510
If no encoding is specified, then the raw buffer is returned.
2521
2511
2522
- If ` options ` is a string, then it specifies the encoding. Example :
2512
+ If ` options ` is a string, then it specifies the encoding:
2523
2513
2524
2514
``` js
2525
2515
fs .readFile (' /etc/passwd' , ' utf8' , callback);
@@ -3519,8 +3509,6 @@ Asynchronously writes data to a file, replacing the file if it already exists.
3519
3509
3520
3510
The ` encoding ` option is ignored if ` data ` is a buffer.
3521
3511
3522
- Example:
3523
-
3524
3512
``` js
3525
3513
const data = new Uint8Array (Buffer .from (' Hello Node.js' ));
3526
3514
fs .writeFile (' message.txt' , data, (err ) => {
@@ -3529,7 +3517,7 @@ fs.writeFile('message.txt', data, (err) => {
3529
3517
});
3530
3518
```
3531
3519
3532
- If ` options ` is a string, then it specifies the encoding. Example :
3520
+ If ` options ` is a string, then it specifies the encoding:
3533
3521
3534
3522
``` js
3535
3523
fs .writeFile (' message.txt' , ' Hello Node.js' , ' utf8' , callback);
@@ -3840,7 +3828,7 @@ doTruncate().catch(console.error);
3840
3828
```
3841
3829
3842
3830
If the file previously was shorter than ` len ` bytes, it is extended, and the
3843
- extended part is filled with null bytes (` '\0' ` ). For example,
3831
+ extended part is filled with null bytes (` '\0' ` ):
3844
3832
3845
3833
``` js
3846
3834
const fs = require (' fs' );
@@ -4050,8 +4038,6 @@ fallback copy mechanism is used.
4050
4038
create a copy-on-write reflink. If the platform does not support copy-on-write,
4051
4039
then the operation will fail.
4052
4040
4053
- Example:
4054
-
4055
4041
``` js
4056
4042
const fsPromises = require (' fs' ).promises ;
4057
4043
@@ -4061,8 +4047,7 @@ fsPromises.copyFile('source.txt', 'destination.txt')
4061
4047
.catch (() => console .log (' The file could not be copied' ));
4062
4048
```
4063
4049
4064
- If the third argument is a number, then it specifies ` flags ` , as shown in the
4065
- following example.
4050
+ If the third argument is a number, then it specifies ` flags ` :
4066
4051
4067
4052
``` js
4068
4053
const fs = require (' fs' );
0 commit comments