diff --git a/lib/repl.js b/lib/repl.js index d3363d4bbc6fd3..dd4c1cc4cc93c7 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 @@ -1319,11 +1319,11 @@ 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; + 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;