Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6d53e79

Browse filesBrowse files
aduh95danielleadams
authored andcommitted
repl: refactor to avoid unsafe array iteration
PR-URL: #37345 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 799b2d5 commit 6d53e79
Copy full SHA for 6d53e79

File tree

Expand file treeCollapse file tree

3 files changed

+10
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-5
lines changed
Open diff view settings
Collapse file

‎lib/internal/repl/await.js‎

Copy file name to clipboardExpand all lines: lib/internal/repl/await.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
ArrayFrom,
5+
ArrayPrototypeForEach,
56
ArrayPrototypeJoin,
67
ArrayPrototypePop,
78
ArrayPrototypePush,
@@ -61,10 +62,10 @@ const visitorsWithoutAncestors = {
6162
state.replace(node.start, node.start + node.kind.length, 'void (');
6263
}
6364

64-
for (const decl of node.declarations) {
65+
ArrayPrototypeForEach(node.declarations, (decl) => {
6566
state.prepend(decl, '(');
6667
state.append(decl, decl.init ? ')' : '=undefined)');
67-
}
68+
});
6869

6970
if (node.declarations.length !== 1) {
7071
state.append(node.declarations[node.declarations.length - 1], ')');
Collapse file

‎lib/internal/repl/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/repl/utils.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ function isRecoverableError(e, code) {
103103
staticClassFeatures,
104104
(Parser) => {
105105
return class extends Parser {
106+
// eslint-disable-next-line no-useless-constructor
107+
constructor(options, input, startPos) {
108+
super(options, input, startPos);
109+
}
106110
nextToken() {
107111
super.nextToken();
108112
if (this.type === tt.eof)
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const {
6262
Boolean,
6363
Error,
6464
FunctionPrototypeBind,
65-
MathMax,
65+
MathMaxApply,
6666
NumberIsNaN,
6767
NumberParseFloat,
6868
ObjectAssign,
@@ -1647,8 +1647,8 @@ function defineDefaultCommands(repl) {
16471647
help: 'Print this help message',
16481648
action: function() {
16491649
const names = ArrayPrototypeSort(ObjectKeys(this.commands));
1650-
const longestNameLength = MathMax(
1651-
...ArrayPrototypeMap(names, (name) => name.length)
1650+
const longestNameLength = MathMaxApply(
1651+
ArrayPrototypeMap(names, (name) => name.length)
16521652
);
16531653
ArrayPrototypeForEach(names, (name) => {
16541654
const cmd = this.commands[name];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.