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

acorn

Package Overview
Dependencies
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

package.json

@@ -6,3 +6,3 @@ {

"main": "dist/acorn.js",
"version": "2.0.0",
"version": "2.0.1",
"engines": {

@@ -9,0 +9,0 @@ "node": ">=0.4.0"

@@ -516,3 +516,3 @@ // A recursive descent parser operates by defining functions for all

this.expect(tt.bracketR)
return
return prop.key
} else {

@@ -522,3 +522,3 @@ prop.computed = false

}
prop.key = (this.type === tt.num || this.type === tt.string) ? this.parseExprAtom() : this.parseIdent(true)
return prop.key = (this.type === tt.num || this.type === tt.string) ? this.parseExprAtom() : this.parseIdent(true)
}

@@ -525,0 +525,0 @@

@@ -40,3 +40,3 @@ // Acorn is a tiny, fast JavaScript parser written in JavaScript.

export const version = "2.0.0"
export const version = "2.0.1"

@@ -43,0 +43,0 @@ // The main exported interface (under `self.acorn` when in the

@@ -259,3 +259,3 @@ import {LooseParser} from "./state"

if (this.options.ecmaVersion >= 6) {
method['static'] = false
method.static = false
isGenerator = this.eat(tt.star)

@@ -267,7 +267,7 @@ }

(this.tok.type != tt.parenL && this.tok.type != tt.braceL)) {
method['static'] = true
method.static = true
isGenerator = this.eat(tt.star)
this.parsePropertyName(method)
} else {
method['static'] = false
method.static = false
}

@@ -281,3 +281,3 @@ if (this.options.ecmaVersion >= 5 && method.key.type === "Identifier" &&

} else {
if (!method.computed && !method['static'] && !isGenerator && (
if (!method.computed && !method.static && !isGenerator && (
method.key.type === "Identifier" && method.key.name === "constructor" ||

@@ -284,0 +284,0 @@ method.key.type === "Literal" && method.key.value === "constructor")) {

import {reservedWords, keywords} from "./identifier"
import {types as tt, lineBreak} from "./tokentype"
import {types as tt} from "./tokentype"
import {lineBreak} from "./whitespace"
export function Parser(options, input, startPos) {
this.options = options
this.loadPlugins(this.options.plugins)
this.sourceFile = this.options.sourceFile || null

@@ -12,2 +12,5 @@ this.isKeyword = keywords[this.options.ecmaVersion >= 6 ? 6 : 5]

// Load plugins
this.loadPlugins(this.options.plugins)
// Set up token state

@@ -14,0 +17,0 @@

@@ -420,2 +420,3 @@ import {types as tt} from "./tokentype"

let classBody = this.startNode()
let hadConstructor = false
classBody.body = []

@@ -427,23 +428,26 @@ this.expect(tt.braceL)

let isGenerator = this.eat(tt.star)
let isMaybeStatic = this.type === tt.name && this.value === "static"
this.parsePropertyName(method)
if (this.type !== tt.parenL && !method.computed && method.key.type === "Identifier" &&
method.key.name === "static") {
method.static = isMaybeStatic && this.type !== tt.parenL
if (method.static) {
if (isGenerator) this.unexpected()
method['static'] = true
isGenerator = this.eat(tt.star)
this.parsePropertyName(method)
} else {
method['static'] = false
}
method.kind = "method"
if (!method.computed && !isGenerator) {
if (method.key.type === "Identifier") {
if (this.type !== tt.parenL && (method.key.name === "get" || method.key.name === "set")) {
method.kind = method.key.name
this.parsePropertyName(method)
} else if (!method['static'] && method.key.name === "constructor") {
method.kind = "constructor"
}
} else if (!method['static'] && method.key.type === "Literal" && method.key.value === "constructor") {
if (!method.computed) {
let {key} = method
let isGetSet = false
if (!isGenerator && key.type === "Identifier" && this.type !== tt.parenL && (key.name === "get" || key.name === "set")) {
isGetSet = true
method.kind = key.name
key = this.parsePropertyName(method)
}
if (!method.static && (key.type === "Identifier" && key.name === "constructor" ||
key.type === "Literal" && key.value === "constructor")) {
if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class")
if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier")
if (isGenerator) this.raise(key.start, "Constructor can't be a generator")
method.kind = "constructor"
hadConstructor = true
}

@@ -450,0 +454,0 @@ }

@@ -28,2 +28,5 @@ import {isIdentifierStart, isIdentifierChar} from "./identifier"

// Are we running under Rhino?
const isRhino = typeof Packages !== "undefined"
// Move to the next token

@@ -418,16 +421,18 @@

// Detect invalid regular expressions.
try {
new RegExp(tmp)
} catch (e) {
if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message)
this.raise(e)
let value = null
// Rhino's regular expression parser is flaky and throws uncatchable exceptions,
// so don't do detection if we are running under Rhino
if (!isRhino) {
try {
new RegExp(tmp)
} catch (e) {
if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message)
this.raise(e)
}
// Get a regular expression object for this pattern-flag pair, or `null` in
// case the current environment doesn't support the flags it uses.
try {
value = new RegExp(content, mods)
} catch (err) {}
}
// Get a regular expression object for this pattern-flag pair, or `null` in
// case the current environment doesn't support the flags it uses.
let value
try {
value = new RegExp(content, mods)
} catch (err) {
value = null
}
return this.finishToken(tt.regexp, {pattern: content, flags: mods, value: value})

@@ -434,0 +439,0 @@ }

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

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