1 | import arrayMap from './_arrayMap';
|
2 | import baseIndexOf from './_baseIndexOf';
|
3 | import baseIndexOfWith from './_baseIndexOfWith';
|
4 | import baseUnary from './_baseUnary';
|
5 |
|
6 |
|
7 | var arrayProto = Array.prototype;
|
8 |
|
9 |
|
10 | var splice = arrayProto.splice;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function basePullAll(array, values, iteratee, comparator) {
|
24 | var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
|
25 | index = -1,
|
26 | length = values.length,
|
27 | seen = array;
|
28 |
|
29 | if (iteratee) {
|
30 | seen = arrayMap(array, baseUnary(iteratee));
|
31 | }
|
32 | while (++index < length) {
|
33 | var fromIndex = 0,
|
34 | value = values[index],
|
35 | computed = iteratee ? iteratee(value) : value;
|
36 |
|
37 | while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
|
38 | if (seen !== array) {
|
39 | splice.call(seen, fromIndex, 1);
|
40 | }
|
41 | splice.call(array, fromIndex, 1);
|
42 | }
|
43 | }
|
44 | return array;
|
45 | }
|
46 |
|
47 | export default basePullAll;
|