Skip to content

Commit 637cd50

Browse files
committed
fixup: remove redundant check
1 parent 668e201 commit 637cd50

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/internal/repl/await.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const {
88
ArrayPrototypePush,
99
FunctionPrototype,
1010
ObjectKeys,
11+
StringPrototypeEndsWith,
12+
StringPrototypeIncludes,
13+
StringPrototypeReplace,
14+
StringPrototypeSplit,
1115
SyntaxError,
1216
} = primordials;
1317

@@ -110,20 +114,18 @@ function processTopLevelAwait(src) {
110114
// Convert keyword parse errors on await into their original errors when
111115
// possible.
112116
if (errPos === awaitPos + 6 &&
113-
src.slice(errPos - 6, errPos - 1) === 'await' &&
114-
e.message.includes('Expecting Unicode escape sequence'))
117+
StringPrototypeIncludes(e.message, 'Expecting Unicode escape sequence'))
115118
return null;
116119
if (errPos === awaitPos + 7 &&
117-
src.slice(errPos - 7, errPos - 2) === 'await' &&
118-
e.message.includes('Unexpected token'))
120+
StringPrototypeIncludes(e.message, 'Unexpected token'))
119121
return null;
120122
const { line, column } = e.loc;
121-
let message = '\n' + src.split('\n')[line - 2] + '\n';
123+
let message = '\n' + StringPrototypeSplit(src, '\n')[line - 2] + '\n';
122124
let i = 0;
123125
while (i++ < column) message += ' ';
124-
message += '^\n\n' + e.message.replace(/ \([^)]+\)/, '');
126+
message += '^\n\n' + StringPrototypeReplace(e.message, / \([^)]+\)/, '');
125127
// V8 unexpected token errors include the token string.
126-
if (message.endsWith('Unexpected token'))
128+
if (StringPrototypeEndsWith(message, 'Unexpected token'))
127129
message += " '" + src[e.pos - wrapPrefix.length] + "'";
128130
// eslint-disable-next-line no-restricted-syntax
129131
throw new SyntaxError(message);

0 commit comments

Comments
 (0)