dropRepeatsBy.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import _curry2 from "./internal/_curry2.js";
  2. import _dispatchable from "./internal/_dispatchable.js";
  3. import _xdropRepeatsWith from "./internal/_xdropRepeatsWith.js";
  4. import dropRepeatsWith from "./dropRepeatsWith.js";
  5. import eqBy from "./eqBy.js";
  6. /**
  7. * Returns a new list without any consecutively repeating elements,
  8. * based upon the value returned by applying the supplied function to
  9. * each list element. [`R.equals`](#equals) is used to determine equality.
  10. *
  11. * Acts as a transducer if a transformer is given in list position.
  12. *
  13. * @func
  14. * @memberOf R
  15. * @since v0.29.0
  16. * @category List
  17. * @sig (a -> b) -> [a] -> [a]
  18. * @param {Function} fn A function used to produce a value to use during comparisons.
  19. * @param {Array} list The array to consider.
  20. * @return {Array} `list` without repeating elements.
  21. * @see R.transduce
  22. * @example
  23. *
  24. * R.dropRepeatsBy(Math.abs, [1, -1, -1, 2, 3, -4, 4, 2, 2]); //=> [1, 2, 3, -4, 2]
  25. */
  26. var dropRepeatsBy =
  27. /*#__PURE__*/
  28. _curry2(function (fn, list) {
  29. return _dispatchable([], function () {
  30. return _xdropRepeatsWith(eqBy(fn));
  31. }, dropRepeatsWith(eqBy(fn)))(list);
  32. });
  33. export default dropRepeatsBy;