From 8819736848a84fb2a0c644d9cdd10ed94676e32a Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Thu, 7 Mar 2019 22:31:13 +0800 Subject: [PATCH 1/4] repl: remove redundant escape --- lib/repl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/repl.js b/lib/repl.js index d3363d4bbc6fd3..fa138e87118c9c 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -229,7 +229,7 @@ function REPLServer(prompt, let awaitPromise = false; const input = code; - if (/^\s*\{/.test(code) && /\}\s*$/.test(code)) { + if (/^\s*{/.test(code) && /\}\s*$/.test(code)) { // It's confusing for `{ a : 1 }` to be interpreted as a block // statement rather than an object literal. So, we first try // to wrap it in parentheses, so that it will be interpreted as From 26c689711fe62f8ddffb25b2aee93b42d77398a7 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Thu, 7 Mar 2019 23:46:28 +0800 Subject: [PATCH 2/4] repl: remove redundant escape --- lib/repl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/repl.js b/lib/repl.js index fa138e87118c9c..fdd5d939856d30 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -229,7 +229,7 @@ function REPLServer(prompt, let awaitPromise = false; const input = code; - if (/^\s*{/.test(code) && /\}\s*$/.test(code)) { + if (/^\s*{/.test(code) && /}\s*$/.test(code)) { // It's confusing for `{ a : 1 }` to be interpreted as a block // statement rather than an object literal. So, we first try // to wrap it in parentheses, so that it will be interpreted as From 6a83057b1e3447210826d7b32d02214d3c04e792 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Thu, 7 Mar 2019 22:33:29 +0800 Subject: [PATCH 3/4] repl: simplify regex expression --- lib/repl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index fdd5d939856d30..858654975c248a 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1319,8 +1319,8 @@ function _memory(cmd) { if (cmd) { // Going down is { and ( e.g. function() { // going up is } and ) - var dw = cmd.match(/{|\(/g); - var up = cmd.match(/}|\)/g); + let dw = cmd.match(/[{(]/g); + let up = cmd.match(/[})]/g); up = up ? up.length : 0; dw = dw ? dw.length : 0; var depth = dw - up; From 3ca5b2afadbffe3bfcaba2ae7b8fcf9b6f59f0af Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Thu, 7 Mar 2019 22:36:30 +0800 Subject: [PATCH 4/4] repl: eliminate var in function _memory --- lib/repl.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index 858654975c248a..dd4c1cc4cc93c7 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1323,7 +1323,7 @@ function _memory(cmd) { let up = cmd.match(/[})]/g); up = up ? up.length : 0; dw = dw ? dw.length : 0; - var depth = dw - up; + let depth = dw - up; if (depth) { (function workIt() { @@ -1342,9 +1342,9 @@ function _memory(cmd) { }); } else if (depth < 0) { // Going... up. - var curr = self.lines.level.pop(); + const curr = self.lines.level.pop(); if (curr) { - var tmp = curr.depth + depth; + const tmp = curr.depth + depth; if (tmp < 0) { // More to go, recurse depth += curr.depth;