main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
937 bytes
|
Line | |
---|
1 | import baseUnset from './_baseUnset.js';
|
---|
2 | import isIndex from './_isIndex.js';
|
---|
3 |
|
---|
4 | /** Used for built-in method references. */
|
---|
5 | var arrayProto = Array.prototype;
|
---|
6 |
|
---|
7 | /** Built-in value references. */
|
---|
8 | var splice = arrayProto.splice;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * The base implementation of `_.pullAt` without support for individual
|
---|
12 | * indexes or capturing the removed elements.
|
---|
13 | *
|
---|
14 | * @private
|
---|
15 | * @param {Array} array The array to modify.
|
---|
16 | * @param {number[]} indexes The indexes of elements to remove.
|
---|
17 | * @returns {Array} Returns `array`.
|
---|
18 | */
|
---|
19 | function basePullAt(array, indexes) {
|
---|
20 | var length = array ? indexes.length : 0,
|
---|
21 | lastIndex = length - 1;
|
---|
22 |
|
---|
23 | while (length--) {
|
---|
24 | var index = indexes[length];
|
---|
25 | if (length == lastIndex || index !== previous) {
|
---|
26 | var previous = index;
|
---|
27 | if (isIndex(index)) {
|
---|
28 | splice.call(array, index, 1);
|
---|
29 | } else {
|
---|
30 | baseUnset(array, index);
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|
34 | return array;
|
---|
35 | }
|
---|
36 |
|
---|
37 | export default basePullAt;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.