Skip to content

Commit

Permalink
feat: replaced fast-deep-equal with fast-equals (#893)
Browse files Browse the repository at this point in the history
* feat: replaced fast-deep-equal with a more maintained, esm supported library fast-equals

* chore: update fast-equals package version

* chore: update package-lock.json

---------

Co-authored-by: byt3sage <[email protected]>
Co-authored-by: Martin Schuhfuss <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2025
1 parent 644fbdc commit b3915fb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
14 changes: 12 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"test:all": "jest"
},
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-equals": "^5.2.2",
"supercluster": "^8.0.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/algorithms/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from "./utils";

import { Cluster } from "../cluster";
import equal from "fast-deep-equal";
import { deepEqual } from "fast-equals";
import { MarkerUtils, Marker } from "../marker-utils";
import { assertNotNull } from "../utils";

Expand Down Expand Up @@ -74,7 +74,7 @@ export class GridAlgorithm extends AbstractViewportAlgorithm {
if (this.state.zoom >= this.maxZoom && newState.zoom >= this.maxZoom) {
// still at or beyond maxZoom, no change
} else {
changed = !equal(this.state, newState);
changed = !deepEqual(this.state, newState);
}

this.state = newState;
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/supercluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { AbstractAlgorithm, AlgorithmInput, AlgorithmOutput } from "./core";
import SuperCluster, { ClusterFeature } from "supercluster";
import { MarkerUtils, Marker } from "../marker-utils";
import { Cluster } from "../cluster";
import equal from "fast-deep-equal";
import { deepEqual } from "fast-equals";
import { assertNotNull } from "../utils";

export type SuperClusterOptions = SuperCluster.Options<
Expand Down Expand Up @@ -57,7 +57,7 @@ export class SuperClusterAlgorithm extends AbstractAlgorithm {

const state = { zoom: zoom };

if (!equal(input.markers, this.markers)) {
if (!deepEqual(input.markers, this.markers)) {
changed = true;
// TODO use proxy to avoid copy?
this.markers = [...input.markers];
Expand All @@ -79,7 +79,7 @@ export class SuperClusterAlgorithm extends AbstractAlgorithm {

if (!changed) {
if (this.state.zoom <= this.maxZoom || state.zoom <= this.maxZoom) {
changed = !equal(this.state, state);
changed = !deepEqual(this.state, state);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/superviewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import SuperCluster, { ClusterFeature } from "supercluster";
import { MarkerUtils, Marker } from "../marker-utils";
import { Cluster } from "../cluster";
import { getPaddedViewport } from "./utils";
import equal from "fast-deep-equal";
import { deepEqual } from "fast-equals";
import { assertNotNull } from "../utils";

export interface SuperClusterViewportOptions
Expand Down Expand Up @@ -71,8 +71,8 @@ export class SuperClusterViewportAlgorithm extends AbstractViewportAlgorithm {
public calculate(input: AlgorithmInput): AlgorithmOutput {
const state = this.getViewportState(input);

let changed = !equal(this.state, state);
if (!equal(input.markers, this.markers)) {
let changed = !deepEqual(this.state, state);
if (!deepEqual(input.markers, this.markers)) {
changed = true;
// TODO use proxy to avoid copy?
this.markers = [...input.markers];
Expand Down

0 comments on commit b3915fb

Please sign in to comment.