without.js 946 B

123456789101112131415161718192021222324252627282930313233343536
  1. import _curry2 from "./internal/_curry2.js";
  2. import _Set from "./internal/_Set.js";
  3. import reject from "./reject.js";
  4. /**
  5. * Returns a new list without values in the first argument.
  6. * [`R.equals`](#equals) is used to determine equality.
  7. *
  8. * Acts as a transducer if a transformer is given in list position.
  9. *
  10. * @func
  11. * @memberOf R
  12. * @since v0.19.0
  13. * @category List
  14. * @sig [a] -> [a] -> [a]
  15. * @param {Array} list1 The values to be removed from `list2`.
  16. * @param {Array} list2 The array to remove values from.
  17. * @return {Array} The new array without values in `list1`.
  18. * @see R.transduce, R.difference, R.remove
  19. * @example
  20. *
  21. * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4]
  22. */
  23. var without =
  24. /*#__PURE__*/
  25. _curry2(function without(xs, list) {
  26. var toRemove = new _Set();
  27. for (var i = 0; i < xs.length; i += 1) {
  28. toRemove.add(xs[i]);
  29. }
  30. return reject(toRemove.has.bind(toRemove), list);
  31. });
  32. export default without;