You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.0 KiB

преди 3 години
  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;