diff options
Diffstat (limited to 'node_modules/estraverse')
-rw-r--r-- | node_modules/estraverse/.editorconfig | 10 | ||||
-rw-r--r-- | node_modules/estraverse/README.md | 124 | ||||
-rw-r--r-- | node_modules/estraverse/estraverse.js | 102 | ||||
-rw-r--r-- | node_modules/estraverse/package.json | 15 |
4 files changed, 59 insertions, 192 deletions
diff --git a/node_modules/estraverse/.editorconfig b/node_modules/estraverse/.editorconfig deleted file mode 100644 index 1d4fc223a..000000000 --- a/node_modules/estraverse/.editorconfig +++ /dev/null @@ -1,10 +0,0 @@ -# top-most EditorConfig file -root = true - -[*] -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 4 -tab_width = 4 diff --git a/node_modules/estraverse/README.md b/node_modules/estraverse/README.md deleted file mode 100644 index 4242c5133..000000000 --- a/node_modules/estraverse/README.md +++ /dev/null @@ -1,124 +0,0 @@ -### Estraverse [![Build Status](https://secure.travis-ci.org/estools/estraverse.png)](http://travis-ci.org/estools/estraverse) - -Estraverse ([estraverse](http://github.com/estools/estraverse)) is -[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm) -traversal functions from [esmangle project](http://github.com/estools/esmangle). - -### Documentation - -You can find usage docs at [wiki page](https://github.com/estools/estraverse/wiki/Usage). - -### Example Usage - -The following code will output all variables declared at the root of a file. - -```javascript -estraverse.traverse(ast, { - enter: function (node, parent) { - if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration') - return estraverse.VisitorOption.Skip; - }, - leave: function (node, parent) { - if (node.type == 'VariableDeclarator') - console.log(node.id.name); - } -}); -``` - -We can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break. - -```javascript -estraverse.traverse(ast, { - enter: function (node) { - this.break(); - } -}); -``` - -And estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it. - -```javascript -result = estraverse.replace(tree, { - enter: function (node) { - // Replace it with replaced. - if (node.type === 'Literal') - return replaced; - } -}); -``` - -By passing `visitor.keys` mapping, we can extend estraverse traversing functionality. - -```javascript -// This tree contains a user-defined `TestExpression` node. -var tree = { - type: 'TestExpression', - - // This 'argument' is the property containing the other **node**. - argument: { - type: 'Literal', - value: 20 - }, - - // This 'extended' is the property not containing the other **node**. - extended: true -}; -estraverse.traverse(tree, { - enter: function (node) { }, - - // Extending the exising traversing rules. - keys: { - // TargetNodeName: [ 'keys', 'containing', 'the', 'other', '**node**' ] - TestExpression: ['argument'] - } -}); -``` - -By passing `visitor.fallback` option, we can control the behavior when encountering unknown nodes. -```javascript -// This tree contains a user-defined `TestExpression` node. -var tree = { - type: 'TestExpression', - - // This 'argument' is the property containing the other **node**. - argument: { - type: 'Literal', - value: 20 - }, - - // This 'extended' is the property not containing the other **node**. - extended: true -}; -estraverse.traverse(tree, { - enter: function (node) { }, - - // Iterating the child **nodes** of unknown nodes. - fallback: 'iteration' -}); -``` - -### License - -Copyright (C) 2012-2013 [Yusuke Suzuki](http://github.com/Constellation) - (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 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 : */ diff --git a/node_modules/estraverse/package.json b/node_modules/estraverse/package.json index e0c441646..f8567e392 100644 --- a/node_modules/estraverse/package.json +++ b/node_modules/estraverse/package.json @@ -3,7 +3,7 @@ "description": "ECMAScript JS AST traversal functions", "homepage": "https://github.com/estools/estraverse", "main": "estraverse.js", - "version": "1.9.3", + "version": "4.2.0", "engines": { "node": ">=0.10.0" }, @@ -19,8 +19,10 @@ "url": "http://github.com/estools/estraverse.git" }, "devDependencies": { + "babel-preset-es2015": "^6.3.13", + "babel-register": "^6.3.13", "chai": "^2.1.1", - "coffee-script": "^1.8.0", + "espree": "^1.11.0", "gulp": "^3.8.10", "gulp-bump": "^0.2.2", "gulp-filter": "^2.0.0", @@ -29,15 +31,10 @@ "jshint": "^2.5.6", "mocha": "^2.1.0" }, - "licenses": [ - { - "type": "BSD", - "url": "http://github.com/estools/estraverse/raw/master/LICENSE.BSD" - } - ], + "license": "BSD-2-Clause", "scripts": { "test": "npm run-script lint && npm run-script unit-test", "lint": "jshint estraverse.js", - "unit-test": "mocha --compilers coffee:coffee-script/register" + "unit-test": "mocha --compilers js:babel-register" } } |