Skip to content
This repository was archived by the owner on Jun 12, 2020. It is now read-only.

Acorn 4.x #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@ module.exports = function(acorn) {

// this is the same parseObj that acorn has with...
function parseObj(isPattern, refDestructuringErrors) {
let node = this.startNode(), first = true, propHash = {}
var node = this.startNode(), first = true, propHash = {}
node.properties = []
this.next()
while (!this.eat(tt.braceR)) {
if (!first) {
this.expect(tt.comma)
if (this.afterTrailingComma(tt.braceR)) break
} else first = false

let prop = this.startNode(), isGenerator, startPos, startLoc
var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc
if (this.options.ecmaVersion >= 6) {

// ...the spread logic borrowed from babylon :)
if (this.type === tt.ellipsis) {
prop = this.parseSpread()
prop.type = isPattern ? "RestProperty" : "SpreadProperty"
node.properties.push(prop)
continue
}

prop.method = false
prop.shorthand = false
if (isPattern || refDestructuringErrors) {
Expand All @@ -35,7 +36,15 @@ module.exports = function(acorn) {
isGenerator = this.eat(tt.star)
}
this.parsePropertyName(prop)
this.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refDestructuringErrors)
if (!isPattern && this.options.ecmaVersion >= 8 && !isGenerator && !prop.computed &&
prop.key.type === "Identifier" && prop.key.name === "async" && this.type !== tt.parenL &&
this.type !== tt.colon && !this.canInsertSemicolon()) {
isAsync = true
this.parsePropertyName(prop, refDestructuringErrors)
} else {
isAsync = false
}
this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors)
this.checkPropClash(prop, propHash)
node.properties.push(this.finishNode(prop, "Property"))
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"test": "node test/run.js"
},
"dependencies": {
"acorn": "^3.1.0"
"acorn": "^4.0.3"
},
"devDependencies": {
"chai": "^3.0.0",
"mocha": "^2.2.5"
},
"version": "1.0.0"
"version": "2.0.0"
}