SIGN IN SIGN UP

A modern JavaScript utility library delivering modularity, performance, & extras.

0 0 9 JavaScript
2016-11-15 22:20:52 -08:00
define(['./_baseUnset', './_isIndex'], function(baseUnset, isIndex) {
2015-12-16 17:49:35 -08:00
2015-12-16 17:53:20 -08:00
/** Used for built-in method references. */
2015-12-16 17:49:35 -08:00
var arrayProto = Array.prototype;
2015-12-16 17:53:20 -08:00
/** Built-in value references. */
2015-12-16 17:49:35 -08:00
var splice = arrayProto.splice;
/**
* The base implementation of `_.pullAt` without support for individual
2015-12-16 17:53:20 -08:00
* indexes or capturing the removed elements.
2015-12-16 17:49:35 -08:00
*
* @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) {
2015-12-16 17:53:20 -08:00
var length = array ? indexes.length : 0,
lastIndex = length - 1;
2015-12-16 17:49:35 -08:00
while (length--) {
2015-12-16 17:50:42 -08:00
var index = indexes[length];
2016-04-19 22:17:16 -07:00
if (length == lastIndex || index !== previous) {
2015-12-16 17:49:35 -08:00
var previous = index;
2015-12-16 17:53:20 -08:00
if (isIndex(index)) {
splice.call(array, index, 1);
2016-11-15 22:20:52 -08:00
} else {
baseUnset(array, index);
2015-12-16 17:53:20 -08:00
}
2015-12-16 17:49:35 -08:00
}
}
return array;
}
return basePullAt;
});