Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: small improvements #26496

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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;
Expand Down