123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import arrayMap from './_arrayMap.js';
- import baseIndexOf from './_baseIndexOf.js';
- import baseIndexOfWith from './_baseIndexOfWith.js';
- import baseUnary from './_baseUnary.js';
- import copyArray from './_copyArray.js';
- var arrayProto = Array.prototype;
- var splice = arrayProto.splice;
- function basePullAll(array, values, iteratee, comparator) {
- var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
- index = -1,
- length = values.length,
- seen = array;
- if (array === values) {
- values = copyArray(values);
- }
- if (iteratee) {
- seen = arrayMap(array, baseUnary(iteratee));
- }
- while (++index < length) {
- var fromIndex = 0,
- value = values[index],
- computed = iteratee ? iteratee(value) : value;
- while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
- if (seen !== array) {
- splice.call(seen, fromIndex, 1);
- }
- splice.call(array, fromIndex, 1);
- }
- }
- return array;
- }
- export default basePullAll;
|