From ac633fafe0fc8a6446095cc971a35fb52a0764f5 Mon Sep 17 00:00:00 2001 From: dornelasnelson Date: Tue, 2 Jan 2024 23:34:40 +0100 Subject: [PATCH] chore: remove lodash.flatten in favor of array.flat() --- package-lock.json | 16 ------------- package.json | 2 -- src/PolygonMap/PolygonMap.tsx | 43 +++++++++++++++++------------------ 3 files changed, 21 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index 42d193a..0e317a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@mapbox/geojson-rewind": "^0.5.2", "@mapbox/geojsonhint": "^3.1.0", "leaflet-path-drag": "^1.8.0-beta.3", - "lodash.flatten": "^4.4.0", "react-undo-redo": "^3.0.0" }, "devDependencies": { @@ -32,7 +31,6 @@ "@testing-library/user-event": "^14.4.3", "@types/jest": "^29.4.0", "@types/leaflet": "^1.9.1", - "@types/lodash.flatten": "^4.4.7", "@types/node": "^18.14.2", "@types/react": "^18.0.28", "@types/react-leaflet": "^3.0.0", @@ -9241,15 +9239,6 @@ "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", "dev": true }, - "node_modules/@types/lodash.flatten": { - "version": "4.4.7", - "resolved": "https://registry.npmjs.org/@types/lodash.flatten/-/lodash.flatten-4.4.7.tgz", - "integrity": "sha512-6yyP/mHEKL2sa86V61F7TnEcUKlLML9+aWI7TCKvnS4SFt7RD4zTVwkdDgluOJqxVkwZ/2z7HvtRs/7j/Uru7g==", - "dev": true, - "dependencies": { - "@types/lodash": "*" - } - }, "node_modules/@types/mdast": { "version": "3.0.11", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.11.tgz", @@ -18111,11 +18100,6 @@ "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", "dev": true }, - "node_modules/lodash.flatten": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", - "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==" - }, "node_modules/lodash.flow": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/lodash.flow/-/lodash.flow-3.5.0.tgz", diff --git a/package.json b/package.json index 320027c..caf5d91 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "@mapbox/geojson-rewind": "^0.5.2", "@mapbox/geojsonhint": "^3.1.0", "leaflet-path-drag": "^1.8.0-beta.3", - "lodash.flatten": "^4.4.0", "react-undo-redo": "^3.0.0" }, "devDependencies": { @@ -66,7 +65,6 @@ "@testing-library/user-event": "^14.4.3", "@types/jest": "^29.4.0", "@types/leaflet": "^1.9.1", - "@types/lodash.flatten": "^4.4.7", "@types/node": "^18.14.2", "@types/react": "^18.0.28", "@types/react-leaflet": "^3.0.0", diff --git a/src/PolygonMap/PolygonMap.tsx b/src/PolygonMap/PolygonMap.tsx index 626ede3..09bc080 100644 --- a/src/PolygonMap/PolygonMap.tsx +++ b/src/PolygonMap/PolygonMap.tsx @@ -1,24 +1,23 @@ -import { LatLngTuple } from 'leaflet'; -import flatten from 'lodash.flatten'; -import { useCallback, useEffect, useRef, useState } from 'react'; -import { useMap } from 'react-leaflet'; - -import { ActionBar } from '../ActionBar/ActionBar'; -import { Modal } from '../common/components/Modal'; -import { MAP } from '../constants'; -import { ExportPolygonForm } from '../conversion/ExportPolygonForm'; -import { ImportPolygonForm } from '../conversion/ImportPolygonForm'; -import { createLeafletLatLngBoundsFromCoordinates } from '../helpers'; -import { Container, Map } from '../leaflet/Map'; -import { TileLayer } from '../leaflet/TileLayer'; -import { Coordinate, RectangleSelection } from '../types'; -import { BoundaryPolygon } from './components/BoundaryPolygon'; -import { ActivePolygon } from './components/ActivePolygon'; -import { InactivePolygon } from './components/InactivePolygon'; -import { PolygonPane } from './components/PolygonPane'; -import { Polyline } from './components/Polyline'; -import { SelectionRectangle } from './components/SelectionRectangle'; -import { MapInner } from './components/MapInner'; +import { LatLngTuple } from 'leaflet' +import { useCallback, useEffect, useRef, useState } from 'react' +import { useMap } from 'react-leaflet' + +import { ActionBar } from '../ActionBar/ActionBar' +import { Modal } from '../common/components/Modal' +import { MAP } from '../constants' +import { ExportPolygonForm } from '../conversion/ExportPolygonForm' +import { ImportPolygonForm } from '../conversion/ImportPolygonForm' +import { createLeafletLatLngBoundsFromCoordinates } from '../helpers' +import { Container, Map } from '../leaflet/Map' +import { TileLayer } from '../leaflet/TileLayer' +import { Coordinate, RectangleSelection } from '../types' +import { ActivePolygon } from './components/ActivePolygon' +import { BoundaryPolygon } from './components/BoundaryPolygon' +import { InactivePolygon } from './components/InactivePolygon' +import { MapInner } from './components/MapInner' +import { PolygonPane } from './components/PolygonPane' +import { Polyline } from './components/Polyline' +import { SelectionRectangle } from './components/SelectionRectangle' export interface PolygonMapProps { activePolygon: Coordinate[]; @@ -103,7 +102,7 @@ export const PolygonMap = ({ const reframeOnPolygon = (polygonCoordinates: Coordinate[] | Coordinate[][]) => { if (map.current && !!polygonCoordinates.length) { - const bounds = createLeafletLatLngBoundsFromCoordinates(flatten(polygonCoordinates)); + const bounds = createLeafletLatLngBoundsFromCoordinates(polygonCoordinates.flat()); map.current.fitBounds(bounds); }