mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 05:35:05 +08:00
DISABLE_THIRD_PARTY_CHECK=new npm module causes package-lock change We can get rid of a custom script and use ESLint for these rules. Additionally this means editors will highlight the issue in the editor. Change-Id: I552b52e7f07b4e7430b3f685dbc3b5fad36ffff2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2052167 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
import _curry2 from './internal/_curry2.js';
|
|
import _dispatchable from './internal/_dispatchable.js';
|
|
import _xdropRepeatsWith from './internal/_xdropRepeatsWith.js';
|
|
import last from './last.js';
|
|
|
|
/**
|
|
* Returns a new list without any consecutively repeating elements. Equality is
|
|
* determined by applying the supplied predicate to each pair of consecutive elements. The
|
|
* first element in a series of equal elements will be preserved.
|
|
*
|
|
* Acts as a transducer if a transformer is given in list position.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.14.0
|
|
* @category List
|
|
* @sig ((a, a) -> Boolean) -> [a] -> [a]
|
|
* @param {Function} pred A predicate used to test whether two items are equal.
|
|
* @param {Array} list The array to consider.
|
|
* @return {Array} `list` without repeating elements.
|
|
* @see R.transduce
|
|
* @example
|
|
*
|
|
* const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3];
|
|
* R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3]
|
|
*/
|
|
var dropRepeatsWith = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) {
|
|
var result = [];
|
|
var idx = 1;
|
|
var len = list.length;
|
|
if (len !== 0) {
|
|
result[0] = list[0];
|
|
while (idx < len) {
|
|
if (!pred(last(result), list[idx])) {
|
|
result[result.length] = list[idx];
|
|
}
|
|
idx += 1;
|
|
}
|
|
}
|
|
return result;
|
|
}));
|
|
export default dropRepeatsWith; |