Skip to content

Commit

Permalink
feat: replaced fast-deep-equal with a more maintained, esm supported …
Browse files Browse the repository at this point in the history
…library fast-equals
  • Loading branch information
byt3sage committed Jul 5, 2024
1 parent c5cdf54 commit c076e0c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
13 changes: 11 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 @@ -36,7 +36,7 @@
"test:all": "jest"
},
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-equals": "^5.0.1",
"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";

export interface GridOptions extends ViewportAlgorithmOptions {
Expand Down Expand Up @@ -69,7 +69,7 @@ export class GridAlgorithm extends AbstractViewportAlgorithm {
if (this.state.zoom >= this.maxZoom && state.zoom >= this.maxZoom) {
// still at or beyond maxZoom, no change
} else {
changed = !equal(this.state, state);
changed = !deepEqual(this.state, state);
}
this.state = state;
if (map.getZoom() >= this.maxZoom) {
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";

export type SuperClusterOptions = SuperCluster.Options<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -52,7 +52,7 @@ export class SuperClusterAlgorithm extends AbstractAlgorithm {
let changed = false;
const state = { zoom: input.map.getZoom() };

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 @@ -74,7 +74,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";

export interface SuperClusterViewportOptions
extends SuperClusterOptions,
Expand Down Expand Up @@ -77,8 +77,8 @@ export class SuperClusterViewportAlgorithm extends AbstractViewportAlgorithm {
),
};

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 c076e0c

Please sign in to comment.