[d24f17c] | 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 |
|
---|
| 27 | var dropRepeatsBy =
|
---|
| 28 | /*#__PURE__*/
|
---|
| 29 | _curry2(function (fn, list) {
|
---|
| 30 | return _dispatchable([], function () {
|
---|
| 31 | return _xdropRepeatsWith(eqBy(fn));
|
---|
| 32 | }, dropRepeatsWith(eqBy(fn)))(list);
|
---|
| 33 | });
|
---|
| 34 |
|
---|
| 35 | export default dropRepeatsBy; |
---|