Comparing version 5.4.0 to 5.4.1
@@ -0,1 +1,7 @@ | ||
## 5.4.1 (2018-02-02) | ||
### Bug fixes | ||
5.4.0 somehow accidentally included an old version of walk.js. | ||
## 5.4.0 (2018-02-01) | ||
@@ -2,0 +8,0 @@ |
@@ -65,2 +65,26 @@ // AST walker module for Mozilla Parser API compatible trees | ||
// A full walk triggers the callback on each node | ||
function full(node, callback, base, state, override) { | ||
if (!base) { base = exports.base | ||
; }(function c(node, st, override) { | ||
var type = override || node.type; | ||
base[type](node, st, c); | ||
if (!override) { callback(node, st, type); } | ||
})(node, state, override); | ||
} | ||
// An fullAncestor walk is like an ancestor walk, but triggers | ||
// the callback on each node | ||
function fullAncestor(node, callback, base, state) { | ||
if (!base) { base = exports.base; } | ||
var ancestors = [];(function c(node, st, override) { | ||
var type = override || node.type; | ||
var isNew = node != ancestors[ancestors.length - 1]; | ||
if (isNew) { ancestors.push(node); } | ||
base[type](node, st, c); | ||
if (!override) { callback(node, st || ancestors, ancestors, type); } | ||
if (isNew) { ancestors.pop(); } | ||
})(node, state); | ||
} | ||
// Find a node with a given start, end, and type (all are optional, | ||
@@ -162,4 +186,8 @@ // null can be used as wildcard). Returns a {node, state} object, or | ||
base.Program = base.BlockStatement = function (node, st, c) { | ||
for (var i = 0; i < node.body.length; ++i) | ||
{ c(node.body[i], st, "Statement"); } | ||
for (var i = 0, list = node.body; i < list.length; i += 1) | ||
{ | ||
var stmt = list[i]; | ||
c(stmt, st, "Statement"); | ||
} | ||
}; | ||
@@ -183,9 +211,23 @@ base.Statement = skipThrough; | ||
c(node.discriminant, st, "Expression"); | ||
for (var i = 0; i < node.cases.length; ++i) { | ||
var cs = node.cases[i]; | ||
for (var i = 0, list = node.cases; i < list.length; i += 1) { | ||
var cs = list[i]; | ||
if (cs.test) { c(cs.test, st, "Expression"); } | ||
for (var j = 0; j < cs.consequent.length; ++j) | ||
{ c(cs.consequent[j], st, "Statement"); } | ||
for (var i$1 = 0, list$1 = cs.consequent; i$1 < list$1.length; i$1 += 1) | ||
{ | ||
var cons = list$1[i$1]; | ||
c(cons, st, "Statement"); | ||
} | ||
} | ||
}; | ||
base.SwitchCase = function (node, st, c) { | ||
if (node.test) { c(node.test, st, "Expression"); } | ||
for (var i = 0, list = node.consequent; i < list.length; i += 1) | ||
{ | ||
var cons = list[i]; | ||
c(cons, st, "Statement"); | ||
} | ||
}; | ||
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) { | ||
@@ -228,4 +270,8 @@ if (node.argument) { c(node.argument, st, "Expression"); } | ||
base.VariableDeclaration = function (node, st, c) { | ||
for (var i = 0; i < node.declarations.length; ++i) | ||
{ c(node.declarations[i], st); } | ||
for (var i = 0, list = node.declarations; i < list.length; i += 1) | ||
{ | ||
var decl = list[i]; | ||
c(decl, st); | ||
} | ||
}; | ||
@@ -239,4 +285,8 @@ base.VariableDeclarator = function (node, st, c) { | ||
if (node.id) { c(node.id, st, "Pattern"); } | ||
for (var i = 0; i < node.params.length; i++) | ||
{ c(node.params[i], st, "Pattern"); } | ||
for (var i = 0, list = node.params; i < list.length; i += 1) | ||
{ | ||
var param = list[i]; | ||
c(param, st, "Pattern"); | ||
} | ||
c(node.body, st, node.expression ? "ScopeExpression" : "ScopeBody"); | ||
@@ -260,5 +310,6 @@ }; | ||
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); }; | ||
base.ArrayPattern = function (node, st, c) { | ||
for (var i = 0; i < node.elements.length; ++i) { | ||
var elt = node.elements[i]; | ||
base.ArrayPattern = function (node, st, c) { | ||
for (var i = 0, list = node.elements; i < list.length; i += 1) { | ||
var elt = list[i]; | ||
if (elt) { c(elt, st, "Pattern"); } | ||
@@ -268,4 +319,8 @@ } | ||
base.ObjectPattern = function (node, st, c) { | ||
for (var i = 0; i < node.properties.length; ++i) | ||
{ c(node.properties[i].value, st, "Pattern"); } | ||
for (var i = 0, list = node.properties; i < list.length; i += 1) | ||
{ | ||
var prop = list[i]; | ||
c(prop.value, st, "Pattern"); | ||
} | ||
}; | ||
@@ -276,4 +331,5 @@ | ||
base.ArrayExpression = function (node, st, c) { | ||
for (var i = 0; i < node.elements.length; ++i) { | ||
var elt = node.elements[i]; | ||
for (var i = 0, list = node.elements; i < list.length; i += 1) { | ||
var elt = list[i]; | ||
if (elt) { c(elt, st, "Expression"); } | ||
@@ -283,9 +339,17 @@ } | ||
base.ObjectExpression = function (node, st, c) { | ||
for (var i = 0; i < node.properties.length; ++i) | ||
{ c(node.properties[i], st); } | ||
for (var i = 0, list = node.properties; i < list.length; i += 1) | ||
{ | ||
var prop = list[i]; | ||
c(prop, st); | ||
} | ||
}; | ||
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration; | ||
base.SequenceExpression = base.TemplateLiteral = function (node, st, c) { | ||
for (var i = 0; i < node.expressions.length; ++i) | ||
{ c(node.expressions[i], st, "Expression"); } | ||
for (var i = 0, list = node.expressions; i < list.length; i += 1) | ||
{ | ||
var expr = list[i]; | ||
c(expr, st, "Expression"); | ||
} | ||
}; | ||
@@ -310,4 +374,9 @@ base.UnaryExpression = base.UpdateExpression = function (node, st, c) { | ||
c(node.callee, st, "Expression"); | ||
if (node.arguments) { for (var i = 0; i < node.arguments.length; ++i) | ||
{ c(node.arguments[i], st, "Expression"); } } | ||
if (node.arguments) | ||
{ for (var i = 0, list = node.arguments; i < list.length; i += 1) | ||
{ | ||
var arg = list[i]; | ||
c(arg, st, "Expression"); | ||
} } | ||
}; | ||
@@ -327,4 +396,8 @@ base.MemberExpression = function (node, st, c) { | ||
base.ImportDeclaration = function (node, st, c) { | ||
for (var i = 0; i < node.specifiers.length; i++) | ||
{ c(node.specifiers[i], st); } | ||
for (var i = 0, list = node.specifiers; i < list.length; i += 1) | ||
{ | ||
var spec = list[i]; | ||
c(spec, st); | ||
} | ||
c(node.source, st, "Expression"); | ||
@@ -336,3 +409,3 @@ }; | ||
c(node.tag, st, "Expression"); | ||
c(node.quasi, st); | ||
c(node.quasi, st, "Expression"); | ||
}; | ||
@@ -343,4 +416,8 @@ base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); }; | ||
if (node.superClass) { c(node.superClass, st, "Expression"); } | ||
for (var i = 0; i < node.body.body.length; i++) | ||
{ c(node.body.body[i], st); } | ||
for (var i = 0, list = node.body.body; i < list.length; i += 1) | ||
{ | ||
var item = list[i]; | ||
c(item, st); | ||
} | ||
}; | ||
@@ -352,2 +429,2 @@ base.MethodDefinition = base.Property = function (node, st, c) { | ||
export { simple, ancestor, recursive, findNodeAt, findNodeAround, findNodeAfter, findNodeBefore, make, base }; | ||
export { simple, ancestor, recursive, full, fullAncestor, findNodeAt, findNodeAround, findNodeAfter, findNodeBefore, make, base }; |
378
dist/walk.js
@@ -1,2 +0,7 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.acorn || (g.acorn = {})).walk = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.acorn = global.acorn || {}, global.acorn.walk = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
// AST walker module for Mozilla Parser API compatible trees | ||
@@ -20,39 +25,23 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.simple = simple; | ||
exports.ancestor = ancestor; | ||
exports.recursive = recursive; | ||
exports.findNodeAt = findNodeAt; | ||
exports.findNodeAround = findNodeAround; | ||
exports.findNodeAfter = findNodeAfter; | ||
exports.findNodeBefore = findNodeBefore; | ||
exports.make = make; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function simple(node, visitors, base, state, override) { | ||
if (!base) base = exports.base;(function c(node, st, override) { | ||
var type = override || node.type, | ||
found = visitors[type]; | ||
if (!base) { base = exports.base | ||
; }(function c(node, st, override) { | ||
var type = override || node.type, found = visitors[type]; | ||
base[type](node, st, c); | ||
if (found) found(node, st); | ||
if (found) { found(node, st); } | ||
})(node, state, override); | ||
} | ||
// An ancestor walk builds up an array of ancestor nodes (including | ||
// the current node) and passes them to the callback as the state parameter. | ||
// An ancestor walk keeps an array of ancestor nodes (including the | ||
// current node) and passes them to the callback as third parameter | ||
// (and also as state parameter when no other state is present). | ||
function ancestor(node, visitors, base, state) { | ||
if (!base) base = exports.base; | ||
if (!state) state = [];(function c(node, st, override) { | ||
var type = override || node.type, | ||
found = visitors[type]; | ||
if (node != st[st.length - 1]) { | ||
st = st.slice(); | ||
st.push(node); | ||
} | ||
if (!base) { base = exports.base; } | ||
var ancestors = [];(function c(node, st, override) { | ||
var type = override || node.type, found = visitors[type]; | ||
var isNew = node != ancestors[ancestors.length - 1]; | ||
if (isNew) { ancestors.push(node); } | ||
base[type](node, st, c); | ||
if (found) found(node, st); | ||
if (found) { found(node, st || ancestors, ancestors); } | ||
if (isNew) { ancestors.pop(); } | ||
})(node, state); | ||
@@ -66,3 +55,2 @@ } | ||
// nodes). | ||
function recursive(node, state, funcs, base, override) { | ||
@@ -75,32 +63,56 @@ var visitor = funcs ? exports.make(funcs, base) : base;(function c(node, st, override) { | ||
function makeTest(test) { | ||
if (typeof test == "string") return function (type) { | ||
return type == test; | ||
};else if (!test) return function () { | ||
return true; | ||
};else return test; | ||
if (typeof test == "string") | ||
{ return function (type) { return type == test; } } | ||
else if (!test) | ||
{ return function () { return true; } } | ||
else | ||
{ return test } | ||
} | ||
var Found = function Found(node, state) { | ||
_classCallCheck(this, Found); | ||
var Found = function Found(node, state) { this.node = node; this.state = state; }; | ||
this.node = node;this.state = state; | ||
// A full walk triggers the callback on each node | ||
function full(node, callback, base, state, override) { | ||
if (!base) { base = exports.base | ||
; }(function c(node, st, override) { | ||
var type = override || node.type; | ||
base[type](node, st, c); | ||
if (!override) { callback(node, st, type); } | ||
})(node, state, override); | ||
} | ||
// An fullAncestor walk is like an ancestor walk, but triggers | ||
// the callback on each node | ||
function fullAncestor(node, callback, base, state) { | ||
if (!base) { base = exports.base; } | ||
var ancestors = [];(function c(node, st, override) { | ||
var type = override || node.type; | ||
var isNew = node != ancestors[ancestors.length - 1]; | ||
if (isNew) { ancestors.push(node); } | ||
base[type](node, st, c); | ||
if (!override) { callback(node, st || ancestors, ancestors, type); } | ||
if (isNew) { ancestors.pop(); } | ||
})(node, state); | ||
} | ||
// Find a node with a given start, end, and type (all are optional, | ||
// null can be used as wildcard). Returns a {node, state} object, or | ||
// undefined when it doesn't find a matching node. | ||
; | ||
function findNodeAt(node, start, end, test, base, state) { | ||
test = makeTest(test); | ||
if (!base) base = exports.base; | ||
if (!base) { base = exports.base; } | ||
try { | ||
;(function c(node, st, override) { | ||
(function c(node, st, override) { | ||
var type = override || node.type; | ||
if ((start == null || node.start <= start) && (end == null || node.end >= end)) base[type](node, st, c); | ||
if ((start == null || node.start == start) && (end == null || node.end == end) && test(type, node)) throw new Found(node, st); | ||
if ((start == null || node.start <= start) && | ||
(end == null || node.end >= end)) | ||
{ base[type](node, st, c); } | ||
if ((start == null || node.start == start) && | ||
(end == null || node.end == end) && | ||
test(type, node)) | ||
{ throw new Found(node, st) } | ||
})(node, state); | ||
} catch (e) { | ||
if (e instanceof Found) return e; | ||
throw e; | ||
if (e instanceof Found) { return e } | ||
throw e | ||
} | ||
@@ -111,16 +123,15 @@ } | ||
// position. Interface similar to findNodeAt. | ||
function findNodeAround(node, pos, test, base, state) { | ||
test = makeTest(test); | ||
if (!base) base = exports.base; | ||
if (!base) { base = exports.base; } | ||
try { | ||
;(function c(node, st, override) { | ||
(function c(node, st, override) { | ||
var type = override || node.type; | ||
if (node.start > pos || node.end < pos) return; | ||
if (node.start > pos || node.end < pos) { return } | ||
base[type](node, st, c); | ||
if (test(type, node)) throw new Found(node, st); | ||
if (test(type, node)) { throw new Found(node, st) } | ||
})(node, state); | ||
} catch (e) { | ||
if (e instanceof Found) return e; | ||
throw e; | ||
if (e instanceof Found) { return e } | ||
throw e | ||
} | ||
@@ -130,16 +141,15 @@ } | ||
// Find the outermost matching node after a given position. | ||
function findNodeAfter(node, pos, test, base, state) { | ||
test = makeTest(test); | ||
if (!base) base = exports.base; | ||
if (!base) { base = exports.base; } | ||
try { | ||
;(function c(node, st, override) { | ||
if (node.end < pos) return; | ||
(function c(node, st, override) { | ||
if (node.end < pos) { return } | ||
var type = override || node.type; | ||
if (node.start >= pos && test(type, node)) throw new Found(node, st); | ||
if (node.start >= pos && test(type, node)) { throw new Found(node, st) } | ||
base[type](node, st, c); | ||
})(node, state); | ||
} catch (e) { | ||
if (e instanceof Found) return e; | ||
throw e; | ||
if (e instanceof Found) { return e } | ||
throw e | ||
} | ||
@@ -149,29 +159,32 @@ } | ||
// Find the outermost matching node before a given position. | ||
function findNodeBefore(node, pos, test, base, state) { | ||
test = makeTest(test); | ||
if (!base) base = exports.base; | ||
var max = undefined;(function c(node, st, override) { | ||
if (node.start > pos) return; | ||
if (!base) { base = exports.base; } | ||
var max;(function c(node, st, override) { | ||
if (node.start > pos) { return } | ||
var type = override || node.type; | ||
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node)) max = new Found(node, st); | ||
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node)) | ||
{ max = new Found(node, st); } | ||
base[type](node, st, c); | ||
})(node, state); | ||
return max; | ||
return max | ||
} | ||
// Fallback to an Object.create polyfill for older environments. | ||
var create = Object.create || function(proto) { | ||
function Ctor() {} | ||
Ctor.prototype = proto; | ||
return new Ctor | ||
}; | ||
// Used to create a custom walker. Will fill in all missing node | ||
// type properties with the defaults. | ||
function make(funcs, base) { | ||
if (!base) base = exports.base; | ||
var visitor = {}; | ||
for (var type in base) visitor[type] = base[type]; | ||
for (var type in funcs) visitor[type] = funcs[type]; | ||
return visitor; | ||
if (!base) { base = exports.base; } | ||
var visitor = create(base); | ||
for (var type in funcs) { visitor[type] = funcs[type]; } | ||
return visitor | ||
} | ||
function skipThrough(node, st, c) { | ||
c(node, st); | ||
} | ||
function skipThrough(node, st, c) { c(node, st); } | ||
function ignore(_node, _st, _c) {} | ||
@@ -183,6 +196,8 @@ | ||
exports.base = base; | ||
base.Program = base.BlockStatement = function (node, st, c) { | ||
for (var i = 0; i < node.body.length; ++i) { | ||
c(node.body[i], st, "Statement"); | ||
for (var i = 0, list = node.body; i < list.length; i += 1) | ||
{ | ||
var stmt = list[i]; | ||
c(stmt, st, "Statement"); | ||
} | ||
@@ -192,13 +207,10 @@ }; | ||
base.EmptyStatement = ignore; | ||
base.ExpressionStatement = base.ParenthesizedExpression = function (node, st, c) { | ||
return c(node.expression, st, "Expression"); | ||
}; | ||
base.ExpressionStatement = base.ParenthesizedExpression = | ||
function (node, st, c) { return c(node.expression, st, "Expression"); }; | ||
base.IfStatement = function (node, st, c) { | ||
c(node.test, st, "Expression"); | ||
c(node.consequent, st, "Statement"); | ||
if (node.alternate) c(node.alternate, st, "Statement"); | ||
if (node.alternate) { c(node.alternate, st, "Statement"); } | ||
}; | ||
base.LabeledStatement = function (node, st, c) { | ||
return c(node.body, st, "Statement"); | ||
}; | ||
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); }; | ||
base.BreakStatement = base.ContinueStatement = ignore; | ||
@@ -211,24 +223,37 @@ base.WithStatement = function (node, st, c) { | ||
c(node.discriminant, st, "Expression"); | ||
for (var i = 0; i < node.cases.length; ++i) { | ||
var cs = node.cases[i]; | ||
if (cs.test) c(cs.test, st, "Expression"); | ||
for (var j = 0; j < cs.consequent.length; ++j) { | ||
c(cs.consequent[j], st, "Statement"); | ||
for (var i = 0, list = node.cases; i < list.length; i += 1) { | ||
var cs = list[i]; | ||
if (cs.test) { c(cs.test, st, "Expression"); } | ||
for (var i$1 = 0, list$1 = cs.consequent; i$1 < list$1.length; i$1 += 1) | ||
{ | ||
var cons = list$1[i$1]; | ||
c(cons, st, "Statement"); | ||
} | ||
} | ||
}; | ||
base.ReturnStatement = base.YieldExpression = function (node, st, c) { | ||
if (node.argument) c(node.argument, st, "Expression"); | ||
base.SwitchCase = function (node, st, c) { | ||
if (node.test) { c(node.test, st, "Expression"); } | ||
for (var i = 0, list = node.consequent; i < list.length; i += 1) | ||
{ | ||
var cons = list[i]; | ||
c(cons, st, "Statement"); | ||
} | ||
}; | ||
base.ThrowStatement = base.SpreadElement = function (node, st, c) { | ||
return c(node.argument, st, "Expression"); | ||
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) { | ||
if (node.argument) { c(node.argument, st, "Expression"); } | ||
}; | ||
base.ThrowStatement = base.SpreadElement = | ||
function (node, st, c) { return c(node.argument, st, "Expression"); }; | ||
base.TryStatement = function (node, st, c) { | ||
c(node.block, st, "Statement"); | ||
if (node.handler) { | ||
c(node.handler.param, st, "Pattern"); | ||
c(node.handler.body, st, "ScopeBody"); | ||
} | ||
if (node.finalizer) c(node.finalizer, st, "Statement"); | ||
if (node.handler) { c(node.handler, st); } | ||
if (node.finalizer) { c(node.finalizer, st, "Statement"); } | ||
}; | ||
base.CatchClause = function (node, st, c) { | ||
c(node.param, st, "Pattern"); | ||
c(node.body, st, "ScopeBody"); | ||
}; | ||
base.WhileStatement = base.DoWhileStatement = function (node, st, c) { | ||
@@ -239,5 +264,5 @@ c(node.test, st, "Expression"); | ||
base.ForStatement = function (node, st, c) { | ||
if (node.init) c(node.init, st, "ForInit"); | ||
if (node.test) c(node.test, st, "Expression"); | ||
if (node.update) c(node.update, st, "Expression"); | ||
if (node.init) { c(node.init, st, "ForInit"); } | ||
if (node.test) { c(node.test, st, "Expression"); } | ||
if (node.update) { c(node.update, st, "Expression"); } | ||
c(node.body, st, "Statement"); | ||
@@ -251,12 +276,14 @@ }; | ||
base.ForInit = function (node, st, c) { | ||
if (node.type == "VariableDeclaration") c(node, st);else c(node, st, "Expression"); | ||
if (node.type == "VariableDeclaration") { c(node, st); } | ||
else { c(node, st, "Expression"); } | ||
}; | ||
base.DebuggerStatement = ignore; | ||
base.FunctionDeclaration = function (node, st, c) { | ||
return c(node, st, "Function"); | ||
}; | ||
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); }; | ||
base.VariableDeclaration = function (node, st, c) { | ||
for (var i = 0; i < node.declarations.length; ++i) { | ||
c(node.declarations[i], st); | ||
for (var i = 0, list = node.declarations; i < list.length; i += 1) | ||
{ | ||
var decl = list[i]; | ||
c(decl, st); | ||
} | ||
@@ -266,37 +293,44 @@ }; | ||
c(node.id, st, "Pattern"); | ||
if (node.init) c(node.init, st, "Expression"); | ||
if (node.init) { c(node.init, st, "Expression"); } | ||
}; | ||
base.Function = function (node, st, c) { | ||
if (node.id) c(node.id, st, "Pattern"); | ||
for (var i = 0; i < node.params.length; i++) { | ||
c(node.params[i], st, "Pattern"); | ||
}c(node.body, st, node.expression ? "ScopeExpression" : "ScopeBody"); | ||
if (node.id) { c(node.id, st, "Pattern"); } | ||
for (var i = 0, list = node.params; i < list.length; i += 1) | ||
{ | ||
var param = list[i]; | ||
c(param, st, "Pattern"); | ||
} | ||
c(node.body, st, node.expression ? "ScopeExpression" : "ScopeBody"); | ||
}; | ||
// FIXME drop these node types in next major version | ||
// (They are awkward, and in ES6 every block can be a scope.) | ||
base.ScopeBody = function (node, st, c) { | ||
return c(node, st, "Statement"); | ||
}; | ||
base.ScopeExpression = function (node, st, c) { | ||
return c(node, st, "Expression"); | ||
}; | ||
base.ScopeBody = function (node, st, c) { return c(node, st, "Statement"); }; | ||
base.ScopeExpression = function (node, st, c) { return c(node, st, "Expression"); }; | ||
base.Pattern = function (node, st, c) { | ||
if (node.type == "Identifier") c(node, st, "VariablePattern");else if (node.type == "MemberExpression") c(node, st, "MemberPattern");else c(node, st); | ||
if (node.type == "Identifier") | ||
{ c(node, st, "VariablePattern"); } | ||
else if (node.type == "MemberExpression") | ||
{ c(node, st, "MemberPattern"); } | ||
else | ||
{ c(node, st); } | ||
}; | ||
base.VariablePattern = ignore; | ||
base.MemberPattern = skipThrough; | ||
base.RestElement = function (node, st, c) { | ||
return c(node.argument, st, "Pattern"); | ||
}; | ||
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); }; | ||
base.ArrayPattern = function (node, st, c) { | ||
for (var i = 0; i < node.elements.length; ++i) { | ||
var elt = node.elements[i]; | ||
if (elt) c(elt, st, "Pattern"); | ||
for (var i = 0, list = node.elements; i < list.length; i += 1) { | ||
var elt = list[i]; | ||
if (elt) { c(elt, st, "Pattern"); } | ||
} | ||
}; | ||
base.ObjectPattern = function (node, st, c) { | ||
for (var i = 0; i < node.properties.length; ++i) { | ||
c(node.properties[i].value, st, "Pattern"); | ||
for (var i = 0, list = node.properties; i < list.length; i += 1) | ||
{ | ||
var prop = list[i]; | ||
c(prop.value, st, "Pattern"); | ||
} | ||
@@ -308,10 +342,14 @@ }; | ||
base.ArrayExpression = function (node, st, c) { | ||
for (var i = 0; i < node.elements.length; ++i) { | ||
var elt = node.elements[i]; | ||
if (elt) c(elt, st, "Expression"); | ||
for (var i = 0, list = node.elements; i < list.length; i += 1) { | ||
var elt = list[i]; | ||
if (elt) { c(elt, st, "Expression"); } | ||
} | ||
}; | ||
base.ObjectExpression = function (node, st, c) { | ||
for (var i = 0; i < node.properties.length; ++i) { | ||
c(node.properties[i], st); | ||
for (var i = 0, list = node.properties; i < list.length; i += 1) | ||
{ | ||
var prop = list[i]; | ||
c(prop, st); | ||
} | ||
@@ -321,4 +359,7 @@ }; | ||
base.SequenceExpression = base.TemplateLiteral = function (node, st, c) { | ||
for (var i = 0; i < node.expressions.length; ++i) { | ||
c(node.expressions[i], st, "Expression"); | ||
for (var i = 0, list = node.expressions; i < list.length; i += 1) | ||
{ | ||
var expr = list[i]; | ||
c(expr, st, "Expression"); | ||
} | ||
@@ -344,13 +385,18 @@ }; | ||
c(node.callee, st, "Expression"); | ||
if (node.arguments) for (var i = 0; i < node.arguments.length; ++i) { | ||
c(node.arguments[i], st, "Expression"); | ||
} | ||
if (node.arguments) | ||
{ for (var i = 0, list = node.arguments; i < list.length; i += 1) | ||
{ | ||
var arg = list[i]; | ||
c(arg, st, "Expression"); | ||
} } | ||
}; | ||
base.MemberExpression = function (node, st, c) { | ||
c(node.object, st, "Expression"); | ||
if (node.computed) c(node.property, st, "Expression"); | ||
if (node.computed) { c(node.property, st, "Expression"); } | ||
}; | ||
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) { | ||
if (node.declaration) c(node.declaration, st, node.type == "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); | ||
if (node.source) c(node.source, st, "Expression"); | ||
if (node.declaration) | ||
{ c(node.declaration, st, node.type == "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); } | ||
if (node.source) { c(node.source, st, "Expression"); } | ||
}; | ||
@@ -361,5 +407,9 @@ base.ExportAllDeclaration = function (node, st, c) { | ||
base.ImportDeclaration = function (node, st, c) { | ||
for (var i = 0; i < node.specifiers.length; i++) { | ||
c(node.specifiers[i], st); | ||
}c(node.source, st, "Expression"); | ||
for (var i = 0, list = node.specifiers; i < list.length; i += 1) | ||
{ | ||
var spec = list[i]; | ||
c(spec, st); | ||
} | ||
c(node.source, st, "Expression"); | ||
}; | ||
@@ -370,20 +420,34 @@ base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = ignore; | ||
c(node.tag, st, "Expression"); | ||
c(node.quasi, st); | ||
c(node.quasi, st, "Expression"); | ||
}; | ||
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { | ||
return c(node, st, "Class"); | ||
}; | ||
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); }; | ||
base.Class = function (node, st, c) { | ||
if (node.id) c(node.id, st, "Pattern"); | ||
if (node.superClass) c(node.superClass, st, "Expression"); | ||
for (var i = 0; i < node.body.body.length; i++) { | ||
c(node.body.body[i], st); | ||
if (node.id) { c(node.id, st, "Pattern"); } | ||
if (node.superClass) { c(node.superClass, st, "Expression"); } | ||
for (var i = 0, list = node.body.body; i < list.length; i += 1) | ||
{ | ||
var item = list[i]; | ||
c(item, st); | ||
} | ||
}; | ||
base.MethodDefinition = base.Property = function (node, st, c) { | ||
if (node.computed) c(node.key, st, "Expression"); | ||
if (node.computed) { c(node.key, st, "Expression"); } | ||
c(node.value, st, "Expression"); | ||
}; | ||
},{}]},{},[1])(1) | ||
}); | ||
exports.simple = simple; | ||
exports.ancestor = ancestor; | ||
exports.recursive = recursive; | ||
exports.full = full; | ||
exports.fullAncestor = fullAncestor; | ||
exports.findNodeAt = findNodeAt; | ||
exports.findNodeAround = findNodeAround; | ||
exports.findNodeAfter = findNodeAfter; | ||
exports.findNodeBefore = findNodeBefore; | ||
exports.make = make; | ||
exports.base = base; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); |
@@ -7,3 +7,3 @@ { | ||
"module": "dist/acorn.es.js", | ||
"version": "5.4.0", | ||
"version": "5.4.1", | ||
"engines": { | ||
@@ -10,0 +10,0 @@ "node": ">=0.4.0" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
489403
10101
2