@@ -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);
@@ -729,13 +728,14 @@ fs.exists('myfile', (exists) => {
729728```js
730729fs.open('myfile', 'wx', (err, fd) => {
731730 if (err) {
732- if (err.code === " EEXIST" ) {
731+ if (err.code === ' EEXIST' ) {
733732 console.error('myfile already exists');
734733 return;
735- } else {
736- throw err;
737734 }
735+
736+ throw err;
738737 }
738+
739739 writeMyData(fd);
740740});
741741```
@@ -759,15 +759,15 @@ fs.exists('myfile', (exists) => {
759759```js
760760fs.open('myfile', 'r', (err, fd) => {
761761 if (err) {
762- if (err.code === " ENOENT" ) {
762+ if (err.code === ' ENOENT' ) {
763763 console.error('myfile does not exist');
764764 return;
765- } else {
766- throw err;
767765 }
768- } else {
769- readMyData(fd) ;
766+
767+ throw err ;
770768 }
769+
770+ readMyData(fd);
771771});
772772```
773773
@@ -945,7 +945,7 @@ const fd = fs.openSync('temp.txt', 'r+');
945945
946946// truncate the file to 10 bytes, whereas the actual size is 7 bytes
947947fs.ftruncate(fd, 10, (err) => {
948- assert.ifError(! err);
948+ assert.ifError(err);
949949 console.log(fs.readFileSync('temp.txt'));
950950});
951951// Prints: <Buffer 4e 6f 64 65 2e 6a 73 00 00 00>
@@ -1154,8 +1154,8 @@ fs.mkdtemp(tmpDir, (err, folder) => {
11541154});
11551155
11561156// This method is *CORRECT*:
1157- const path = require('path');
1158- fs.mkdtemp(tmpDir + path. sep, (err, folder) => {
1157+ const { sep } = require('path');
1158+ fs.mkdtemp(`${ tmpDir}${ sep}` , (err, folder) => {
11591159 if (err) throw err;
11601160 console.log(folder);
11611161 // Will print something similar to `/tmp/abc123`.
@@ -1564,7 +1564,7 @@ argument will automatically be normalized to absolute path.
15641564Here is an example below:
15651565
15661566```js
1567- fs.symlink('./foo', './new-port');
1567+ fs.symlink('./foo', './new-port', callback );
15681568```
15691569
15701570It creates a symbolic link named "new-port" that points to "foo".
@@ -1910,7 +1910,7 @@ Example:
19101910```js
19111911fs.writeFile('message.txt', 'Hello Node.js', (err) => {
19121912 if (err) throw err;
1913- console.log('It\'s saved!');
1913+ console.log('The file has been saved!');
19141914});
19151915```
19161916
0 commit comments