Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

meriyah

Package Overview
Dependencies
Maintainers
1
Versions
917
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meriyah - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1-dev.20190627

6

dist/common.d.ts

@@ -53,4 +53,4 @@ import { Token } from './token';

None = 0,
ArgList = 1,
Variable = 4,
Variable = 1,
ArgList = 2,
Let = 8,

@@ -113,3 +113,3 @@ Const = 16

startLine: number;
columnPos: number;
colPos: number;
linePos: number;

@@ -116,0 +116,0 @@ end: number;

@@ -7,6 +7,6 @@ import { ParserState } from './common';

description: string;
constructor(index: number, line: number, column: number, source: string, type: Errors, ...params: string[]);
constructor(startindex: number, line: number, column: number, source: string, type: Errors, ...params: string[]);
}
export declare function report(state: ParserState, type: Errors, ...params: string[]): never;
export declare function reportAt(state: ParserState, index: number, line: number, column: number, type: Errors, ...params: string[]): never;
export declare function report(parser: ParserState, type: Errors, ...params: string[]): never;
export declare function reportAt(parser: ParserState, index: number, line: number, column: number, type: Errors, ...params: string[]): never;
//# sourceMappingURL=errors.d.ts.map

@@ -8,4 +8,5 @@ import { ParserState } from '../common';

}
export declare function nextCodePoint(parser: ParserState): number;
export declare function nextCP(parser: ParserState): number;
export declare function consumeMultiUnitCodePoint(parser: ParserState, hi: number): boolean;
export declare function storeRaw(parser: ParserState, start: number): void;
export declare function consumeLineFeed(parser: ParserState, lastIsCR: boolean): void;

@@ -12,0 +13,0 @@ export declare function advanceNewline(parser: ParserState): void;

export { scanSingleToken, nextToken } from './scan';
export { skipMultiLineComment, skipSingleLineComment, skipHashBang } from './comments';
export { nextCodePoint, consumeMultiUnitCodePoint, isExoticECMAScriptWhitespace, fromCodePoint, toHex, consumeLineFeed, advanceNewline, LexerState } from './common';
export { nextCP, consumeMultiUnitCodePoint, isExoticECMAScriptWhitespace, fromCodePoint, toHex, storeRaw, consumeLineFeed, advanceNewline, LexerState } from './common';
export { CharTypes, CharFlags, isIdentifierStart, isIdentifierPart } from './charClassifier';

@@ -5,0 +5,0 @@ export { scanIdentifier, scanIdentifierSlowCase, scanUnicodeIdentifier, scanPrivateName, scanUnicodeEscapeValue } from './identifier';

@@ -6,3 +6,3 @@ import { Options } from './parser';

export declare function parse(source: string, options: Options | void): ESTree.Program;
export declare const version = "0.5.2";
export declare const version = "0.6.1";
//# sourceMappingURL=meriyah.d.ts.map

@@ -49,3 +49,3 @@ import { Token } from './token';

export declare function parseVariableStatement(parser: ParserState, context: Context, scope: ScopeState, origin: BindingOrigin, start: number, line: number, column: number): ESTree.VariableDeclaration;
export declare function parseVariableDeclarationList(parser: ParserState, context: Context, scope: ScopeState, verifyDuplicates: 0 | 1, type: BindingType, origin: BindingOrigin): ESTree.VariableDeclarator[];
export declare function parseVariableDeclarationList(parser: ParserState, context: Context, scope: ScopeState, verifyDuplicates: 0 | 1, isVarDecl: 0 | 1, type: BindingType, origin: BindingOrigin): ESTree.VariableDeclarator[];
export declare function parseForStatement(parser: ParserState, context: Context, scope: ScopeState, labels: any, start: number, line: number, column: number): ESTree.ForStatement | ESTree.ForInStatement | ESTree.ForOfStatement;

@@ -99,3 +99,3 @@ export declare function parseExpression(parser: ParserState, context: Context, assignable: 0 | 1, inGroup: 0 | 1, start: number, line: number, column: number): ESTree.Expression;

export declare function parseFieldDefinition(parser: ParserState, context: Context, key: ESTree.PrivateName | ESTree.Expression | null, state: PropertyKind, decorators: ESTree.Decorator[] | null, start: number, line: number, column: number): ESTree.FieldDefinition;
export declare function parseBindingPattern(parser: ParserState, context: Context, scope: any, dupeChecks: 0 | 1, type: BindingType, origin: BindingOrigin, start: number, line: number, column: number): ESTree.Pattern | ESTree.Identifier;
export declare function parseBindingPattern(parser: ParserState, context: Context, scope: any, dupeChecks: 0 | 1, isVarDecl: 0 | 1, type: BindingType, origin: BindingOrigin, start: number, line: number, column: number): ESTree.Pattern | ESTree.Identifier;
//# sourceMappingURL=parser.d.ts.map

@@ -0,0 +0,0 @@ ISC License

{
"name": "meriyah",
"version": "0.6.0",
"version": "0.6.1-dev.20190627",
"description": "A 100% compliant, self-hosted javascript parser with high focus on both performance and stability",

@@ -92,2 +92,2 @@ "main": "dist/meriyah.umd.js",

}
}
}

@@ -19,4 +19,4 @@ # Meriyah

* Reduced memory usage
* Very well tested (~81 000 unit tests with full code coverage))
* Lightweight - ~76 KB minified
* Very well tested (~81 000 unit tests with full code coverage)
* Lightweight - ~82 KB minified

@@ -123,1 +123,11 @@ ## ESNext features

| `webcompat` | Enable [web compability](https://tc39.github.io/ecma262/#sec-additional-ecmascript-features-for-web-browsers) |
## ECMAScript compability
Meriyah is 100% ECMA spec compatible, but you have to enable several [options](https://github.com/meriyah/meriyah#options) to make sure your code parses with 100% ECMA spec compability. This is done because Meriyah's main focus is on performance, and each option you enable will have impact on it's performance.
Also note that support for additional ECMAScript features for Web Browsers (*annexB*) isn't enabled by default as in other parsers, but you can instead parse with and without web compability .
This is done because AnnexB is an extension of the language, and also beaucse all the `Test262 suite` tests has no web compability.
Lexical binding and scope tracking has to be enabled with the `lexical` option.

@@ -61,4 +61,4 @@ import { Token, KeywordDescTable } from './token';

None = 0,
ArgList = 1 << 0,
Variable = 1 << 2,
Variable = 1 << 0,
ArgList = 1 << 1,
Let = 1 << 3,

@@ -137,3 +137,3 @@ Const = 1 << 4

startLine: number;
columnPos: number;
colPos: number;
linePos: number;

@@ -140,0 +140,0 @@ end: number;

@@ -349,3 +349,3 @@ import { ParserState } from './common';

public description: string;
constructor(index: number, line: number, column: number, source: string, type: Errors, ...params: string[]) {
constructor(startindex: number, line: number, column: number, source: string, type: Errors, ...params: string[]) {
let message =

@@ -362,3 +362,3 @@ '[' + line + ':' + column + ']: ' + errorMessages[type].replace(/%(\d+)/g, (_: string, i: number) => params[i]);

this.index = index;
this.index = startindex;
this.line = line;

@@ -379,4 +379,4 @@ this.column = column;

*/
export function report(state: ParserState, type: Errors, ...params: string[]): never {
throw new ParseError(state.index, state.line, state.column, state.source, type, ...params);
export function report(parser: ParserState, type: Errors, ...params: string[]): never {
throw new ParseError(parser.index, parser.line, parser.column, parser.source, type, ...params);
}

@@ -397,3 +397,3 @@

export function reportAt(
state: ParserState,
parser: ParserState,
index: number,

@@ -405,3 +405,3 @@ line: number,

): never {
throw new ParseError(index, line, column, state.source, type, ...params);
throw new ParseError(index, line, column, parser.source, type, ...params);
}

@@ -1,2 +0,2 @@

import { nextCodePoint, CharTypes, CharFlags, LexerState, advanceNewline, consumeLineFeed } from './';
import { nextCP, CharTypes, CharFlags, LexerState, advanceNewline, consumeLineFeed } from './';
import { Chars } from '../chars';

@@ -12,2 +12,4 @@ import { ParserState } from '../common';

export function skipHashBang(parser: ParserState): void {
// HashbangComment ::
// #! SingleLineCommentChars
let index = parser.index;

@@ -45,3 +47,3 @@ if (index === parser.end) return;

}
nextCodePoint(parser);
nextCP(parser);
}

@@ -60,4 +62,4 @@ return state;

while (parser.nextCP === Chars.Asterisk) {
if (nextCodePoint(parser) === Chars.Slash) {
nextCodePoint(parser);
if (nextCP(parser) === Chars.Slash) {
nextCP(parser);
return state;

@@ -77,3 +79,3 @@ }

} else {
nextCodePoint(parser);
nextCP(parser);
}

@@ -80,0 +82,0 @@ }

@@ -17,3 +17,3 @@ import { Chars } from '../chars';

*/
export function nextCodePoint(parser: ParserState): number {
export function nextCP(parser: ParserState): number {
parser.column++;

@@ -38,2 +38,6 @@ return (parser.nextCP = parser.source.charCodeAt(++parser.index));

export function storeRaw(parser: ParserState, start: number) {
parser.tokenRaw = parser.source.slice(start, parser.index);
}
/**

@@ -40,0 +44,0 @@ * Use to consume a line feed instead of `advanceNewline`.

import { ParserState, Context } from '../common';
import { Token, descKeywordTable } from '../token';
import { Chars } from '../chars';
import { nextCodePoint, consumeMultiUnitCodePoint, fromCodePoint, toHex } from './';
import { nextCP, consumeMultiUnitCodePoint, fromCodePoint, toHex } from './';
import { CharTypes, CharFlags, isIdentifierPart } from './charClassifier';

@@ -17,6 +17,6 @@ import { report, Errors } from '../errors';

const canBeKeyword = CharTypes[parser.nextCP] & CharFlags.KeywordCandidate;
while ((CharTypes[nextCodePoint(parser)] & CharFlags.IdentifierPart) !== 0) {}
while ((CharTypes[nextCP(parser)] & CharFlags.IdentifierPart) !== 0) {}
parser.tokenValue = parser.source.slice(parser.tokenIndex, parser.index);
const hasEscape = CharTypes[parser.nextCP] & CharFlags.BackSlash;
if (!hasEscape && parser.nextCP < 0x7e) {
if ((parser.nextCP & ~0x7f) === 0 && !hasEscape) {
return descKeywordTable[parser.tokenValue] || Token.Identifier;

@@ -66,3 +66,3 @@ }

} else if (isIdentifierPart(parser.nextCP) || consumeMultiUnitCodePoint(parser, parser.nextCP)) {
nextCodePoint(parser);
nextCP(parser);
} else {

@@ -103,3 +103,3 @@ break;

export function scanPrivateName(parser: ParserState): Token {
nextCodePoint(parser); // consumes '#'
nextCP(parser); // consumes '#'
if (

@@ -140,3 +140,3 @@ (CharTypes[parser.nextCP] & CharFlags.Decimal) !== 0 ||

if (parser.nextCP === Chars.LeftBrace) {
while (CharTypes[nextCodePoint(parser)] & CharFlags.Hex) {
while (CharTypes[nextCP(parser)] & CharFlags.Hex) {
codePoint = (codePoint << 4) | toHex(parser.nextCP);

@@ -154,3 +154,3 @@ // Check this early to avoid `code` wrapping to a negative on overflow (which is

}
nextCodePoint(parser); // consumes '}'
nextCP(parser); // consumes '}'
return codePoint;

@@ -157,0 +157,0 @@ }

export { scanSingleToken, nextToken } from './scan';
export { skipMultiLineComment, skipSingleLineComment, skipHashBang } from './comments';
export {
nextCodePoint,
nextCP,
consumeMultiUnitCodePoint,

@@ -9,2 +9,3 @@ isExoticECMAScriptWhitespace,

toHex,
storeRaw,
consumeLineFeed,

@@ -11,0 +12,0 @@ advanceNewline,

import { ParserState, Context, Flags } from '../common';
import { Token } from '../token';
import { nextCodePoint, toHex, CharTypes, CharFlags, isIdentifierStart } from './';
import { nextCP, toHex, CharTypes, CharFlags, isIdentifierStart, storeRaw } from './';
import { Chars } from '../chars';

@@ -21,6 +21,6 @@ import { report, Errors } from '../errors';

if (isFloat) {
while (CharTypes[nextCodePoint(parser)] & CharFlags.Decimal) {}
while (CharTypes[nextCP(parser)] & CharFlags.Decimal) {}
} else {
if (parser.nextCP === Chars.Zero) {
nextCodePoint(parser);
nextCP(parser);

@@ -31,3 +31,3 @@ // Hex

let digits = 0;
while (CharTypes[nextCodePoint(parser)] & CharFlags.Hex) {
while (CharTypes[nextCP(parser)] & CharFlags.Hex) {
value = value * 0x10 + toHex(parser.nextCP);

@@ -41,3 +41,3 @@ digits++;

let digits = 0;
while (CharTypes[nextCodePoint(parser)] & CharFlags.Octal) {
while (CharTypes[nextCP(parser)] & CharFlags.Octal) {
value = value * 8 + (parser.nextCP - Chars.Zero);

@@ -50,3 +50,3 @@ digits++;

let digits = 0;
while (CharTypes[nextCodePoint(parser)] & CharFlags.Binary) {
while (CharTypes[nextCP(parser)] & CharFlags.Binary) {
value = value * 2 + (parser.nextCP - Chars.Zero);

@@ -67,3 +67,3 @@ digits++;

value = value * 8 + (parser.nextCP - Chars.Zero);
} while (CharTypes[nextCodePoint(parser)] & CharFlags.Decimal);
} while (CharTypes[nextCP(parser)] & CharFlags.Decimal);
} else if (CharTypes[parser.nextCP] & CharFlags.ImplicitOctalDigits) {

@@ -81,3 +81,3 @@ if (context & Context.Strict) report(parser, Errors.StrictOctalEscape);

let digit = 9;
while (digit >= 0 && CharTypes[nextCodePoint(parser)] & CharFlags.Decimal) {
while (digit >= 0 && CharTypes[nextCP(parser)] & CharFlags.Decimal) {
value = 10 * value + (parser.nextCP - Chars.Zero);

@@ -95,3 +95,3 @@ --digit;

while (CharTypes[parser.nextCP] & CharFlags.Decimal) {
nextCodePoint(parser);
nextCP(parser);
}

@@ -102,5 +102,5 @@

isFloat = 1;
nextCodePoint(parser); // consumes '.'
nextCP(parser); // consumes '.'
while (CharTypes[parser.nextCP] & CharFlags.Decimal) {
nextCodePoint(parser);
nextCP(parser);
}

@@ -119,3 +119,3 @@ }

isBigInt = 1;
nextCodePoint(parser);
nextCP(parser);
// Scan any exponential notation

@@ -127,7 +127,7 @@ } else if ((parser.nextCP | 32) === Chars.LowerE) {

nextCodePoint(parser);
nextCP(parser);
// '-', '+'
if (CharTypes[parser.nextCP] & CharFlags.Exponent) {
nextCodePoint(parser);
nextCP(parser);
}

@@ -138,3 +138,3 @@

while (CharTypes[parser.nextCP] & CharFlags.Decimal) {
nextCodePoint(parser);
nextCP(parser);
exponentDigits++;

@@ -150,18 +150,22 @@ }

// not be an identifier start or a decimal digit
if (CharTypes[parser.nextCP] & CharFlags.Decimal || isIdentifierStart(parser.nextCP)) {
if ((parser.index < parser.end && CharTypes[parser.nextCP] & CharFlags.Decimal) || isIdentifierStart(parser.nextCP)) {
report(parser, Errors.IDStartAfterNumber);
}
if (context & Context.OptionsRaw) parser.tokenRaw = parser.source.slice(parser.tokenIndex, parser.index);
parser.tokenValue =
kind & (NumberKind.ImplicitOctal | NumberKind.Binary | NumberKind.Hex | NumberKind.Octal)
? value
: kind & NumberKind.DecimalWithLeadingZero
? parseFloat(parser.source.slice(parser.tokenIndex, parser.index))
: isBigInt
? parseInt(parser.source.slice(parser.tokenIndex, parser.index), 0xa)
: +parser.source.slice(parser.tokenIndex, parser.index);
if (context & Context.OptionsRaw || isBigInt) parser.tokenRaw = parser.source.slice(parser.tokenIndex, parser.index);
if (kind & (NumberKind.ImplicitOctal | NumberKind.Binary | NumberKind.Hex | NumberKind.Octal)) {
parser.tokenValue = value;
} else {
const raw = parser.source.slice(parser.tokenIndex, parser.index);
parser.tokenValue =
kind & NumberKind.DecimalWithLeadingZero ? parseFloat(raw) : isBigInt ? parseInt(raw, 0xa) : +raw;
}
return isBigInt ? Token.BigIntLiteral : Token.NumericLiteral;
if (isBigInt) {
storeRaw(parser, parser.tokenIndex);
return Token.BigIntLiteral;
}
if (context & Context.OptionsRaw) storeRaw(parser, parser.tokenIndex);
return Token.NumericLiteral;
}
import { Chars } from '../chars';
import { Context, ParserState } from '../common';
import { Token } from '../token';
import { nextCodePoint, isIdentifierPart } from './';
import { nextCP, isIdentifierPart } from './';
import { report, Errors } from '../errors';

@@ -26,3 +26,3 @@

const ch = parser.nextCP;
nextCodePoint(parser);
nextCP(parser);

@@ -75,3 +75,3 @@ if (preparseState & RegexState.Escape) {

loop: while (parser.index < parser.source.length) {
loop: while (isIdentifierPart(parser.nextCP)) {
switch (parser.nextCP) {

@@ -109,7 +109,6 @@ case Chars.LowerG:

default:
if (!isIdentifierPart(parser.nextCP)) break loop;
report(parser, Errors.UnexpectedTokenRegExpFlag);
}
nextCodePoint(parser);
nextCP(parser);
}

@@ -116,0 +115,0 @@

@@ -9,3 +9,3 @@ import { skipSingleLineComment, skipMultiLineComment, LexerState } from './';

import {
nextCodePoint,
nextCP,
consumeMultiUnitCodePoint,

@@ -190,3 +190,3 @@ isExoticECMAScriptWhitespace,

parser.tokenIndex = parser.index;
parser.columnPos = parser.column;
parser.colPos = parser.column;
parser.linePos = parser.line;

@@ -200,3 +200,2 @@

switch (token) {
// Look for an unambiguous single-char token
case Token.LeftParen:

@@ -215,8 +214,8 @@ case Token.RightParen:

case Token.Illegal:
nextCodePoint(parser);
nextCP(parser);
return token;
// Skip over non-EOL whitespace chars.
// Skip over non-EOL whitespace chars
case Token.WhiteSpace:
nextCodePoint(parser);
nextCP(parser);
break;

@@ -232,6 +231,5 @@

state = (state | LexerState.LastIsCR | LexerState.NewLine) ^ LexerState.LastIsCR;
parser.flags |= Flags.NewLine;
break;
// Look for an identifier.
// Look for an identifier
case Token.Identifier:

@@ -246,7 +244,8 @@ return scanIdentifier(parser, context);

case Token.StringLiteral:
return scanString(parser, context) as Token;
return scanString(parser, context);
case Token.Template:
return scanTemplate(parser, context) as Token;
return scanTemplate(parser, context);
// Escaped identifiers
case Token.EscapedIdentifier:

@@ -261,9 +260,9 @@ return scanUnicodeIdentifier(parser, context);

case Token.Negate:
if (nextCodePoint(parser) !== Chars.EqualSign) {
if (nextCP(parser) !== Chars.EqualSign) {
return Token.Negate;
}
if (nextCodePoint(parser) !== Chars.EqualSign) {
if (nextCP(parser) !== Chars.EqualSign) {
return Token.LooseNotEqual;
}
nextCodePoint(parser);
nextCP(parser);
return Token.StrictNotEqual;

@@ -273,9 +272,30 @@

case Token.Modulo:
if (nextCodePoint(parser) !== Chars.EqualSign) return Token.Modulo;
nextCodePoint(parser);
if (nextCP(parser) !== Chars.EqualSign) return Token.Modulo;
nextCP(parser);
return Token.ModuloAssign;
// `=`, `==`, `===`, `=>`
case Token.Assign: {
nextCP(parser);
if (parser.index >= parser.end) return Token.Assign;
const next = parser.nextCP;
if (next === Chars.EqualSign) {
if (nextCP(parser) === Chars.EqualSign) {
nextCP(parser);
return Token.StrictEqual;
} else {
return Token.LooseEqual;
}
} else if (next === Chars.GreaterThan) {
nextCP(parser);
return Token.Arrow;
}
return Token.Assign;
}
// `*`, `**`, `*=`, `**=`
case Token.Multiply: {
nextCodePoint(parser);
nextCP(parser);
if (parser.index >= parser.end) return Token.Multiply;

@@ -285,3 +305,3 @@ const next = parser.nextCP;

if (next === Chars.EqualSign) {
nextCodePoint(parser);
nextCP(parser);
return Token.MultiplyAssign;

@@ -291,5 +311,5 @@ }

if (next !== Chars.Asterisk) return Token.Multiply;
nextCodePoint(parser);
nextCP(parser);
if (parser.nextCP !== Chars.EqualSign) return Token.Exponentiate;
nextCodePoint(parser);
nextCP(parser);
return Token.ExponentiateAssign;

@@ -300,4 +320,4 @@ }

case Token.BitwiseXor:
if (nextCodePoint(parser) !== Chars.EqualSign) return Token.BitwiseXor;
nextCodePoint(parser);
if (nextCP(parser) !== Chars.EqualSign) return Token.BitwiseXor;
nextCP(parser);
return Token.BitwiseXorAssign;

@@ -307,7 +327,7 @@

case Token.Add: {
nextCodePoint(parser);
nextCP(parser);
if (parser.index >= parser.end) return Token.Add;
if (parser.nextCP === Chars.Plus) {
nextCodePoint(parser);
nextCP(parser);
return Token.Increment;

@@ -317,3 +337,3 @@ }

if (parser.nextCP === Chars.EqualSign) {
nextCodePoint(parser);
nextCP(parser);
return Token.AddAssign;

@@ -327,3 +347,3 @@ }

case Token.Subtract: {
nextCodePoint(parser);
nextCP(parser);
if (parser.index >= parser.end) return Token.Subtract;

@@ -333,3 +353,3 @@ const next = parser.nextCP;

if (next === Chars.Hyphen) {
nextCodePoint(parser);
nextCP(parser);
if (

@@ -349,3 +369,3 @@ (context & Context.Module) === 0 &&

if (next === Chars.EqualSign) {
nextCodePoint(parser);
nextCP(parser);
return Token.SubtractAssign;

@@ -358,11 +378,11 @@ }

case Token.Divide: {
nextCodePoint(parser);
nextCP(parser);
if (parser.index < parser.end) {
const ch = parser.nextCP;
if (ch === Chars.Slash) {
nextCodePoint(parser);
nextCP(parser);
state = skipSingleLineComment(parser, state);
continue;
} else if (ch === Chars.Asterisk) {
nextCodePoint(parser);
nextCP(parser);
state = skipMultiLineComment(parser, state) as LexerState;

@@ -373,3 +393,3 @@ continue;

} else if (ch === Chars.EqualSign) {
nextCodePoint(parser);
nextCP(parser);
return Token.DivideAssign;

@@ -384,3 +404,3 @@ }

case Token.LessThan:
nextCodePoint(parser);
nextCP(parser);
if (parser.index >= parser.end) return Token.LessThan;

@@ -390,5 +410,4 @@

case Chars.LessThan:
nextCodePoint(parser);
if ((parser.nextCP as number) === Chars.EqualSign) {
nextCodePoint(parser);
if (nextCP(parser) === Chars.EqualSign) {
nextCP(parser);
return Token.ShiftLeftAssign;

@@ -400,7 +419,6 @@ } else {

case Chars.EqualSign:
nextCodePoint(parser);
nextCP(parser);
return Token.LessThanOrEqual;
case Chars.Exclamation:
// Treat HTML begin-comment as comment-till-end-of-line.
if (

@@ -420,27 +438,5 @@ (context & Context.Module) === 0 &&

// `=`, `==`, `===`, `=>`
case Token.Assign: {
nextCodePoint(parser);
if (parser.index >= parser.end) return Token.Assign;
const next = parser.nextCP;
if (next === Chars.EqualSign) {
nextCodePoint(parser);
if (parser.nextCP === Chars.EqualSign) {
nextCodePoint(parser);
return Token.StrictEqual;
} else {
return Token.LooseEqual;
}
} else if (next === Chars.GreaterThan) {
nextCodePoint(parser);
return Token.Arrow;
}
return Token.Assign;
}
// `|`, `||`, `|=`
case Token.BitwiseOr: {
nextCodePoint(parser);
nextCP(parser);
if (parser.index >= parser.end) return Token.BitwiseOr;

@@ -450,6 +446,6 @@ const next = parser.nextCP;

if (next === Chars.VerticalBar) {
nextCodePoint(parser);
nextCP(parser);
return Token.LogicalOr;
} else if (next === Chars.EqualSign) {
nextCodePoint(parser);
nextCP(parser);
return Token.BitwiseOrAssign;

@@ -463,3 +459,3 @@ }

case Token.GreaterThan: {
nextCodePoint(parser);
nextCP(parser);
if (parser.index >= parser.end) return Token.GreaterThan;

@@ -469,3 +465,3 @@ const next = parser.nextCP;

if (next === Chars.EqualSign) {
nextCodePoint(parser);
nextCP(parser);
return Token.GreaterThanOrEqual;

@@ -475,3 +471,3 @@ }

if (next !== Chars.GreaterThan) return Token.GreaterThan;
nextCodePoint(parser);
nextCP(parser);

@@ -482,5 +478,4 @@ if (parser.index < parser.end) {

if (next === Chars.GreaterThan) {
nextCodePoint(parser);
if (parser.nextCP === Chars.EqualSign) {
nextCodePoint(parser);
if (nextCP(parser) === Chars.EqualSign) {
nextCP(parser);
return Token.LogicalShiftRightAssign;

@@ -491,3 +486,3 @@ } else {

} else if (next === Chars.EqualSign) {
nextCodePoint(parser);
nextCP(parser);
return Token.ShiftRightAssign;

@@ -502,3 +497,3 @@ }

case Token.BitwiseAnd: {
nextCodePoint(parser);
nextCP(parser);
if (parser.index >= parser.end) return Token.BitwiseAnd;

@@ -508,3 +503,3 @@ const next = parser.nextCP;

if (next === Chars.Ampersand) {
nextCodePoint(parser);
nextCP(parser);
return Token.LogicalAnd;

@@ -514,3 +509,3 @@ }

if (next === Chars.EqualSign) {
nextCodePoint(parser);
nextCP(parser);
return Token.BitwiseAndAssign;

@@ -523,7 +518,7 @@ }

case Token.Period:
nextCodePoint(parser);
nextCP(parser);
if ((CharTypes[parser.nextCP] & CharFlags.Decimal) !== 0) return scanNumber(parser, context, /* isFloat */ 1);
if (parser.nextCP === Chars.Period) {
if (nextCodePoint(parser) === Chars.Period) {
nextCodePoint(parser);
if (nextCP(parser) === Chars.Period) {
nextCP(parser);
return Token.Ellipsis;

@@ -538,2 +533,4 @@ }

} else {
// Non-ASCII code points can only be identifiers or whitespace.
if ((first ^ Chars.LineSeparator) <= 1) {

@@ -551,3 +548,3 @@ state = (state | LexerState.LastIsCR | LexerState.NewLine) ^ LexerState.LastIsCR;

if (isExoticECMAScriptWhitespace(first)) {
nextCodePoint(parser);
nextCP(parser);
continue;

@@ -554,0 +551,0 @@ }

@@ -5,3 +5,3 @@ import { ParserState, Context, Flags } from '../common';

import { report, Errors } from '../errors';
import { toHex, nextCodePoint, fromCodePoint, CharTypes, CharFlags } from './';
import { toHex, nextCP, fromCodePoint, CharTypes, CharFlags, storeRaw } from './';

@@ -24,3 +24,3 @@ // Intentionally negative

let ret: string | void = '';
let ch = nextCodePoint(parser);
let ch = nextCP(parser);
let marker = parser.index; // Consumes the quote

@@ -30,4 +30,4 @@ while ((CharTypes[ch] & CharFlags.LineTerminator) === 0) {

ret += parser.source.slice(marker, parser.index);
nextCodePoint(parser); // skip closing quote
if (context & Context.OptionsRaw) parser.tokenRaw = parser.source.slice(start, parser.index);
nextCP(parser); // skip closing quote
if (context & Context.OptionsRaw) storeRaw(parser, start);
parser.tokenValue = ret;

@@ -39,3 +39,3 @@ return Token.StringLiteral;

ret += parser.source.slice(marker, parser.index);
const ch = nextCodePoint(parser);
const ch = nextCP(parser);

@@ -54,3 +54,3 @@ if (ch > 0x7e) {

if (parser.index >= parser.end) report(parser, Errors.UnterminatedString);
ch = nextCodePoint(parser);
ch = nextCP(parser);
}

@@ -178,6 +178,6 @@

case Chars.LowerX: {
const ch1 = nextCodePoint(parser);
const ch1 = nextCP(parser);
if ((CharTypes[ch1] & CharFlags.Hex) === 0) return Escape.InvalidHex;
const hi = toHex(ch1);
const ch2 = nextCodePoint(parser);
const ch2 = nextCP(parser);
if ((CharTypes[ch2] & CharFlags.Hex) === 0) return Escape.InvalidHex;

@@ -193,7 +193,7 @@ const lo = toHex(ch2);

case Chars.LowerU: {
const ch = nextCodePoint(parser);
const ch = nextCP(parser);
if (parser.nextCP === Chars.LeftBrace) {
let code = 0;
while ((CharTypes[nextCodePoint(parser)] & CharFlags.Hex) !== 0) {
while ((CharTypes[nextCP(parser)] & CharFlags.Hex) !== 0) {
code = (code << 4) | toHex(parser.nextCP);

@@ -200,0 +200,0 @@ if (code > Chars.NonBMPMax) return Escape.OutOfRange;

import { ParserState, Context } from '../common';
import { Token } from '../token';
import { Chars } from '../chars';
import { nextCodePoint, fromCodePoint } from './common';
import { nextCP, fromCodePoint } from './common';
import { parseEscape, Escape, handleStringError } from './string';

@@ -16,11 +16,11 @@ import { report, Errors } from '../errors';

let ch = nextCodePoint(parser);
let ch = nextCP(parser);
while (ch !== Chars.Backtick) {
if (ch === Chars.Dollar && parser.source.charCodeAt(parser.index + 1) === Chars.LeftBrace) {
nextCodePoint(parser);
nextCP(parser);
tail = false;
break;
} else if ((ch & 8) === 8 && ch === Chars.Backslash) {
ch = nextCodePoint(parser);
ch = nextCP(parser);
if (ch > 0x7e) {

@@ -58,6 +58,6 @@ ret += fromCodePoint(ch);

if (parser.index >= parser.end) report(parser, Errors.UnterminatedTemplate);
ch = nextCodePoint(parser);
ch = nextCP(parser);
}
nextCodePoint(parser); // Consume the quote or opening brace
nextCP(parser); // Consume the quote or opening brace
parser.tokenValue = ret;

@@ -99,3 +99,3 @@ if (tail) {

if (parser.index >= parser.end) report(parser, Errors.UnterminatedTemplate);
ch = nextCodePoint(parser);
ch = nextCP(parser);
}

@@ -102,0 +102,0 @@

@@ -26,2 +26,2 @@ import { Context } from './common';

export const version = '0.5.2';
export const version = '0.6.1';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc