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

@lezer/javascript

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lezer/javascript - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

10

CHANGELOG.md

@@ -0,1 +1,11 @@

## 1.4.1 (2023-01-09)
### Bug fixes
Fix a bug where something like `yield [1]` (or `await`) was parsed as a member expression.
Add support for `yield*` syntax.
Escapes in strings are now parsed as their own tokens (and styled with the `escape` tag).
## 1.4.0 (2022-12-19)

@@ -2,0 +12,0 @@

6

package.json
{
"name": "@lezer/javascript",
"version": "1.4.0",
"version": "1.4.1",
"description": "lezer-based JavaScript grammar",

@@ -22,4 +22,4 @@ "main": "dist/index.cjs",

"dependencies": {
"@lezer/lr": "^1.0.0",
"@lezer/highlight": "^1.0.0"
"@lezer/lr": "^1.3.0",
"@lezer/highlight": "^1.1.3"
},

@@ -26,0 +26,0 @@ "repository": {

@@ -32,2 +32,3 @@ import {styleTags, tags as t} from "@lezer/highlight"

String: t.string,
Escape: t.escape,
ArithOp: t.arithmeticOperator,

@@ -34,0 +35,0 @@ LogicOp: t.logicOperator,

// This file was generated by lezer-generator. You probably shouldn't edit it.
export const
noSemi = 294,
noSemi = 301,
incdec = 1,
incdecPrefix = 2,
templateContent = 295,
InterpolationStart = 3,
templateEnd = 296,
insertSemi = 297,
spaces = 299,
newline = 300,
LineComment = 4,
BlockComment = 5,
Script = 6,
ExportDeclaration = 7,
Star = 9,
VariableName = 11,
String = 12,
insertSemi = 302,
spaces = 304,
newline = 305,
LineComment = 3,
BlockComment = 4,
Script = 5,
ExportDeclaration = 6,
Star = 8,
VariableName = 10,
String = 11,
Escape = 12,
FunctionDeclaration = 16,

@@ -27,79 +25,83 @@ VariableDefinition = 19,

templateType = 32,
typeofMemberExpression = 39,
PropertyName = 42,
TemplateString = 44,
templateExpr = 45,
RegExp = 47,
ArrayExpression = 49,
Property = 55,
PropertyDefinition = 59,
Block = 60,
TypeArgList = 64,
LessThan = 65,
ArgList = 69,
UnaryExpression = 70,
ParenthesizedExpression = 76,
ClassExpression = 77,
ClassBody = 79,
MethodDeclaration = 80,
Decorator = 81,
PrivatePropertyName = 84,
PrivatePropertyDefinition = 90,
PropertyDeclaration = 91,
Optional = 94,
TypeAnnotation = 95,
StaticBlock = 97,
FunctionExpression = 98,
ArrowFunction = 99,
ParamList = 101,
ArrayPattern = 102,
ObjectPattern = 103,
PatternProperty = 104,
MemberExpression = 108,
BinaryExpression = 109,
divide = 111,
questionOp = 127,
AssignmentExpression = 129,
JSXElement = 137,
JSXSelfCloseEndTag = 138,
JSXStartTag = 139,
JSXSelfClosingTag = 140,
JSXIdentifier = 141,
JSXLowerIdentifier = 143,
JSXNamespacedName = 144,
JSXMemberExpression = 145,
JSXAttributeValue = 148,
JSXEndTag = 150,
JSXOpenTag = 151,
JSXFragmentTag = 152,
JSXText = 153,
JSXEscape = 154,
JSXStartCloseTag = 155,
JSXCloseTag = 156,
SequenceExpression = 160,
TypeName = 168,
ParamTypeList = 171,
IndexedType = 173,
Label = 175,
ObjectType = 178,
MethodType = 179,
PropertyType = 180,
IndexSignature = 181,
TypePredicate = 184,
ClassDeclaration = 194,
VariableDeclaration = 198,
TypeAliasDeclaration = 201,
InterfaceDeclaration = 202,
EnumDeclaration = 204,
NamespaceDeclaration = 207,
AmbientDeclaration = 210,
ExportGroup = 218,
ImportDeclaration = 221,
ImportGroup = 222,
ForSpec = 225,
ForInSpec = 226,
ForOfSpec = 227,
SingleExpression = 262,
SingleClassItem = 263,
InterpolationStart = 33,
typeofMemberExpression = 40,
PropertyName = 43,
TemplateString = 45,
templateEscape = 46,
templateExpr = 47,
RegExp = 49,
ArrayExpression = 51,
Property = 57,
PropertyDefinition = 61,
Block = 62,
TypeArgList = 66,
LessThan = 67,
ArgList = 71,
UnaryExpression = 72,
YieldExpression = 76,
AwaitExpression = 78,
ParenthesizedExpression = 80,
ClassExpression = 81,
ClassBody = 83,
MethodDeclaration = 84,
Decorator = 85,
PrivatePropertyName = 88,
PrivatePropertyDefinition = 94,
PropertyDeclaration = 95,
Optional = 98,
TypeAnnotation = 99,
StaticBlock = 101,
FunctionExpression = 102,
ArrowFunction = 103,
ParamList = 105,
ArrayPattern = 106,
ObjectPattern = 107,
PatternProperty = 108,
MemberExpression = 112,
BinaryExpression = 113,
divide = 115,
questionOp = 131,
AssignmentExpression = 133,
JSXElement = 141,
JSXSelfCloseEndTag = 142,
JSXStartTag = 143,
JSXSelfClosingTag = 144,
JSXIdentifier = 145,
JSXLowerIdentifier = 147,
JSXNamespacedName = 148,
JSXMemberExpression = 149,
JSXAttributeValue = 152,
JSXEndTag = 154,
JSXOpenTag = 155,
JSXFragmentTag = 156,
JSXText = 157,
JSXEscape = 158,
JSXStartCloseTag = 159,
JSXCloseTag = 160,
SequenceExpression = 164,
TypeName = 172,
ParamTypeList = 175,
IndexedType = 177,
Label = 179,
ObjectType = 182,
MethodType = 183,
PropertyType = 184,
IndexSignature = 185,
TypePredicate = 188,
ClassDeclaration = 198,
VariableDeclaration = 202,
TypeAliasDeclaration = 205,
InterfaceDeclaration = 206,
EnumDeclaration = 208,
NamespaceDeclaration = 211,
AmbientDeclaration = 214,
ExportGroup = 222,
ImportDeclaration = 225,
ImportGroup = 226,
ForSpec = 229,
ForInSpec = 230,
ForOfSpec = 231,
SingleExpression = 266,
SingleClassItem = 267,
Dialect_jsx = 0,
Dialect_ts = 1

@@ -5,3 +5,3 @@ /* Hand-written tokenizers for JavaScript tokens that can't be

import {ExternalTokenizer, ContextTracker} from "@lezer/lr"
import {insertSemi, noSemi, incdec, incdecPrefix, templateContent, InterpolationStart, templateEnd,
import {insertSemi, noSemi, incdec, incdecPrefix,
spaces, newline, BlockComment, LineComment,

@@ -13,4 +13,4 @@ Dialect_ts} from "./parser.terms.js"

const braceR = 125, braceL = 123, semicolon = 59, slash = 47, star = 42,
plus = 43, minus = 45, dollar = 36, backtick = 96, backslash = 92,
const braceR = 125, semicolon = 59, slash = 47, star = 42,
plus = 43, minus = 45, backslash = 92,
angleL = 60, angleR = 62, period = 46

@@ -51,28 +51,1 @@

}, {contextual: true})
export const template = new ExternalTokenizer(input => {
for (let afterDollar = false, i = 0;; i++) {
let {next} = input
if (next < 0) {
if (i) input.acceptToken(templateContent)
break
} else if (next == backtick) {
if (i) input.acceptToken(templateContent)
else input.acceptToken(templateEnd, 1)
break
} else if (next == braceL && afterDollar) {
if (i == 1) input.acceptToken(InterpolationStart, 1)
else input.acceptToken(templateContent, -1)
break
} else if (next == 10 /* "\n" */ && i) {
// Break up template strings on lines, to avoid huge tokens
input.advance()
input.acceptToken(templateContent)
break
} else if (next == backslash) {
input.advance()
}
afterDollar = next == dollar
input.advance()
}
})

@@ -21,7 +21,7 @@ # Minimal

Script(ExpressionStatement(String),
ExpressionStatement(String),
ExpressionStatement(String),
ExpressionStatement(String),
ExpressionStatement(String))
Script(ExpressionStatement(String(Escape,Escape)),
ExpressionStatement(String(Escape,Escape)),
ExpressionStatement(String(Escape)),
ExpressionStatement(String(Escape)),
ExpressionStatement(String(Escape)))

@@ -297,2 +297,4 @@ # Numbers

yield db.users.where('[endpoint+email]');
yield* a;
yield [22];

@@ -302,4 +304,6 @@ ==>

Script(
ExpressionStatement(UnaryExpression(yield,
CallExpression(MemberExpression(MemberExpression(VariableName,PropertyName),PropertyName),ArgList(String)))))
ExpressionStatement(YieldExpression(yield,
CallExpression(MemberExpression(MemberExpression(VariableName,PropertyName),PropertyName),ArgList(String)))),
ExpressionStatement(YieldExpression(yield,Star,VariableName)),
ExpressionStatement(YieldExpression(yield,ArrayExpression(Number))))

@@ -322,3 +326,3 @@ # Template strings

`\\`;
`\\\``;

@@ -340,3 +344,3 @@ `one${`two${`three`}`}`;

ExpressionStatement(TemplateString(Interpolation(InterpolationStart,VariableName,InterpolationEnd))),
ExpressionStatement(TemplateString),
ExpressionStatement(TemplateString(Escape,Escape)),
ExpressionStatement(TemplateString(Interpolation(InterpolationStart,TemplateString(

@@ -413,3 +417,3 @@ Interpolation(InterpolationStart,TemplateString,InterpolationEnd)),InterpolationEnd))),

Block(ExpressionStatement(AssignmentExpression(VariableName,Equals,VariableName)))),
Property(Star,PropertyDefinition,ParamList,Block(ExpressionStatement(UnaryExpression(yield,VariableName)))),
Property(Star,PropertyDefinition,ParamList,Block(ExpressionStatement(YieldExpression(yield,VariableName)))),
Property(PropertyDefinition,ParamList,Block(ReturnStatement(return,Number)))))))

@@ -454,3 +458,3 @@

ExpressionStatement(VariableName),
ExpressionStatement(UnaryExpression(yield,VariableName)))))))
ExpressionStatement(YieldExpression(yield,VariableName)))))))

@@ -530,4 +534,4 @@ # Member expressions

Script(
ExpressionStatement(UnaryExpression(await,CallExpression(VariableName,ArgList))),
ExpressionStatement(UnaryExpression(await,VariableName)))
ExpressionStatement(AwaitExpression(await,CallExpression(VariableName,ArgList))),
ExpressionStatement(AwaitExpression(await,VariableName)))

@@ -534,0 +538,0 @@ # Numeric operators

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 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