Skip to content

Commit

Permalink
fixup: remove redundant check
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Jun 25, 2021
1 parent 668e201 commit 637cd50
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/internal/repl/await.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const {
ArrayPrototypePush,
FunctionPrototype,
ObjectKeys,
StringPrototypeEndsWith,
StringPrototypeIncludes,
StringPrototypeReplace,
StringPrototypeSplit,
SyntaxError,
} = primordials;

Expand Down Expand Up @@ -110,20 +114,18 @@ function processTopLevelAwait(src) {
// Convert keyword parse errors on await into their original errors when
// possible.
if (errPos === awaitPos + 6 &&
src.slice(errPos - 6, errPos - 1) === 'await' &&
e.message.includes('Expecting Unicode escape sequence'))
StringPrototypeIncludes(e.message, 'Expecting Unicode escape sequence'))
return null;
if (errPos === awaitPos + 7 &&
src.slice(errPos - 7, errPos - 2) === 'await' &&
e.message.includes('Unexpected token'))
StringPrototypeIncludes(e.message, 'Unexpected token'))
return null;
const { line, column } = e.loc;
let message = '\n' + src.split('\n')[line - 2] + '\n';
let message = '\n' + StringPrototypeSplit(src, '\n')[line - 2] + '\n';
let i = 0;
while (i++ < column) message += ' ';
message += '^\n\n' + e.message.replace(/ \([^)]+\)/, '');
message += '^\n\n' + StringPrototypeReplace(e.message, / \([^)]+\)/, '');
// V8 unexpected token errors include the token string.
if (message.endsWith('Unexpected token'))
if (StringPrototypeEndsWith(message, 'Unexpected token'))
message += " '" + src[e.pos - wrapPrefix.length] + "'";
// eslint-disable-next-line no-restricted-syntax
throw new SyntaxError(message);
Expand Down

0 comments on commit 637cd50

Please sign in to comment.