Skip to content

Commit bc2b983

Browse files
committed
2 parents ece6a66 + 6f8a8b9 commit bc2b983

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/tokenizer.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ import { Token, TokenName } from './token';
44

55
type ReaderEntry = string | null;
66

7+
const beforeFunctionExpressionTokens = [
8+
'(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
9+
'return', 'case', 'delete', 'throw', 'void',
10+
// assignment operators
11+
'=', '+=', '-=', '*=', '**=', '/=', '%=', '<<=', '>>=', '>>>=',
12+
'&=', '|=', '^=', ',',
13+
// binary/unary operators
14+
'+', '-', '*', '**', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
15+
'|', '^', '!', '~', '&&', '||', '??', '?', ':', '===', '==', '>=',
16+
'<=', '<', '>', '!=', '!=='
17+
];
18+
719
interface BufferEntry {
820
type: string;
921
value: string;
@@ -27,15 +39,7 @@ class Reader {
2739

2840
// A function following one of those tokens is an expression.
2941
beforeFunctionExpression(t: string): boolean {
30-
return ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
31-
'return', 'case', 'delete', 'throw', 'void',
32-
// assignment operators
33-
'=', '+=', '-=', '*=', '**=', '/=', '%=', '<<=', '>>=', '>>>=',
34-
'&=', '|=', '^=', ',',
35-
// binary/unary operators
36-
'+', '-', '*', '**', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
37-
'|', '^', '!', '~', '&&', '||', '??', '?', ':', '===', '==', '>=',
38-
'<=', '<', '>', '!=', '!=='].indexOf(t) >= 0;
42+
return beforeFunctionExpressionTokens.includes(t);
3943
}
4044

4145
// Determine if forward slash (/) is an operator or part of a regular expression

0 commit comments

Comments
 (0)