pullAll.js 710 B

123456789101112131415161718192021222324252627282930
  1. var basePullAll = require('./_basePullAll');
  2. /**
  3. * This method is like `_.pull` except that it accepts an array of values to remove.
  4. *
  5. * **Note:** Unlike `_.difference`, this method mutates `array`.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 4.0.0
  10. * @category Array
  11. * @param {Array} array The array to modify.
  12. * @param {Array} values The values to remove.
  13. * @returns {Array} Returns `array`.
  14. * @example
  15. *
  16. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  17. *
  18. * _.pullAll(array, ['a', 'c']);
  19. * console.log(array);
  20. * // => ['b', 'b']
  21. */
  22. function pullAll(array, values) {
  23. return (array && array.length && values && values.length)
  24. ? basePullAll(array, values)
  25. : array;
  26. }
  27. module.exports = pullAll;