Socket
Socket
Sign inDemoInstall

acorn-es7-plugin

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn-es7-plugin - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

test/babel.js

58

acorn-es7-plugin.js

@@ -10,3 +10,3 @@ var NotAsync = {} ;

function state(p) {
if (('state' in p) && p.state.constructor && p.state.constructor.name==='State')
if (('state' in p) && p.state.constructor && p.state.constructor.name==='State')
return p.state ; // Probably babylon

@@ -19,7 +19,7 @@ return p ; // Probably acorn

function subParse(parser, pos, extensions) {
// NB: The Babylon constructor does NOT expect 'pos' as an argument, and so
// NB: The Babylon constructor does NOT expect 'pos' as an argument, and so
// the input needs truncation at the start position, however at present
// this doesn't work nicely as all the node location/start/end values
// are therefore offset. Consequently, this plug-in is NOT currently working
// with the (undocumented) Babylon plug-in interface.
// are therefore offset. Consequently, this plug-in is NOT currently working
// with the (undocumented) Babylon plug-in interface.
var p = new parser.constructor(parser.options, parser.input, pos);

@@ -57,2 +57,4 @@ if (extensions)

var st = state(this) ;
var start = st.start;
var startLoc = st.startLoc;
if (st.type.label==='name') {

@@ -66,2 +68,4 @@ if (asyncFunction.test(st.input.slice(st.start))) {

r.async = true ;
r.start = start;
r.loc && (r.loc.start = startLoc);
return r ;

@@ -72,3 +76,3 @@ } finally {

} else if ((typeof options==="object" && options.asyncExits) && asyncExit.test(st.input.slice(st.start))) {
// NON-STANDARD EXTENSION iff. options.asyncExits is set, the
// NON-STANDARD EXTENSION iff. options.asyncExits is set, the
// extensions 'async return <expr>?' and 'async throw <expr>?'

@@ -80,2 +84,4 @@ // are enabled. In each case they are the standard ESTree nodes

r.async = true ;
r.start = start;
r.loc && (r.loc.start = startLoc);
return r ;

@@ -85,3 +91,3 @@ }

return base.apply(this,arguments);
}
}
}) ;

@@ -93,2 +99,3 @@

var start = st.start ;
var startLoc = st.startLoc;
var rhs,r = base.apply(this,arguments);

@@ -103,3 +110,3 @@ if (r.type==='Identifier') {

var inBody = false ;
var parseHooks = {

@@ -123,5 +130,4 @@ parseFunctionBody:function(){

} ;
start = st.start ;
rhs = subParse(this,start,parseHooks).parseExpression() ;
rhs = subParse(this,st.start,parseHooks).parseExpression() ;
if (rhs.type==='SequenceExpression')

@@ -131,2 +137,4 @@ rhs = rhs.expressions[0] ;

rhs.async = true ;
rhs.start = start;
rhs.loc && (rhs.loc.start = startLoc);
st.pos = rhs.end;

@@ -146,3 +154,3 @@ this.next();

else if (r.name==='await') {
var n = this.startNode() ;
var n = this.startNodeAt(r.start, r.loc && r.loc.start);
if (st.inAsyncFunction) {

@@ -152,6 +160,6 @@ rhs = this.parseExprSubscripts() ;

n.argument = rhs ;
n = this.finishNodeAt(n,'AwaitExpression', rhs.end, rhs.loc) ;
n = this.finishNodeAt(n,'AwaitExpression', rhs.end, rhs.loc && rhs.loc.end) ;
es7check(n) ;
return n ;
} else
} else
// NON-STANDARD EXTENSION iff. options.awaitAnywhere is true,

@@ -172,3 +180,3 @@ // an 'AwaitExpression' is allowed anywhere the token 'await'

n.argument = rhs ;
n = this.finishNodeAt(n,'AwaitExpression', rhs.end, rhs.loc) ;
n = this.finishNodeAt(n,'AwaitExpression', rhs.end, rhs.loc && rhs.loc.end) ;
st.pos = rhs.end;

@@ -186,2 +194,22 @@ this.next();

parser.extend('finishNodeAt',function(base){
return function(node,type,pos,loc) {
if (node.__asyncValue) {
delete node.__asyncValue ;
node.value.async = true ;
}
return base.apply(this,arguments) ;
}
}) ;
parser.extend('finishNode',function(base){
return function(node,type) {
if (node.__asyncValue) {
delete node.__asyncValue ;
node.value.async = true ;
}
return base.apply(this,arguments) ;
}
}) ;
parser.extend("parsePropertyName",function(base){

@@ -195,3 +223,2 @@ return function (prop) {

es7check(prop) ;
prop.async = true ;
key = base.apply(this,arguments) ;

@@ -204,2 +231,3 @@ if (key.type==='Identifier') {

}
prop.__asyncValue = true ;
}

@@ -206,0 +234,0 @@ }

{
"name": "acorn-es7-plugin",
"version": "1.0.8",
"version": "1.0.9",
"description": "A plugin for the Acorn parser that understands the ES7 keywords async and await",
"main": "acorn-es7-plugin.js",
"scripts": {
"test": "echo \"### No tests here - 'npm install nodent' and test there\""
"test": "cd test ; npm i ; npm test"
},

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

Sorry, the diff of this file is not supported yet

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