aboutsummaryrefslogtreecommitdiff
path: root/node_modules/estraverse/estraverse.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-27 17:36:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-27 17:36:13 +0200
commit5f466137ad6ac596600e3ff53c9b786815398445 (patch)
treef914c221874f0b16bf3def7ac01d59d1a99a3b0b /node_modules/estraverse/estraverse.js
parentc9f5ac8e763eda19aa0564179300cfff76785435 (diff)
node_modules, clean up package.json
Diffstat (limited to 'node_modules/estraverse/estraverse.js')
-rw-r--r--node_modules/estraverse/estraverse.js102
1 files changed, 53 insertions, 49 deletions
diff --git a/node_modules/estraverse/estraverse.js b/node_modules/estraverse/estraverse.js
index 99bbb8c3b..09ae47832 100644
--- a/node_modules/estraverse/estraverse.js
+++ b/node_modules/estraverse/estraverse.js
@@ -24,20 +24,8 @@
*/
/*jslint vars:false, bitwise:true*/
/*jshint indent:4*/
-/*global exports:true, define:true*/
-(function (root, factory) {
- 'use strict';
-
- // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
- // and plain browser loading,
- if (typeof define === 'function' && define.amd) {
- define(['exports'], factory);
- } else if (typeof exports !== 'undefined') {
- factory(exports);
- } else {
- factory((root.estraverse = {}));
- }
-}(this, function clone(exports) {
+/*global exports:true*/
+(function clone(exports) {
'use strict';
var Syntax,
@@ -155,6 +143,7 @@
Syntax = {
AssignmentExpression: 'AssignmentExpression',
+ AssignmentPattern: 'AssignmentPattern',
ArrayExpression: 'ArrayExpression',
ArrayPattern: 'ArrayPattern',
ArrowFunctionExpression: 'ArrowFunctionExpression',
@@ -175,8 +164,9 @@
DirectiveStatement: 'DirectiveStatement',
DoWhileStatement: 'DoWhileStatement',
EmptyStatement: 'EmptyStatement',
- ExportBatchSpecifier: 'ExportBatchSpecifier',
- ExportDeclaration: 'ExportDeclaration',
+ ExportAllDeclaration: 'ExportAllDeclaration',
+ ExportDefaultDeclaration: 'ExportDefaultDeclaration',
+ ExportNamedDeclaration: 'ExportNamedDeclaration',
ExportSpecifier: 'ExportSpecifier',
ExpressionStatement: 'ExpressionStatement',
ForStatement: 'ForStatement',
@@ -195,6 +185,7 @@
LabeledStatement: 'LabeledStatement',
LogicalExpression: 'LogicalExpression',
MemberExpression: 'MemberExpression',
+ MetaProperty: 'MetaProperty',
MethodDefinition: 'MethodDefinition',
ModuleSpecifier: 'ModuleSpecifier',
NewExpression: 'NewExpression',
@@ -202,9 +193,11 @@
ObjectPattern: 'ObjectPattern',
Program: 'Program',
Property: 'Property',
+ RestElement: 'RestElement',
ReturnStatement: 'ReturnStatement',
SequenceExpression: 'SequenceExpression',
SpreadElement: 'SpreadElement',
+ Super: 'Super',
SwitchStatement: 'SwitchStatement',
SwitchCase: 'SwitchCase',
TaggedTemplateExpression: 'TaggedTemplateExpression',
@@ -224,9 +217,10 @@
VisitorKeys = {
AssignmentExpression: ['left', 'right'],
+ AssignmentPattern: ['left', 'right'],
ArrayExpression: ['elements'],
ArrayPattern: ['elements'],
- ArrowFunctionExpression: ['params', 'defaults', 'rest', 'body'],
+ ArrowFunctionExpression: ['params', 'body'],
AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
BlockStatement: ['body'],
BinaryExpression: ['left', 'right'],
@@ -234,8 +228,8 @@
CallExpression: ['callee', 'arguments'],
CatchClause: ['param', 'body'],
ClassBody: ['body'],
- ClassDeclaration: ['id', 'body', 'superClass'],
- ClassExpression: ['id', 'body', 'superClass'],
+ ClassDeclaration: ['id', 'superClass', 'body'],
+ ClassExpression: ['id', 'superClass', 'body'],
ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
ConditionalExpression: ['test', 'consequent', 'alternate'],
@@ -244,26 +238,28 @@
DirectiveStatement: [],
DoWhileStatement: ['body', 'test'],
EmptyStatement: [],
- ExportBatchSpecifier: [],
- ExportDeclaration: ['declaration', 'specifiers', 'source'],
- ExportSpecifier: ['id', 'name'],
+ ExportAllDeclaration: ['source'],
+ ExportDefaultDeclaration: ['declaration'],
+ ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
+ ExportSpecifier: ['exported', 'local'],
ExpressionStatement: ['expression'],
ForStatement: ['init', 'test', 'update', 'body'],
ForInStatement: ['left', 'right', 'body'],
ForOfStatement: ['left', 'right', 'body'],
- FunctionDeclaration: ['id', 'params', 'defaults', 'rest', 'body'],
- FunctionExpression: ['id', 'params', 'defaults', 'rest', 'body'],
+ FunctionDeclaration: ['id', 'params', 'body'],
+ FunctionExpression: ['id', 'params', 'body'],
GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
Identifier: [],
IfStatement: ['test', 'consequent', 'alternate'],
ImportDeclaration: ['specifiers', 'source'],
- ImportDefaultSpecifier: ['id'],
- ImportNamespaceSpecifier: ['id'],
- ImportSpecifier: ['id', 'name'],
+ ImportDefaultSpecifier: ['local'],
+ ImportNamespaceSpecifier: ['local'],
+ ImportSpecifier: ['imported', 'local'],
Literal: [],
LabeledStatement: ['label', 'body'],
LogicalExpression: ['left', 'right'],
MemberExpression: ['object', 'property'],
+ MetaProperty: ['meta', 'property'],
MethodDefinition: ['key', 'value'],
ModuleSpecifier: [],
NewExpression: ['callee', 'arguments'],
@@ -271,9 +267,11 @@
ObjectPattern: ['properties'],
Program: ['body'],
Property: ['key', 'value'],
+ RestElement: [ 'argument' ],
ReturnStatement: ['argument'],
SequenceExpression: ['expressions'],
SpreadElement: ['argument'],
+ Super: [],
SwitchStatement: ['discriminant', 'cases'],
SwitchCase: ['test', 'consequent'],
TaggedTemplateExpression: ['tag', 'quasi'],
@@ -281,7 +279,7 @@
TemplateLiteral: ['quasis', 'expressions'],
ThisExpression: [],
ThrowStatement: ['argument'],
- TryStatement: ['block', 'handlers', 'handler', 'guardedHandlers', 'finalizer'],
+ TryStatement: ['block', 'handler', 'finalizer'],
UnaryExpression: ['argument'],
UpdateExpression: ['argument'],
VariableDeclaration: ['declarations'],
@@ -434,7 +432,13 @@
this.__leavelist = [];
this.__current = null;
this.__state = null;
- this.__fallback = visitor.fallback === 'iteration';
+ this.__fallback = null;
+ if (visitor.fallback === 'iteration') {
+ this.__fallback = objectKeys;
+ } else if (typeof visitor.fallback === 'function') {
+ this.__fallback = visitor.fallback;
+ }
+
this.__keys = VisitorKeys;
if (visitor.keys) {
this.__keys = extend(objectCreate(this.__keys), visitor.keys);
@@ -508,11 +512,11 @@
}
node = element.node;
- nodeType = element.wrap || node.type;
+ nodeType = node.type || element.wrap;
candidates = this.__keys[nodeType];
if (!candidates) {
if (this.__fallback) {
- candidates = objectKeys(node);
+ candidates = this.__fallback(node);
} else {
throw new Error('Unknown node type ' + nodeType + '.');
}
@@ -550,6 +554,20 @@
};
Controller.prototype.replace = function replace(root, visitor) {
+ var worklist,
+ leavelist,
+ node,
+ nodeType,
+ target,
+ element,
+ current,
+ current2,
+ candidates,
+ candidate,
+ sentinel,
+ outer,
+ key;
+
function removeElem(element) {
var i,
key,
@@ -575,20 +593,6 @@
}
}
- var worklist,
- leavelist,
- node,
- nodeType,
- target,
- element,
- current,
- current2,
- candidates,
- candidate,
- sentinel,
- outer,
- key;
-
this.__initialize(root, visitor);
sentinel = {};
@@ -662,11 +666,11 @@
continue;
}
- nodeType = element.wrap || node.type;
+ nodeType = node.type || element.wrap;
candidates = this.__keys[nodeType];
if (!candidates) {
if (this.__fallback) {
- candidates = objectKeys(node);
+ candidates = this.__fallback(node);
} else {
throw new Error('Unknown node type ' + nodeType + '.');
}
@@ -830,7 +834,7 @@
return tree;
}
- exports.version = '1.8.1-dev';
+ exports.version = require('./package.json').version;
exports.Syntax = Syntax;
exports.traverse = traverse;
exports.replace = replace;
@@ -841,5 +845,5 @@
exports.cloneEnvironment = function () { return clone({}); };
return exports;
-}));
+}(exports));
/* vim: set sw=4 ts=4 et tw=80 : */