@newdash/newdash
Version:
javascript/typescript utility library
34 lines (33 loc) • 1.16 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const baseUnset_1 = __importDefault(require("./baseUnset"));
const isIndex_1 = __importDefault(require("./isIndex"));
/**
* The base implementation of `pullAt` without support for individual
* indexes or capturing the removed elements.
*
* @private
* @param {Array} array The array to modify.
* @param {number[]} indexes The indexes of elements to remove.
* @returns {Array} Returns `array`.
*/
function basePullAt(array, indexes) {
var length = array ? indexes.length : 0, lastIndex = length - 1;
while (length--) {
var index = indexes[length];
if (length == lastIndex || index !== previous) {
var previous = index;
if ((0, isIndex_1.default)(index)) {
Array.prototype.splice.call(array, index, 1);
}
else {
(0, baseUnset_1.default)(array, index);
}
}
}
return array;
}
exports.default = basePullAt;