1 var baseIndexOf = require('./baseIndexOf'),
2 cacheIndexOf = require('./cacheIndexOf'),
3 createCache = require('./createCache');
5 /** Used as the size to enable large array optimizations. */
6 var LARGE_ARRAY_SIZE = 200;
9 * The base implementation of `_.difference` which accepts a single array
10 * of values to exclude.
13 * @param {Array} array The array to inspect.
14 * @param {Array} values The values to exclude.
15 * @returns {Array} Returns the new array of filtered values.
17 function baseDifference(array, values) {
18 var length = array ? array.length : 0,
25 indexOf = baseIndexOf,
27 cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,
28 valuesLength = values.length;
31 indexOf = cacheIndexOf;
36 while (++index < length) {
37 var value = array[index];
39 if (isCommon && value === value) {
40 var valuesIndex = valuesLength;
41 while (valuesIndex--) {
42 if (values[valuesIndex] === value) {
48 else if (indexOf(values, value, 0) < 0) {
55 module.exports = baseDifference;