Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce bundle size of apps that import @turf/helpers #2623

Merged
merged 6 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/turf-boolean-equal/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Feature, Geometry } from "geojson";
import { GeojsonEquality } from "@turf/helpers";
import { geojsonEquality } from "geojson-equality-ts";
import { cleanCoords } from "@turf/clean-coords";
import { getGeom } from "@turf/invariant";

Expand Down Expand Up @@ -45,8 +45,9 @@ function booleanEqual(
const type2 = getGeom(feature2).type;
if (type1 !== type2) return false;

const equality = new GeojsonEquality({ precision: precision });
return equality.compare(cleanCoords(feature1), cleanCoords(feature2));
return geojsonEquality(cleanCoords(feature1), cleanCoords(feature2), {
precision,
});
}

export { booleanEqual };
Expand Down
1 change: 1 addition & 0 deletions packages/turf-boolean-equal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@turf/clean-coords": "workspace:^",
"@turf/helpers": "workspace:^",
"@turf/invariant": "workspace:^",
"geojson-equality-ts": "^1.0.2",
"tslib": "^2.6.2"
}
}
6 changes: 3 additions & 3 deletions packages/turf-boolean-overlap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { segmentEach } from "@turf/meta";
import { getGeom } from "@turf/invariant";
import { lineOverlap } from "@turf/line-overlap";
import { lineIntersect } from "@turf/line-intersect";
import { GeojsonEquality } from "@turf/helpers";
import { geojsonEquality } from "geojson-equality-ts";

/**
* Compares two geometries of the same dimension and returns true if their intersection set results in a geometry
Expand Down Expand Up @@ -49,8 +49,8 @@ function booleanOverlap(
if (type1 === "Point") throw new Error("Point geometry not supported");

// features must be not equal
const equality = new GeojsonEquality({ precision: 6 });
if (equality.compare(feature1 as any, feature2 as any)) return false;
if (geojsonEquality(feature1 as any, feature2 as any, { precision: 6 }))
return false;

let overlap = 0;

Expand Down
1 change: 1 addition & 0 deletions packages/turf-boolean-overlap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@turf/line-intersect": "workspace:^",
"@turf/line-overlap": "workspace:^",
"@turf/meta": "workspace:^",
"geojson-equality-ts": "^1.0.2",
"tslib": "^2.6.2"
}
}
1 change: 0 additions & 1 deletion packages/turf-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {

import { Id } from "./lib/geojson.js";
export * from "./lib/geojson.js";
export * from "./lib/geojson-equality.js";

// TurfJS Combined Types
export type Coord = Feature<Point> | Point | Position;
Expand Down
198 changes: 0 additions & 198 deletions packages/turf-helpers/lib/geojson-equality.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/turf-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
},
"devDependencies": {
"@types/benchmark": "^2.1.5",
"@types/deep-equal": "^1.0.4",
"@types/tape": "^4.2.32",
"benchmark": "^2.1.4",
"npm-run-all": "^4.1.5",
Expand All @@ -69,7 +68,6 @@
"typescript": "^5.2.2"
},
"dependencies": {
"deep-equal": "^2.2.3",
"tslib": "^2.6.2"
}
}
Loading
Loading