-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
50 lines (50 loc) · 5.4 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
"name": "estraverse",
"description": "ECMAScript JS AST traversal functions",
"homepage": "https://github.com/estools/estraverse",
"main": "estraverse.js",
"version": "1.9.3",
"engines": {
"node": ">=0.10.0"
},
"maintainers": [
{
"name": "Yusuke Suzuki",
"email": "utatane.tea@gmail.com",
"url": "http://github.com/Constellation"
}
],
"repository": {
"type": "git",
"url": "http://github.com/estools/estraverse.git"
},
"devDependencies": {
"chai": "^2.1.1",
"coffee-script": "^1.8.0",
"gulp": "^3.8.10",
"gulp-bump": "^0.2.2",
"gulp-filter": "^2.0.0",
"gulp-git": "^1.0.1",
"gulp-tag-version": "^1.2.1",
"jshint": "^2.5.6",
"mocha": "^2.1.0"
},
"licenses": [
{
"type": "BSD",
"url": "http://github.com/estools/estraverse/raw/master/LICENSE.BSD"
}
],
"scripts": {
"test": "npm run-script lint && npm run-script unit-test",
"lint": "jshint estraverse.js",
"unit-test": "mocha --compilers coffee:coffee-script/register"
},
"readme": "### Estraverse [![Build Status](https://secure.travis-ci.org/estools/estraverse.png)](http://travis-ci.org/estools/estraverse)\n\nEstraverse ([estraverse](http://github.com/estools/estraverse)) is\n[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)\ntraversal functions from [esmangle project](http://github.com/estools/esmangle).\n\n### Documentation\n\nYou can find usage docs at [wiki page](https://github.com/estools/estraverse/wiki/Usage).\n\n### Example Usage\n\nThe following code will output all variables declared at the root of a file.\n\n```javascript\nestraverse.traverse(ast, {\n enter: function (node, parent) {\n if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')\n return estraverse.VisitorOption.Skip;\n },\n leave: function (node, parent) {\n if (node.type == 'VariableDeclarator')\n console.log(node.id.name);\n }\n});\n```\n\nWe can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break.\n\n```javascript\nestraverse.traverse(ast, {\n enter: function (node) {\n this.break();\n }\n});\n```\n\nAnd estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.\n\n```javascript\nresult = estraverse.replace(tree, {\n enter: function (node) {\n // Replace it with replaced.\n if (node.type === 'Literal')\n return replaced;\n }\n});\n```\n\nBy passing `visitor.keys` mapping, we can extend estraverse traversing functionality.\n\n```javascript\n// This tree contains a user-defined `TestExpression` node.\nvar tree = {\n type: 'TestExpression',\n\n // This 'argument' is the property containing the other **node**.\n argument: {\n type: 'Literal',\n value: 20\n },\n\n // This 'extended' is the property not containing the other **node**.\n extended: true\n};\nestraverse.traverse(tree, {\n enter: function (node) { },\n\n // Extending the exising traversing rules.\n keys: {\n // TargetNodeName: [ 'keys', 'containing', 'the', 'other', '**node**' ]\n TestExpression: ['argument']\n }\n});\n```\n\nBy passing `visitor.fallback` option, we can control the behavior when encountering unknown nodes.\n```javascript\n// This tree contains a user-defined `TestExpression` node.\nvar tree = {\n type: 'TestExpression',\n\n // This 'argument' is the property containing the other **node**.\n argument: {\n type: 'Literal',\n value: 20\n },\n\n // This 'extended' is the property not containing the other **node**.\n extended: true\n};\nestraverse.traverse(tree, {\n enter: function (node) { },\n\n // Iterating the child **nodes** of unknown nodes.\n fallback: 'iteration'\n});\n```\n\n### License\n\nCopyright (C) 2012-2013 [Yusuke Suzuki](http://github.com/Constellation)\n (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/estools/estraverse/issues"
},
"_id": "estraverse@1.9.3",
"_from": "estraverse@^1.9.1"
}