without.js 858 B

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