Sha256: a74e2434b9a73146842de0b583154b75bd4c50440090d5b1f852d6931312cd50

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.remove = remove;
exports._removeFromScope = _removeFromScope;
exports._callRemovalHooks = _callRemovalHooks;
exports._remove = _remove;
exports._markRemoved = _markRemoved;
exports._assertUnremoved = _assertUnremoved;

var _removalHooks = require("./lib/removal-hooks");

function remove() {
  this._assertUnremoved();

  this.resync();

  this._removeFromScope();

  if (this._callRemovalHooks()) {
    this._markRemoved();

    return;
  }

  this.shareCommentsWithSiblings();

  this._remove();

  this._markRemoved();
}

function _removeFromScope() {
  const bindings = this.getBindingIdentifiers();
  Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
}

function _callRemovalHooks() {
  for (const fn of _removalHooks.hooks) {
    if (fn(this, this.parentPath)) return true;
  }
}

function _remove() {
  if (Array.isArray(this.container)) {
    this.container.splice(this.key, 1);
    this.updateSiblingKeys(this.key, -1);
  } else {
    this._replaceWith(null);
  }
}

function _markRemoved() {
  this.shouldSkip = true;
  this.removed = true;
  this.node = null;
}

function _assertUnremoved() {
  if (this.removed) {
    throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
  }
}

Version data entries

13 entries across 13 versions & 5 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/@babel/traverse/lib/path/removal.js
disco_app-0.18.2 test/dummy/node_modules/@babel/traverse/lib/path/removal.js
condenser-0.0.8 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js
learn_create-0.0.22 lib/templates/javascript_lab_template/node_modules/@babel/traverse/lib/path/removal.js
jester-data-8.0.0 node_modules/@babel/traverse/lib/path/removal.js
ezii-os-5.2.1 node_modules/@babel/traverse/lib/path/removal.js
ezii-os-2.0.1 node_modules/@babel/traverse/lib/path/removal.js
ezii-os-1.1.0 node_modules/@babel/traverse/lib/path/removal.js
ezii-os-1.0.0 node_modules/@babel/traverse/lib/path/removal.js
condenser-0.0.7 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js
ezii-os-0.0.0.1.0 node_modules/@babel/traverse/lib/path/removal.js
ezii-os-0.0.0.0.1 node_modules/@babel/traverse/lib/path/removal.js
condenser-0.0.5 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js