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