Sha256: bc72d8c5d3eb8fa5b0bde71cb82a7efc3e4a3a3162e453b03497c1cbe7e3f258

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 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");

var _index = require("./index");

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._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
  this.node = null;
}

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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
enju_library-0.3.8 spec/dummy/node_modules/@babel/traverse/lib/path/removal.js
condenser-0.2 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js
condenser-0.1 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js
condenser-0.0.12 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js
condenser-0.0.11 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js
condenser-0.0.10 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js
condenser-0.0.9 lib/condenser/processors/node_modules/@babel/traverse/lib/path/removal.js