79f1acf484cf591df18fe099449ad7a7fb973fb5d46fddac0c0572c97671ce7b8f9e4c25a268b7a14b14e41683925fe0553a166a4d6e3a508bc928632327d6 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. var baseDifference = require('./_baseDifference'),
  2. baseFlatten = require('./_baseFlatten'),
  3. baseRest = require('./_baseRest'),
  4. isArrayLikeObject = require('./isArrayLikeObject');
  5. /**
  6. * Creates an array of `array` values not included in the other given arrays
  7. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8. * for equality comparisons. The order and references of result values are
  9. * determined by the first array.
  10. *
  11. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  12. *
  13. * @static
  14. * @memberOf _
  15. * @since 0.1.0
  16. * @category Array
  17. * @param {Array} array The array to inspect.
  18. * @param {...Array} [values] The values to exclude.
  19. * @returns {Array} Returns the new array of filtered values.
  20. * @see _.without, _.xor
  21. * @example
  22. *
  23. * _.difference([2, 1], [2, 3]);
  24. * // => [1]
  25. */
  26. var difference = baseRest(function(array, values) {
  27. return isArrayLikeObject(array)
  28. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  29. : [];
  30. });
  31. module.exports = difference;