From 00e3985d32ba4f24bac98ad32ab785d6783aad36 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 25 Mar 2017 15:33:03 +0200 Subject: [PATCH 1/7] doc: unify quotes in fs.md --- doc/api/fs.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index a527e9489672df..4d328279d54cd5 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -377,7 +377,7 @@ fs.access('myfile', (err) => { ```js fs.open('myfile', 'wx', (err, fd) => { if (err) { - if (err.code === "EEXIST") { + if (err.code === 'EEXIST') { console.error('myfile already exists'); return; } else { @@ -394,7 +394,7 @@ fs.open('myfile', 'wx', (err, fd) => { ```js fs.access('myfile', (err) => { if (err) { - if (err.code === "ENOENT") { + if (err.code === 'ENOENT') { console.error('myfile does not exist'); return; } else { @@ -414,7 +414,7 @@ fs.access('myfile', (err) => { ```js fs.open('myfile', 'r', (err, fd) => { if (err) { - if (err.code === "ENOENT") { + if (err.code === 'ENOENT') { console.error('myfile does not exist'); return; } else { @@ -779,7 +779,7 @@ fs.exists('myfile', (exists) => { ```js fs.open('myfile', 'wx', (err, fd) => { if (err) { - if (err.code === "EEXIST") { + if (err.code === 'EEXIST') { console.error('myfile already exists'); return; } else { @@ -809,7 +809,7 @@ fs.exists('myfile', (exists) => { ```js fs.open('myfile', 'r', (err, fd) => { if (err) { - if (err.code === "ENOENT") { + if (err.code === 'ENOENT') { console.error('myfile does not exist'); return; } else { From e8f88ecba4b7e99732be93286282ec4680c8aaff Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 25 Mar 2017 15:37:00 +0200 Subject: [PATCH 2/7] doc: avoid quote escaping in fs.md --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 4d328279d54cd5..2eb902cc2b41fa 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2173,7 +2173,7 @@ Example: ```js fs.writeFile('message.txt', 'Hello Node.js', (err) => { if (err) throw err; - console.log('It\'s saved!'); + console.log('The file has been saved!'); }); ``` From f02f2d8d5670f24d026c74fb3c32e4b6b853cf8b Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 25 Mar 2017 15:41:39 +0200 Subject: [PATCH 3/7] doc: simplify logics in fs.md Delete unnecessary `else` after `return` and `throw`. --- doc/api/fs.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 2eb902cc2b41fa..c936b39e5b6423 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -380,9 +380,9 @@ fs.open('myfile', 'wx', (err, fd) => { if (err.code === 'EEXIST') { console.error('myfile already exists'); return; - } else { - throw err; } + + throw err; } writeMyData(fd); @@ -397,9 +397,9 @@ fs.access('myfile', (err) => { if (err.code === 'ENOENT') { console.error('myfile does not exist'); return; - } else { - throw err; } + + throw err; } fs.open('myfile', 'r', (err, fd) => { @@ -417,9 +417,9 @@ fs.open('myfile', 'r', (err, fd) => { if (err.code === 'ENOENT') { console.error('myfile does not exist'); return; - } else { - throw err; } + + throw err; } readMyData(fd); @@ -782,10 +782,11 @@ fs.open('myfile', 'wx', (err, fd) => { if (err.code === 'EEXIST') { console.error('myfile already exists'); return; - } else { - throw err; } + + throw err; } + writeMyData(fd); }); ``` @@ -812,12 +813,12 @@ fs.open('myfile', 'r', (err, fd) => { if (err.code === 'ENOENT') { console.error('myfile does not exist'); return; - } else { - throw err; } - } else { - readMyData(fd); + + throw err; } + + readMyData(fd); }); ``` From 599b771ecb2860a4686d05e40db36a88fada749b Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 25 Mar 2017 15:43:33 +0200 Subject: [PATCH 4/7] doc: concatenation -> template literal in fs.md --- doc/api/fs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index c936b39e5b6423..d1379161f82747 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1282,8 +1282,8 @@ fs.mkdtemp(tmpDir, (err, folder) => { }); // This method is *CORRECT*: -const path = require('path'); -fs.mkdtemp(tmpDir + path.sep, (err, folder) => { +const { sep } = require('path'); +fs.mkdtemp(`${tmpDir}${sep}`, (err, folder) => { if (err) throw err; console.log(folder); // Will print something similar to `/tmp/abc123`. From 0994787132c191f48deece681b3425bf76062a2f Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 25 Mar 2017 15:44:28 +0200 Subject: [PATCH 5/7] doc: add missing callback in fs.md --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index d1379161f82747..a6a61f1d078dee 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1764,7 +1764,7 @@ argument will automatically be normalized to absolute path. Here is an example below: ```js -fs.symlink('./foo', './new-port'); +fs.symlink('./foo', './new-port', callback); ``` It creates a symbolic link named "new-port" that points to "foo". From 43ef4b2a7e21297b0df1391be81287c7516faf54 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 25 Mar 2017 15:45:51 +0200 Subject: [PATCH 6/7] doc: fix typo in fs.md --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index a6a61f1d078dee..c0c21b81687599 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1026,7 +1026,7 @@ const fd = fs.openSync('temp.txt', 'r+'); // truncate the file to 10 bytes, whereas the actual size is 7 bytes fs.ftruncate(fd, 10, (err) => { - assert.ifError(!err); + assert.ifError(err); console.log(fs.readFileSync('temp.txt')); }); // Prints: From 6873d7192b0ac8b7e87495a6b3f5de839731159d Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 25 Mar 2017 15:47:19 +0200 Subject: [PATCH 7/7] doc: update output example in fs.md --- doc/api/fs.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index c0c21b81687599..0105d35fc2a3d5 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -218,7 +218,7 @@ For a regular file [`util.inspect(stats)`][] would return a string very similar to this: ```js -{ +Stats { dev: 2114, ino: 48064969, mode: 33188, @@ -232,8 +232,7 @@ similar to this: atime: Mon, 10 Oct 2011 23:24:11 GMT, mtime: Mon, 10 Oct 2011 23:24:11 GMT, ctime: Mon, 10 Oct 2011 23:24:11 GMT, - birthtime: Mon, 10 Oct 2011 23:24:11 GMT -} + birthtime: Mon, 10 Oct 2011 23:24:11 GMT } ``` Please note that `atime`, `mtime`, `birthtime`, and `ctime` are