@@ -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' );
@@ -1563,7 +1553,7 @@ deprecated: v1.0.0
1563
1553
* ` exists ` {boolean}
1564
1554
1565
1555
Test whether or not the given path exists by checking with the file system.
1566
- Then call the ` callback ` argument with either true or false. Example :
1556
+ Then call the ` callback ` argument with either true or false:
1567
1557
1568
1558
``` js
1569
1559
fs .exists (' /etc/passwd' , (exists ) => {
@@ -1896,7 +1886,7 @@ fs.ftruncate(fd, 4, (err) => {
1896
1886
```
1897
1887
1898
1888
If the file previously was shorter than ` len ` bytes, it is extended, and the
1899
- extended part is filled with null bytes (` '\0' ` ). For example,
1889
+ extended part is filled with null bytes (` '\0' ` ):
1900
1890
1901
1891
``` js
1902
1892
console .log (fs .readFileSync (' temp.txt' , ' utf8' ));
@@ -2485,7 +2475,7 @@ changes:
2485
2475
* ` err ` {Error}
2486
2476
* ` data ` {string|Buffer}
2487
2477
2488
- Asynchronously reads the entire contents of a file. Example:
2478
+ Asynchronously reads the entire contents of a file.
2489
2479
2490
2480
``` js
2491
2481
fs .readFile (' /etc/passwd' , (err , data ) => {
@@ -2499,7 +2489,7 @@ contents of the file.
2499
2489
2500
2490
If no encoding is specified, then the raw buffer is returned.
2501
2491
2502
- If ` options ` is a string, then it specifies the encoding. Example :
2492
+ If ` options ` is a string, then it specifies the encoding:
2503
2493
2504
2494
``` js
2505
2495
fs .readFile (' /etc/passwd' , ' utf8' , callback);
@@ -3499,8 +3489,6 @@ Asynchronously writes data to a file, replacing the file if it already exists.
3499
3489
3500
3490
The ` encoding ` option is ignored if ` data ` is a buffer.
3501
3491
3502
- Example:
3503
-
3504
3492
``` js
3505
3493
const data = new Uint8Array (Buffer .from (' Hello Node.js' ));
3506
3494
fs .writeFile (' message.txt' , data, (err ) => {
@@ -3509,7 +3497,7 @@ fs.writeFile('message.txt', data, (err) => {
3509
3497
});
3510
3498
```
3511
3499
3512
- If ` options ` is a string, then it specifies the encoding. Example :
3500
+ If ` options ` is a string, then it specifies the encoding:
3513
3501
3514
3502
``` js
3515
3503
fs .writeFile (' message.txt' , ' Hello Node.js' , ' utf8' , callback);
@@ -3820,7 +3808,7 @@ doTruncate().catch(console.error);
3820
3808
```
3821
3809
3822
3810
If the file previously was shorter than ` len ` bytes, it is extended, and the
3823
- extended part is filled with null bytes (` '\0' ` ). For example,
3811
+ extended part is filled with null bytes (` '\0' ` ):
3824
3812
3825
3813
``` js
3826
3814
const fs = require (' fs' );
@@ -4030,8 +4018,6 @@ fallback copy mechanism is used.
4030
4018
create a copy-on-write reflink. If the platform does not support copy-on-write,
4031
4019
then the operation will fail.
4032
4020
4033
- Example:
4034
-
4035
4021
``` js
4036
4022
const fsPromises = require (' fs' ).promises ;
4037
4023
@@ -4041,8 +4027,7 @@ fsPromises.copyFile('source.txt', 'destination.txt')
4041
4027
.catch (() => console .log (' The file could not be copied' ));
4042
4028
```
4043
4029
4044
- If the third argument is a number, then it specifies ` flags ` , as shown in the
4045
- following example.
4030
+ If the third argument is a number, then it specifies ` flags ` :
4046
4031
4047
4032
``` js
4048
4033
const fs = require (' fs' );
0 commit comments