1 | import baseCastPath from './_baseCastPath';
|
2 | import isIndex from './_isIndex';
|
3 | import isKey from './_isKey';
|
4 | import last from './last';
|
5 | import parent from './_parent';
|
6 |
|
7 |
|
8 | var arrayProto = Array.prototype;
|
9 |
|
10 |
|
11 | var splice = arrayProto.splice;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function basePullAt(array, indexes) {
|
23 | var length = array ? indexes.length : 0,
|
24 | lastIndex = length - 1;
|
25 |
|
26 | while (length--) {
|
27 | var index = indexes[length];
|
28 | if (lastIndex == length || index != previous) {
|
29 | var previous = index;
|
30 | if (isIndex(index)) {
|
31 | splice.call(array, index, 1);
|
32 | }
|
33 | else if (!isKey(index, array)) {
|
34 | var path = baseCastPath(index),
|
35 | object = parent(array, path);
|
36 |
|
37 | if (object != null) {
|
38 | delete object[last(path)];
|
39 | }
|
40 | }
|
41 | else {
|
42 | delete array[index];
|
43 | }
|
44 | }
|
45 | }
|
46 | return array;
|
47 | }
|
48 |
|
49 | export default basePullAt;
|