1 | var arrayMap = require('./_arrayMap'),
|
2 | baseIndexOf = require('./_baseIndexOf'),
|
3 | baseIndexOfWith = require('./_baseIndexOfWith'),
|
4 | baseUnary = require('./_baseUnary'),
|
5 | copyArray = require('./_copyArray');
|
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 |
|
23 |
|
24 | function basePullAll(array, values, iteratee, comparator) {
|
25 | var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
|
26 | index = -1,
|
27 | length = values.length,
|
28 | seen = array;
|
29 |
|
30 | if (array === values) {
|
31 | values = copyArray(values);
|
32 | }
|
33 | if (iteratee) {
|
34 | seen = arrayMap(array, baseUnary(iteratee));
|
35 | }
|
36 | while (++index < length) {
|
37 | var fromIndex = 0,
|
38 | value = values[index],
|
39 | computed = iteratee ? iteratee(value) : value;
|
40 |
|
41 | while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
|
42 | if (seen !== array) {
|
43 | splice.call(seen, fromIndex, 1);
|
44 | }
|
45 | splice.call(array, fromIndex, 1);
|
46 | }
|
47 | }
|
48 | return array;
|
49 | }
|
50 |
|
51 | module.exports = basePullAll;
|