Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / escodegen / node_modules / estraverse / README.md
1 ### Estraverse [![Build Status](https://secure.travis-ci.org/estools/estraverse.png)](http://travis-ci.org/estools/estraverse)
2
3 Estraverse ([estraverse](http://github.com/estools/estraverse)) is
4 [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
5 traversal functions from [esmangle project](http://github.com/estools/esmangle).
6
7 ### Documentation
8
9 You can find usage docs at [wiki page](https://github.com/estools/estraverse/wiki/Usage).
10
11 ### Example Usage
12
13 The following code will output all variables declared at the root of a file.
14
15 ```javascript
16 estraverse.traverse(ast, {
17     enter: function (node, parent) {
18         if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')
19             return estraverse.VisitorOption.Skip;
20     },
21     leave: function (node, parent) {
22         if (node.type == 'VariableDeclarator')
23           console.log(node.id.name);
24     }
25 });
26 ```
27
28 We can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break.
29
30 ```javascript
31 estraverse.traverse(ast, {
32     enter: function (node) {
33         this.break();
34     }
35 });
36 ```
37
38 And estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.
39
40 ```javascript
41 result = estraverse.replace(tree, {
42     enter: function (node) {
43         // Replace it with replaced.
44         if (node.type === 'Literal')
45             return replaced;
46     }
47 });
48 ```
49
50 By passing `visitor.keys` mapping, we can extend estraverse traversing functionality.
51
52 ```javascript
53 // This tree contains a user-defined `TestExpression` node.
54 var tree = {
55     type: 'TestExpression',
56
57     // This 'argument' is the property containing the other **node**.
58     argument: {
59         type: 'Literal',
60         value: 20
61     },
62
63     // This 'extended' is the property not containing the other **node**.
64     extended: true
65 };
66 estraverse.traverse(tree, {
67     enter: function (node) { },
68
69     // Extending the exising traversing rules.
70     keys: {
71         // TargetNodeName: [ 'keys', 'containing', 'the', 'other', '**node**' ]
72         TestExpression: ['argument']
73     }
74 });
75 ```
76
77 By passing `visitor.fallback` option, we can control the behavior when encountering unknown nodes.
78 ```javascript
79 // This tree contains a user-defined `TestExpression` node.
80 var tree = {
81     type: 'TestExpression',
82
83     // This 'argument' is the property containing the other **node**.
84     argument: {
85         type: 'Literal',
86         value: 20
87     },
88
89     // This 'extended' is the property not containing the other **node**.
90     extended: true
91 };
92 estraverse.traverse(tree, {
93     enter: function (node) { },
94
95     // Iterating the child **nodes** of unknown nodes.
96     fallback: 'iteration'
97 });
98 ```
99
100 ### License
101
102 Copyright (C) 2012-2013 [Yusuke Suzuki](http://github.com/Constellation)
103  (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
104
105 Redistribution and use in source and binary forms, with or without
106 modification, are permitted provided that the following conditions are met:
107
108   * Redistributions of source code must retain the above copyright
109     notice, this list of conditions and the following disclaimer.
110
111   * Redistributions in binary form must reproduce the above copyright
112     notice, this list of conditions and the following disclaimer in the
113     documentation and/or other materials provided with the distribution.
114
115 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
116 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
117 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
118 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
119 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
120 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
121 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
122 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
123 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
124 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.