@babel/traverse 7.0.0-beta.31

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.

@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+
6
+ var t = _interopRequireWildcard(require("@babel/types"));
7
+
8
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
9
+
10
+ var referenceVisitor = {
11
+ ReferencedIdentifier: function ReferencedIdentifier(path, state) {
12
+ if (path.isJSXIdentifier() && t.react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
13
+ return;
14
+ }
15
+
16
+ if (path.node.name === "this") {
17
+ var scope = path.scope;
18
+
19
+ do {
20
+ if (scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) {
21
+ break;
22
+ }
23
+ } while (scope = scope.parent);
24
+
25
+ if (scope) state.breakOnScopePaths.push(scope.path);
26
+ }
27
+
28
+ var binding = path.scope.getBinding(path.node.name);
29
+ if (!binding) return;
30
+ if (binding !== state.scope.getBinding(path.node.name)) return;
31
+ state.bindings[path.node.name] = binding;
32
+ }
33
+ };
34
+
35
+ var PathHoister = function () {
36
+ function PathHoister(path, scope) {
37
+ this.breakOnScopePaths = [];
38
+ this.bindings = {};
39
+ this.scopes = [];
40
+ this.scope = scope;
41
+ this.path = path;
42
+ this.attachAfter = false;
43
+ }
44
+
45
+ var _proto = PathHoister.prototype;
46
+
47
+ _proto.isCompatibleScope = function isCompatibleScope(scope) {
48
+ for (var key in this.bindings) {
49
+ var binding = this.bindings[key];
50
+
51
+ if (!scope.bindingIdentifierEquals(key, binding.identifier)) {
52
+ return false;
53
+ }
54
+ }
55
+
56
+ return true;
57
+ };
58
+
59
+ _proto.getCompatibleScopes = function getCompatibleScopes() {
60
+ var scope = this.path.scope;
61
+
62
+ do {
63
+ if (this.isCompatibleScope(scope)) {
64
+ this.scopes.push(scope);
65
+ } else {
66
+ break;
67
+ }
68
+
69
+ if (this.breakOnScopePaths.indexOf(scope.path) >= 0) {
70
+ break;
71
+ }
72
+ } while (scope = scope.parent);
73
+ };
74
+
75
+ _proto.getAttachmentPath = function getAttachmentPath() {
76
+ var path = this._getAttachmentPath();
77
+
78
+ if (!path) return;
79
+ var targetScope = path.scope;
80
+
81
+ if (targetScope.path === path) {
82
+ targetScope = path.scope.parent;
83
+ }
84
+
85
+ if (targetScope.path.isProgram() || targetScope.path.isFunction()) {
86
+ for (var name in this.bindings) {
87
+ if (!targetScope.hasOwnBinding(name)) continue;
88
+ var binding = this.bindings[name];
89
+
90
+ if (binding.kind === "param" || binding.path.parentKey === "params") {
91
+ continue;
92
+ }
93
+
94
+ var bindingParentPath = this.getAttachmentParentForPath(binding.path);
95
+
96
+ if (bindingParentPath.key >= path.key) {
97
+ this.attachAfter = true;
98
+ path = binding.path;
99
+ var _arr = binding.constantViolations;
100
+
101
+ for (var _i = 0; _i < _arr.length; _i++) {
102
+ var violationPath = _arr[_i];
103
+
104
+ if (this.getAttachmentParentForPath(violationPath).key > path.key) {
105
+ path = violationPath;
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ if (path.parentPath.isExportDeclaration()) {
113
+ path = path.parentPath;
114
+ }
115
+
116
+ return path;
117
+ };
118
+
119
+ _proto._getAttachmentPath = function _getAttachmentPath() {
120
+ var scopes = this.scopes;
121
+ var scope = scopes.pop();
122
+ if (!scope) return;
123
+
124
+ if (scope.path.isFunction()) {
125
+ if (this.hasOwnParamBindings(scope)) {
126
+ if (this.scope === scope) return;
127
+ var bodies = scope.path.get("body").get("body");
128
+
129
+ for (var i = 0; i < bodies.length; i++) {
130
+ if (bodies[i].node._blockHoist) continue;
131
+ return bodies[i];
132
+ }
133
+ } else {
134
+ return this.getNextScopeAttachmentParent();
135
+ }
136
+ } else if (scope.path.isProgram()) {
137
+ return this.getNextScopeAttachmentParent();
138
+ }
139
+ };
140
+
141
+ _proto.getNextScopeAttachmentParent = function getNextScopeAttachmentParent() {
142
+ var scope = this.scopes.pop();
143
+ if (scope) return this.getAttachmentParentForPath(scope.path);
144
+ };
145
+
146
+ _proto.getAttachmentParentForPath = function getAttachmentParentForPath(path) {
147
+ do {
148
+ if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
149
+ return path;
150
+ }
151
+ } while (path = path.parentPath);
152
+ };
153
+
154
+ _proto.hasOwnParamBindings = function hasOwnParamBindings(scope) {
155
+ for (var name in this.bindings) {
156
+ if (!scope.hasOwnBinding(name)) continue;
157
+ var binding = this.bindings[name];
158
+ if (binding.kind === "param" && binding.constant) return true;
159
+ }
160
+
161
+ return false;
162
+ };
163
+
164
+ _proto.run = function run() {
165
+ this.path.traverse(referenceVisitor, this);
166
+ this.getCompatibleScopes();
167
+ var attachTo = this.getAttachmentPath();
168
+ if (!attachTo) return;
169
+ if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
170
+ var uid = attachTo.scope.generateUidIdentifier("ref");
171
+ var declarator = t.variableDeclarator(uid, this.path.node);
172
+ var insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
173
+ attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t.variableDeclaration("var", [declarator])]);
174
+ var parent = this.path.parentPath;
175
+
176
+ if (parent.isJSXElement() && this.path.container === parent.node.children) {
177
+ uid = t.JSXExpressionContainer(uid);
178
+ }
179
+
180
+ this.path.replaceWith(uid);
181
+ };
182
+
183
+ return PathHoister;
184
+ }();
185
+
186
+ exports.default = PathHoister;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.hooks = void 0;
5
+ var hooks = [function (self, parent) {
6
+ var removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement();
7
+
8
+ if (removeParent) {
9
+ parent.remove();
10
+ return true;
11
+ }
12
+ }, function (self, parent) {
13
+ if (parent.isSequenceExpression() && parent.node.expressions.length === 1) {
14
+ parent.replaceWith(parent.node.expressions[0]);
15
+ return true;
16
+ }
17
+ }, function (self, parent) {
18
+ if (parent.isBinary()) {
19
+ if (self.key === "left") {
20
+ parent.replaceWith(parent.node.right);
21
+ } else {
22
+ parent.replaceWith(parent.node.left);
23
+ }
24
+
25
+ return true;
26
+ }
27
+ }, function (self, parent) {
28
+ if (parent.isIfStatement() && (self.key === "consequent" || self.key === "alternate") || self.key === "body" && (parent.isLoop() || parent.isArrowFunctionExpression())) {
29
+ self.replaceWith({
30
+ type: "BlockStatement",
31
+ body: []
32
+ });
33
+ return true;
34
+ }
35
+ }];
36
+ exports.hooks = hooks;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.ForAwaitStatement = exports.NumericLiteralTypeAnnotation = exports.ExistentialTypeParam = exports.SpreadProperty = exports.RestProperty = exports.Flow = exports.Pure = exports.Generated = exports.User = exports.Var = exports.BlockScoped = exports.Referenced = exports.Scope = exports.Expression = exports.Statement = exports.BindingIdentifier = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = void 0;
5
+
6
+ var t = _interopRequireWildcard(require("@babel/types"));
7
+
8
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
9
+
10
+ var ReferencedIdentifier = {
11
+ types: ["Identifier", "JSXIdentifier"],
12
+ checkPath: function checkPath(_ref, opts) {
13
+ var node = _ref.node,
14
+ parent = _ref.parent;
15
+
16
+ if (!t.isIdentifier(node, opts) && !t.isJSXMemberExpression(parent, opts)) {
17
+ if (t.isJSXIdentifier(node, opts)) {
18
+ if (t.react.isCompatTag(node.name)) return false;
19
+ } else {
20
+ return false;
21
+ }
22
+ }
23
+
24
+ return t.isReferenced(node, parent);
25
+ }
26
+ };
27
+ exports.ReferencedIdentifier = ReferencedIdentifier;
28
+ var ReferencedMemberExpression = {
29
+ types: ["MemberExpression"],
30
+ checkPath: function checkPath(_ref2) {
31
+ var node = _ref2.node,
32
+ parent = _ref2.parent;
33
+ return t.isMemberExpression(node) && t.isReferenced(node, parent);
34
+ }
35
+ };
36
+ exports.ReferencedMemberExpression = ReferencedMemberExpression;
37
+ var BindingIdentifier = {
38
+ types: ["Identifier"],
39
+ checkPath: function checkPath(_ref3) {
40
+ var node = _ref3.node,
41
+ parent = _ref3.parent;
42
+ return t.isIdentifier(node) && t.isBinding(node, parent);
43
+ }
44
+ };
45
+ exports.BindingIdentifier = BindingIdentifier;
46
+ var Statement = {
47
+ types: ["Statement"],
48
+ checkPath: function checkPath(_ref4) {
49
+ var node = _ref4.node,
50
+ parent = _ref4.parent;
51
+
52
+ if (t.isStatement(node)) {
53
+ if (t.isVariableDeclaration(node)) {
54
+ if (t.isForXStatement(parent, {
55
+ left: node
56
+ })) return false;
57
+ if (t.isForStatement(parent, {
58
+ init: node
59
+ })) return false;
60
+ }
61
+
62
+ return true;
63
+ } else {
64
+ return false;
65
+ }
66
+ }
67
+ };
68
+ exports.Statement = Statement;
69
+ var Expression = {
70
+ types: ["Expression"],
71
+ checkPath: function checkPath(path) {
72
+ if (path.isIdentifier()) {
73
+ return path.isReferencedIdentifier();
74
+ } else {
75
+ return t.isExpression(path.node);
76
+ }
77
+ }
78
+ };
79
+ exports.Expression = Expression;
80
+ var Scope = {
81
+ types: ["Scopable"],
82
+ checkPath: function checkPath(path) {
83
+ return t.isScope(path.node, path.parent);
84
+ }
85
+ };
86
+ exports.Scope = Scope;
87
+ var Referenced = {
88
+ checkPath: function checkPath(path) {
89
+ return t.isReferenced(path.node, path.parent);
90
+ }
91
+ };
92
+ exports.Referenced = Referenced;
93
+ var BlockScoped = {
94
+ checkPath: function checkPath(path) {
95
+ return t.isBlockScoped(path.node);
96
+ }
97
+ };
98
+ exports.BlockScoped = BlockScoped;
99
+ var Var = {
100
+ types: ["VariableDeclaration"],
101
+ checkPath: function checkPath(path) {
102
+ return t.isVar(path.node);
103
+ }
104
+ };
105
+ exports.Var = Var;
106
+ var User = {
107
+ checkPath: function checkPath(path) {
108
+ return path.node && !!path.node.loc;
109
+ }
110
+ };
111
+ exports.User = User;
112
+ var Generated = {
113
+ checkPath: function checkPath(path) {
114
+ return !path.isUser();
115
+ }
116
+ };
117
+ exports.Generated = Generated;
118
+ var Pure = {
119
+ checkPath: function checkPath(path, opts) {
120
+ return path.scope.isPure(path.node, opts);
121
+ }
122
+ };
123
+ exports.Pure = Pure;
124
+ var Flow = {
125
+ types: ["Flow", "ImportDeclaration", "ExportDeclaration", "ImportSpecifier"],
126
+ checkPath: function checkPath(_ref5) {
127
+ var node = _ref5.node;
128
+
129
+ if (t.isFlow(node)) {
130
+ return true;
131
+ } else if (t.isImportDeclaration(node)) {
132
+ return node.importKind === "type" || node.importKind === "typeof";
133
+ } else if (t.isExportDeclaration(node)) {
134
+ return node.exportKind === "type";
135
+ } else if (t.isImportSpecifier(node)) {
136
+ return node.importKind === "type" || node.importKind === "typeof";
137
+ } else {
138
+ return false;
139
+ }
140
+ }
141
+ };
142
+ exports.Flow = Flow;
143
+ var RestProperty = {
144
+ types: ["RestElement"],
145
+ checkPath: function checkPath(path) {
146
+ return path.parentPath && path.parentPath.isObjectPattern();
147
+ }
148
+ };
149
+ exports.RestProperty = RestProperty;
150
+ var SpreadProperty = {
151
+ types: ["RestElement"],
152
+ checkPath: function checkPath(path) {
153
+ return path.parentPath && path.parentPath.isObjectExpression();
154
+ }
155
+ };
156
+ exports.SpreadProperty = SpreadProperty;
157
+ var ExistentialTypeParam = {
158
+ types: ["ExistsTypeAnnotation"]
159
+ };
160
+ exports.ExistentialTypeParam = ExistentialTypeParam;
161
+ var NumericLiteralTypeAnnotation = {
162
+ types: ["NumberLiteralTypeAnnotation"]
163
+ };
164
+ exports.NumericLiteralTypeAnnotation = NumericLiteralTypeAnnotation;
165
+ var ForAwaitStatement = {
166
+ types: ["ForOfStatement"],
167
+ checkPath: function checkPath(_ref6) {
168
+ var node = _ref6.node;
169
+ return node.await === true;
170
+ }
171
+ };
172
+ exports.ForAwaitStatement = ForAwaitStatement;
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.insertBefore = insertBefore;
5
+ exports._containerInsert = _containerInsert;
6
+ exports._containerInsertBefore = _containerInsertBefore;
7
+ exports._containerInsertAfter = _containerInsertAfter;
8
+ exports.insertAfter = insertAfter;
9
+ exports.updateSiblingKeys = updateSiblingKeys;
10
+ exports._verifyNodeList = _verifyNodeList;
11
+ exports.unshiftContainer = unshiftContainer;
12
+ exports.pushContainer = pushContainer;
13
+ exports.hoist = hoist;
14
+
15
+ var _cache = require("../cache");
16
+
17
+ var _hoister = _interopRequireDefault(require("./lib/hoister"));
18
+
19
+ var _index = _interopRequireDefault(require("./index"));
20
+
21
+ var t = _interopRequireWildcard(require("@babel/types"));
22
+
23
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
24
+
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+
27
+ function insertBefore(nodes) {
28
+ this._assertUnremoved();
29
+
30
+ nodes = this._verifyNodeList(nodes);
31
+
32
+ if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) {
33
+ return this.parentPath.insertBefore(nodes);
34
+ } else if (this.isNodeType("Expression") && this.listKey !== "params" && this.listKey !== "arguments" || this.parentPath.isForStatement() && this.key === "init") {
35
+ if (this.node) nodes.push(this.node);
36
+ return this.replaceExpressionWithStatements(nodes);
37
+ } else if (Array.isArray(this.container)) {
38
+ return this._containerInsertBefore(nodes);
39
+ } else if (this.isStatementOrBlock()) {
40
+ var shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null);
41
+ this.replaceWith(t.blockStatement(shouldInsertCurrentNode ? [this.node] : []));
42
+ return this.unshiftContainer("body", nodes);
43
+ } else {
44
+ throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
45
+ }
46
+ }
47
+
48
+ function _containerInsert(from, nodes) {
49
+ var _container;
50
+
51
+ this.updateSiblingKeys(from, nodes.length);
52
+ var paths = [];
53
+
54
+ (_container = this.container).splice.apply(_container, [from, 0].concat(nodes));
55
+
56
+ for (var i = 0; i < nodes.length; i++) {
57
+ var to = from + i;
58
+ var path = this.getSibling("" + to);
59
+ paths.push(path);
60
+
61
+ if (this.context && this.context.queue) {
62
+ path.pushContext(this.context);
63
+ }
64
+ }
65
+
66
+ var contexts = this._getQueueContexts();
67
+
68
+ for (var _i = 0; _i < paths.length; _i++) {
69
+ var _path = paths[_i];
70
+
71
+ _path.setScope();
72
+
73
+ _path.debug("Inserted.");
74
+
75
+ for (var _iterator = contexts, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
76
+ var _ref;
77
+
78
+ if (_isArray) {
79
+ if (_i2 >= _iterator.length) break;
80
+ _ref = _iterator[_i2++];
81
+ } else {
82
+ _i2 = _iterator.next();
83
+ if (_i2.done) break;
84
+ _ref = _i2.value;
85
+ }
86
+
87
+ var _context = _ref;
88
+
89
+ _context.maybeQueue(_path, true);
90
+ }
91
+ }
92
+
93
+ return paths;
94
+ }
95
+
96
+ function _containerInsertBefore(nodes) {
97
+ return this._containerInsert(this.key, nodes);
98
+ }
99
+
100
+ function _containerInsertAfter(nodes) {
101
+ return this._containerInsert(this.key + 1, nodes);
102
+ }
103
+
104
+ function insertAfter(nodes) {
105
+ this._assertUnremoved();
106
+
107
+ nodes = this._verifyNodeList(nodes);
108
+
109
+ if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) {
110
+ return this.parentPath.insertAfter(nodes);
111
+ } else if (this.isNodeType("Expression") || this.parentPath.isForStatement() && this.key === "init") {
112
+ if (this.node) {
113
+ var temp = this.scope.generateDeclaredUidIdentifier();
114
+ nodes.unshift(t.expressionStatement(t.assignmentExpression("=", temp, this.node)));
115
+ nodes.push(t.expressionStatement(temp));
116
+ }
117
+
118
+ return this.replaceExpressionWithStatements(nodes);
119
+ } else if (Array.isArray(this.container)) {
120
+ return this._containerInsertAfter(nodes);
121
+ } else if (this.isStatementOrBlock()) {
122
+ var shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null);
123
+ this.replaceWith(t.blockStatement(shouldInsertCurrentNode ? [this.node] : []));
124
+ return this.pushContainer("body", nodes);
125
+ } else {
126
+ throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
127
+ }
128
+ }
129
+
130
+ function updateSiblingKeys(fromIndex, incrementBy) {
131
+ if (!this.parent) return;
132
+
133
+ var paths = _cache.path.get(this.parent);
134
+
135
+ for (var i = 0; i < paths.length; i++) {
136
+ var path = paths[i];
137
+
138
+ if (path.key >= fromIndex) {
139
+ path.key += incrementBy;
140
+ }
141
+ }
142
+ }
143
+
144
+ function _verifyNodeList(nodes) {
145
+ if (!nodes) {
146
+ return [];
147
+ }
148
+
149
+ if (nodes.constructor !== Array) {
150
+ nodes = [nodes];
151
+ }
152
+
153
+ for (var i = 0; i < nodes.length; i++) {
154
+ var node = nodes[i];
155
+ var msg = void 0;
156
+
157
+ if (!node) {
158
+ msg = "has falsy node";
159
+ } else if (typeof node !== "object") {
160
+ msg = "contains a non-object node";
161
+ } else if (!node.type) {
162
+ msg = "without a type";
163
+ } else if (node instanceof _index.default) {
164
+ msg = "has a NodePath when it expected a raw object";
165
+ }
166
+
167
+ if (msg) {
168
+ var type = Array.isArray(node) ? "array" : typeof node;
169
+ throw new Error("Node list " + msg + " with the index of " + i + " and type of " + type);
170
+ }
171
+ }
172
+
173
+ return nodes;
174
+ }
175
+
176
+ function unshiftContainer(listKey, nodes) {
177
+ this._assertUnremoved();
178
+
179
+ nodes = this._verifyNodeList(nodes);
180
+
181
+ var path = _index.default.get({
182
+ parentPath: this,
183
+ parent: this.node,
184
+ container: this.node[listKey],
185
+ listKey: listKey,
186
+ key: 0
187
+ });
188
+
189
+ return path.insertBefore(nodes);
190
+ }
191
+
192
+ function pushContainer(listKey, nodes) {
193
+ this._assertUnremoved();
194
+
195
+ nodes = this._verifyNodeList(nodes);
196
+ var container = this.node[listKey];
197
+
198
+ var path = _index.default.get({
199
+ parentPath: this,
200
+ parent: this.node,
201
+ container: container,
202
+ listKey: listKey,
203
+ key: container.length
204
+ });
205
+
206
+ return path.replaceWithMultiple(nodes);
207
+ }
208
+
209
+ function hoist(scope) {
210
+ if (scope === void 0) {
211
+ scope = this.scope;
212
+ }
213
+
214
+ var hoister = new _hoister.default(this, scope);
215
+ return hoister.run();
216
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.remove = remove;
5
+ exports._callRemovalHooks = _callRemovalHooks;
6
+ exports._remove = _remove;
7
+ exports._markRemoved = _markRemoved;
8
+ exports._assertUnremoved = _assertUnremoved;
9
+
10
+ var _removalHooks = require("./lib/removal-hooks");
11
+
12
+ function remove() {
13
+ this._assertUnremoved();
14
+
15
+ this.resync();
16
+
17
+ if (this._callRemovalHooks()) {
18
+ this._markRemoved();
19
+
20
+ return;
21
+ }
22
+
23
+ this.shareCommentsWithSiblings();
24
+
25
+ this._remove();
26
+
27
+ this._markRemoved();
28
+ }
29
+
30
+ function _callRemovalHooks() {
31
+ var _arr = _removalHooks.hooks;
32
+
33
+ for (var _i = 0; _i < _arr.length; _i++) {
34
+ var fn = _arr[_i];
35
+ if (fn(this, this.parentPath)) return true;
36
+ }
37
+ }
38
+
39
+ function _remove() {
40
+ if (Array.isArray(this.container)) {
41
+ this.container.splice(this.key, 1);
42
+ this.updateSiblingKeys(this.key, -1);
43
+ } else {
44
+ this._replaceWith(null);
45
+ }
46
+ }
47
+
48
+ function _markRemoved() {
49
+ this.shouldSkip = true;
50
+ this.removed = true;
51
+ this.node = null;
52
+ }
53
+
54
+ function _assertUnremoved() {
55
+ if (this.removed) {
56
+ throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
57
+ }
58
+ }