From 34a9d94baacbd7a2b0b3345fb554665fa1515bf3 Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Thu, 8 Aug 2024 17:17:20 +0100 Subject: [PATCH] refactor: use native `findLast(Index)` over lodash's --- adminSiteClient/GrapherConfigGridEditor.tsx | 4 +--- .../grapher/src/stackedCharts/StackedUtils.ts | 5 ++--- packages/@ourworldindata/utils/src/Util.ts | 4 ---- packages/@ourworldindata/utils/src/index.ts | 2 -- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/adminSiteClient/GrapherConfigGridEditor.tsx b/adminSiteClient/GrapherConfigGridEditor.tsx index b26aa5edfde..d66fc72ddd1 100644 --- a/adminSiteClient/GrapherConfigGridEditor.tsx +++ b/adminSiteClient/GrapherConfigGridEditor.tsx @@ -31,7 +31,6 @@ import { match, P } from "ts-pattern" //import * as lodash from "lodash" import { cloneDeep, - findLastIndex, isArray, isEmpty, isEqual, @@ -1447,8 +1446,7 @@ export class GrapherConfigGridEditor extends React.Component item.key === itemKey ) if (itemIndex !== -1) { - const lastVisibleIndex = findLastIndex( - columnSelection, + const lastVisibleIndex = columnSelection.findLastIndex( (item) => item.visible ) diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/StackedUtils.ts b/packages/@ourworldindata/grapher/src/stackedCharts/StackedUtils.ts index 6750d54904c..8cebafc57cd 100644 --- a/packages/@ourworldindata/grapher/src/stackedCharts/StackedUtils.ts +++ b/packages/@ourworldindata/grapher/src/stackedCharts/StackedUtils.ts @@ -8,7 +8,6 @@ import { findGreatestCommonDivisorOfArray, rollingMap, omitUndefinedValues, - findLast, } from "@ourworldindata/utils" import { StackedPointPositionType, StackedSeries } from "./StackedConstants" @@ -42,8 +41,8 @@ export const stackSeriesInBothDirections = < .map((s) => s.points[pointIndex]) const pointBelowThisOne = point.value < 0 - ? findLast(pointsBelowThisOne, (p) => p.value < 0) - : findLast(pointsBelowThisOne, (p) => p.value >= 0) + ? pointsBelowThisOne.findLast((p) => p.value < 0) + : pointsBelowThisOne.findLast((p) => p.value >= 0) point.valueOffset = pointBelowThisOne ? pointBelowThisOne.value + pointBelowThisOne.valueOffset : 0 diff --git a/packages/@ourworldindata/utils/src/Util.ts b/packages/@ourworldindata/utils/src/Util.ts index 567ba543efe..f9f7b7232d5 100644 --- a/packages/@ourworldindata/utils/src/Util.ts +++ b/packages/@ourworldindata/utils/src/Util.ts @@ -13,8 +13,6 @@ import { dropWhile, escapeRegExp, extend, - findLast, - findLastIndex, flatten, get, groupBy, @@ -87,8 +85,6 @@ export { dropWhile, escapeRegExp, extend, - findLast, - findLastIndex, flatten, get, groupBy, diff --git a/packages/@ourworldindata/utils/src/index.ts b/packages/@ourworldindata/utils/src/index.ts index 0cd96a487a0..e4ec7519807 100644 --- a/packages/@ourworldindata/utils/src/index.ts +++ b/packages/@ourworldindata/utils/src/index.ts @@ -156,8 +156,6 @@ export { dropRightWhile, dropWhile, extend, - findLast, - findLastIndex, flatten, get, groupBy,