@@ -218,7 +218,7 @@ For a regular file [`util.inspect(stats)`][] would return a string very
218218similar to this:
219219
220220``` js
221- {
221+ Stats {
222222 dev: 2114 ,
223223 ino: 48064969 ,
224224 mode: 33188 ,
@@ -232,8 +232,7 @@ similar to this:
232232 atime: Mon, 10 Oct 2011 23 : 24 : 11 GMT ,
233233 mtime: Mon, 10 Oct 2011 23 : 24 : 11 GMT ,
234234 ctime: Mon, 10 Oct 2011 23 : 24 : 11 GMT ,
235- birthtime: Mon, 10 Oct 2011 23 : 24 : 11 GMT
236- }
235+ birthtime: Mon, 10 Oct 2011 23 : 24 : 11 GMT }
237236```
238237
239238Please note that ` atime ` , ` mtime ` , ` birthtime ` , and ` ctime ` are
@@ -377,12 +376,12 @@ fs.access('myfile', (err) => {
377376``` js
378377fs .open (' myfile' , ' wx' , (err , fd ) => {
379378 if (err) {
380- if (err .code === " EEXIST" ) {
379+ if (err .code === ' EEXIST' ) {
381380 console .error (' myfile already exists' );
382381 return ;
383- } else {
384- throw err;
385382 }
383+
384+ throw err;
386385 }
387386
388387 writeMyData (fd);
@@ -394,12 +393,12 @@ fs.open('myfile', 'wx', (err, fd) => {
394393``` js
395394fs .access (' myfile' , (err ) => {
396395 if (err) {
397- if (err .code === " ENOENT" ) {
396+ if (err .code === ' ENOENT' ) {
398397 console .error (' myfile does not exist' );
399398 return ;
400- } else {
401- throw err;
402399 }
400+
401+ throw err;
403402 }
404403
405404 fs .open (' myfile' , ' r' , (err , fd ) => {
@@ -414,12 +413,12 @@ fs.access('myfile', (err) => {
414413``` js
415414fs .open (' myfile' , ' r' , (err , fd ) => {
416415 if (err) {
417- if (err .code === " ENOENT" ) {
416+ if (err .code === ' ENOENT' ) {
418417 console .error (' myfile does not exist' );
419418 return ;
420- } else {
421- throw err;
422419 }
420+
421+ throw err;
423422 }
424423
425424 readMyData (fd);
@@ -779,13 +778,14 @@ fs.exists('myfile', (exists) => {
779778``` js
780779fs .open (' myfile' , ' wx' , (err , fd ) => {
781780 if (err) {
782- if (err .code === " EEXIST" ) {
781+ if (err .code === ' EEXIST' ) {
783782 console .error (' myfile already exists' );
784783 return ;
785- } else {
786- throw err;
787784 }
785+
786+ throw err;
788787 }
788+
789789 writeMyData (fd);
790790});
791791```
@@ -809,15 +809,15 @@ fs.exists('myfile', (exists) => {
809809``` js
810810fs .open (' myfile' , ' r' , (err , fd ) => {
811811 if (err) {
812- if (err .code === " ENOENT" ) {
812+ if (err .code === ' ENOENT' ) {
813813 console .error (' myfile does not exist' );
814814 return ;
815- } else {
816- throw err;
817815 }
818- } else {
819- readMyData (fd) ;
816+
817+ throw err ;
820818 }
819+
820+ readMyData (fd);
821821});
822822```
823823
@@ -1025,7 +1025,7 @@ const fd = fs.openSync('temp.txt', 'r+');
10251025
10261026// truncate the file to 10 bytes, whereas the actual size is 7 bytes
10271027fs .ftruncate (fd, 10 , (err ) => {
1028- assert .ifError (! err);
1028+ assert .ifError (err);
10291029 console .log (fs .readFileSync (' temp.txt' ));
10301030});
10311031// Prints: <Buffer 4e 6f 64 65 2e 6a 73 00 00 00>
@@ -1281,8 +1281,8 @@ fs.mkdtemp(tmpDir, (err, folder) => {
12811281});
12821282
12831283// This method is *CORRECT*:
1284- const path = require (' path' );
1285- fs .mkdtemp (tmpDir + path . sep , (err , folder ) => {
1284+ const { sep } = require (' path' );
1285+ fs .mkdtemp (` ${ tmpDir}${ sep} ` , (err , folder ) => {
12861286 if (err) throw err;
12871287 console .log (folder);
12881288 // Will print something similar to `/tmp/abc123`.
@@ -1763,7 +1763,7 @@ argument will automatically be normalized to absolute path.
17631763Here is an example below:
17641764
17651765``` js
1766- fs .symlink (' ./foo' , ' ./new-port' );
1766+ fs .symlink (' ./foo' , ' ./new-port' , callback );
17671767```
17681768
17691769It creates a symbolic link named "new-port" that points to "foo".
@@ -2174,7 +2174,7 @@ Example:
21742174``` js
21752175fs .writeFile (' message.txt' , ' Hello Node.js' , (err ) => {
21762176 if (err) throw err;
2177- console .log (' It \' s saved!' );
2177+ console .log (' The file has been saved!' );
21782178});
21792179```
21802180
0 commit comments