From 5c19b0e3f6d18933dc6499c4a376212bdc22b1a5 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Date: Wed, 16 Nov 2016 01:41:14 +0200 Subject: [PATCH 1/2] doc: small improvements in readline code examples 1. Consistent template literals in `console.log()`. 2. === instead of ==. --- doc/api/readline.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index 36c7e4502274bd..ea11fbac90c25a 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -21,7 +21,7 @@ const rl = readline.createInterface({ rl.question('What do you think of Node.js? ', (answer) => { // TODO: Log the answer in a database - console.log('Thank you for your valuable feedback:', answer); + console.log(`Thank you for your valuable feedback: ${answer}`); rl.close(); }); @@ -404,7 +404,7 @@ For instance: `[[substr1, substr2, ...], originalsubstring]`. ```js function completer(line) { var completions = '.help .error .exit .quit .q'.split(' '); - var hits = completions.filter((c) => { return c.indexOf(line) == 0 }); + var hits = completions.filter((c) => { return c.indexOf(line) === 0 }); // show all completions if none found return [hits.length ? hits : completions, line]; } @@ -512,7 +512,7 @@ const rl = readline.createInterface({ }); rl.on('line', (line) => { - console.log('Line from file:', line); + console.log(`Line from file: ${line}`); }); ``` From 28d9bdeccc9fe0c22f2de10ba833f1f135bc3060 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Date: Wed, 16 Nov 2016 02:23:13 +0200 Subject: [PATCH 2/2] doc: more improvements in readline code examples const instead of var --- doc/api/readline.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index ea11fbac90c25a..fff79817335e3c 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -403,8 +403,8 @@ For instance: `[[substr1, substr2, ...], originalsubstring]`. ```js function completer(line) { - var completions = '.help .error .exit .quit .q'.split(' '); - var hits = completions.filter((c) => { return c.indexOf(line) === 0 }); + const completions = '.help .error .exit .quit .q'.split(' '); + const hits = completions.filter((c) => { return c.indexOf(line) === 0 }); // show all completions if none found return [hits.length ? hits : completions, line]; }