reject.js 917 B

1234567891011121314151617181920212223242526272829303132333435
  1. import _complement from "./internal/_complement.js";
  2. import _curry2 from "./internal/_curry2.js";
  3. import filter from "./filter.js";
  4. /**
  5. * The complement of [`filter`](#filter).
  6. *
  7. * Acts as a transducer if a transformer is given in list position. Filterable
  8. * objects include plain objects or any object that has a filter method such
  9. * as `Array`.
  10. *
  11. * @func
  12. * @memberOf R
  13. * @since v0.1.0
  14. * @category List
  15. * @sig Filterable f => (a -> Boolean) -> f a -> f a
  16. * @param {Function} pred
  17. * @param {Array} filterable
  18. * @return {Array}
  19. * @see R.filter, R.transduce, R.addIndex
  20. * @example
  21. *
  22. * const isOdd = (n) => n % 2 !== 0;
  23. *
  24. * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]
  25. *
  26. * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
  27. */
  28. var reject =
  29. /*#__PURE__*/
  30. _curry2(function reject(pred, filterable) {
  31. return filter(_complement(pred), filterable);
  32. });
  33. export default reject;