@babel/traverse 7.0.0-beta.43 → 7.0.0-beta.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @babel/traverse might be problematic. Click here for more details.
- package/lib/context.js +40 -4
- package/lib/index.js +18 -6
- package/lib/path/ancestry.js +12 -4
- package/lib/path/comments.js +1 -1
- package/lib/path/context.js +26 -2
- package/lib/path/conversion.js +13 -12
- package/lib/path/evaluation.js +45 -18
- package/lib/path/family.js +5 -2
- package/lib/path/index.js +10 -7
- package/lib/path/inference/index.js +6 -2
- package/lib/path/inference/inferer-reference.js +4 -2
- package/lib/path/inference/inferers.js +3 -5
- package/lib/path/introspection.js +71 -5
- package/lib/path/lib/hoister.js +9 -3
- package/lib/path/lib/virtual-types.js +1 -1
- package/lib/path/modification.js +34 -10
- package/lib/path/removal.js +4 -1
- package/lib/path/replacement.js +20 -5
- package/lib/scope/index.js +146 -33
- package/lib/scope/lib/renamer.js +7 -11
- package/lib/visitors.js +53 -9
- package/package.json +9 -9
package/lib/visitors.js
CHANGED
@@ -12,7 +12,7 @@ var virtualTypes = _interopRequireWildcard(require("./path/lib/virtual-types"));
|
|
12
12
|
function t() {
|
13
13
|
const data = _interopRequireWildcard(require("@babel/types"));
|
14
14
|
|
15
|
-
t = function () {
|
15
|
+
t = function t() {
|
16
16
|
return data;
|
17
17
|
};
|
18
18
|
|
@@ -22,7 +22,7 @@ function t() {
|
|
22
22
|
function _clone() {
|
23
23
|
const data = _interopRequireDefault(require("lodash/clone"));
|
24
24
|
|
25
|
-
_clone = function () {
|
25
|
+
_clone = function _clone() {
|
26
26
|
return data;
|
27
27
|
};
|
28
28
|
|
@@ -44,7 +44,19 @@ function explode(visitor) {
|
|
44
44
|
const fns = visitor[nodeType];
|
45
45
|
delete visitor[nodeType];
|
46
46
|
|
47
|
-
for (
|
47
|
+
for (var _iterator = parts, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
48
|
+
var _ref;
|
49
|
+
|
50
|
+
if (_isArray) {
|
51
|
+
if (_i >= _iterator.length) break;
|
52
|
+
_ref = _iterator[_i++];
|
53
|
+
} else {
|
54
|
+
_i = _iterator.next();
|
55
|
+
if (_i.done) break;
|
56
|
+
_ref = _i.value;
|
57
|
+
}
|
58
|
+
|
59
|
+
const part = _ref;
|
48
60
|
visitor[part] = fns;
|
49
61
|
}
|
50
62
|
}
|
@@ -54,7 +66,10 @@ function explode(visitor) {
|
|
54
66
|
ensureEntranceObjects(visitor);
|
55
67
|
ensureCallbackArrays(visitor);
|
56
68
|
|
57
|
-
|
69
|
+
var _arr = Object.keys(visitor);
|
70
|
+
|
71
|
+
for (var _i2 = 0; _i2 < _arr.length; _i2++) {
|
72
|
+
const nodeType = _arr[_i2];
|
58
73
|
if (shouldIgnoreKey(nodeType)) continue;
|
59
74
|
const wrapper = virtualTypes[nodeType];
|
60
75
|
if (!wrapper) continue;
|
@@ -67,7 +82,11 @@ function explode(visitor) {
|
|
67
82
|
delete visitor[nodeType];
|
68
83
|
|
69
84
|
if (wrapper.types) {
|
70
|
-
|
85
|
+
var _arr2 = wrapper.types;
|
86
|
+
|
87
|
+
for (var _i4 = 0; _i4 < _arr2.length; _i4++) {
|
88
|
+
const type = _arr2[_i4];
|
89
|
+
|
71
90
|
if (visitor[type]) {
|
72
91
|
mergePair(visitor[type], fns);
|
73
92
|
} else {
|
@@ -93,7 +112,19 @@ function explode(visitor) {
|
|
93
112
|
if (!aliases) continue;
|
94
113
|
delete visitor[nodeType];
|
95
114
|
|
96
|
-
for (
|
115
|
+
for (var _iterator2 = aliases, _isArray2 = Array.isArray(_iterator2), _i3 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
116
|
+
var _ref2;
|
117
|
+
|
118
|
+
if (_isArray2) {
|
119
|
+
if (_i3 >= _iterator2.length) break;
|
120
|
+
_ref2 = _iterator2[_i3++];
|
121
|
+
} else {
|
122
|
+
_i3 = _iterator2.next();
|
123
|
+
if (_i3.done) break;
|
124
|
+
_ref2 = _i3.value;
|
125
|
+
}
|
126
|
+
|
127
|
+
const alias = _ref2;
|
97
128
|
const existing = visitor[alias];
|
98
129
|
|
99
130
|
if (existing) {
|
@@ -149,7 +180,20 @@ function verify(visitor) {
|
|
149
180
|
function validateVisitorMethods(path, val) {
|
150
181
|
const fns = [].concat(val);
|
151
182
|
|
152
|
-
for (
|
183
|
+
for (var _iterator3 = fns, _isArray3 = Array.isArray(_iterator3), _i5 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
|
184
|
+
var _ref3;
|
185
|
+
|
186
|
+
if (_isArray3) {
|
187
|
+
if (_i5 >= _iterator3.length) break;
|
188
|
+
_ref3 = _iterator3[_i5++];
|
189
|
+
} else {
|
190
|
+
_i5 = _iterator3.next();
|
191
|
+
if (_i5.done) break;
|
192
|
+
_ref3 = _i5.value;
|
193
|
+
}
|
194
|
+
|
195
|
+
const fn = _ref3;
|
196
|
+
|
153
197
|
if (typeof fn !== "function") {
|
154
198
|
throw new TypeError(`Non-function found defined in ${path} with type ${typeof fn}`);
|
155
199
|
}
|
@@ -189,7 +233,7 @@ function wrapWithStateOrWrapper(oldVisitor, state, wrapper) {
|
|
189
233
|
let newFn = fn;
|
190
234
|
|
191
235
|
if (state) {
|
192
|
-
newFn = function (path) {
|
236
|
+
newFn = function newFn(path) {
|
193
237
|
return fn.call(state, path, state);
|
194
238
|
};
|
195
239
|
}
|
@@ -225,7 +269,7 @@ function ensureCallbackArrays(obj) {
|
|
225
269
|
}
|
226
270
|
|
227
271
|
function wrapCheck(wrapper, fn) {
|
228
|
-
const newFn = function (path) {
|
272
|
+
const newFn = function newFn(path) {
|
229
273
|
if (wrapper.checkPath(path)) {
|
230
274
|
return fn.apply(this, arguments);
|
231
275
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babel/traverse",
|
3
|
-
"version": "7.0.0-beta.
|
3
|
+
"version": "7.0.0-beta.47",
|
4
4
|
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
5
5
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
6
6
|
"homepage": "https://babeljs.io/",
|
@@ -8,18 +8,18 @@
|
|
8
8
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-traverse",
|
9
9
|
"main": "lib/index.js",
|
10
10
|
"dependencies": {
|
11
|
-
"@babel/code-frame": "7.0.0-beta.
|
12
|
-
"@babel/generator": "7.0.0-beta.
|
13
|
-
"@babel/helper-function-name": "7.0.0-beta.
|
14
|
-
"@babel/helper-split-export-declaration": "7.0.0-beta.
|
15
|
-
"@babel/types": "7.0.0-beta.
|
16
|
-
"babylon": "7.0.0-beta.
|
11
|
+
"@babel/code-frame": "7.0.0-beta.47",
|
12
|
+
"@babel/generator": "7.0.0-beta.47",
|
13
|
+
"@babel/helper-function-name": "7.0.0-beta.47",
|
14
|
+
"@babel/helper-split-export-declaration": "7.0.0-beta.47",
|
15
|
+
"@babel/types": "7.0.0-beta.47",
|
16
|
+
"babylon": "7.0.0-beta.47",
|
17
17
|
"debug": "^3.1.0",
|
18
18
|
"globals": "^11.1.0",
|
19
19
|
"invariant": "^2.2.0",
|
20
|
-
"lodash": "^4.
|
20
|
+
"lodash": "^4.17.5"
|
21
21
|
},
|
22
22
|
"devDependencies": {
|
23
|
-
"@babel/helper-plugin-test-runner": "7.0.0-beta.
|
23
|
+
"@babel/helper-plugin-test-runner": "7.0.0-beta.47"
|
24
24
|
}
|
25
25
|
}
|