-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
Copy pathbasePullAt.js
34 lines (29 loc) · 972 Bytes
/
basePullAt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
define(['./baseAt', './baseCompareAscending', './isIndex'], function(baseAt, baseCompareAscending, isIndex) {
/** Used for native method references. */
var arrayProto = Array.prototype;
/** Native method references. */
var splice = arrayProto.splice;
/**
* The base implementation of `_.pullAt` without support for individual
* index arguments.
*
* @private
* @param {Array} array The array to modify.
* @param {number[]} indexes The indexes of elements to remove.
* @returns {Array} Returns the new array of removed elements.
*/
function basePullAt(array, indexes) {
var length = indexes.length,
result = baseAt(array, indexes);
indexes.sort(baseCompareAscending);
while (length--) {
var index = parseFloat(indexes[length]);
if (index != previous && isIndex(index)) {
var previous = index;
splice.call(array, index, 1);
}
}
return result;
}
return basePullAt;
});