From 387d79922a1dcddbe482b5b9d33773a0e5829044 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Fri, 23 Feb 2024 14:54:29 -0500 Subject: [PATCH] Replace fast-deep-equal with dequal --- package.json | 2 +- pnpm-lock.yaml | 15 ++++++++------- src/diff.ts | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 73d5e9c..3a8ea0e 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,6 @@ "typescript": "^5.0.0" }, "dependencies": { - "fast-deep-equal": "^3.1.3" + "dequal": "^2.0.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 535c8ac..fa339ba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,9 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: - fast-deep-equal: - specifier: ^3.1.3 - version: 3.1.3 + dequal: + specifier: ^2.0.3 + version: 2.0.3 react: specifier: ^17 || ^18 version: 18.2.0 @@ -854,6 +854,11 @@ packages: type-detect: 4.0.8 dev: true + /dequal@2.0.3: + resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} + engines: {node: '>=6'} + dev: false + /diff-sequences@29.6.3: resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -925,10 +930,6 @@ packages: strip-final-newline: 3.0.0 dev: true - /fast-deep-equal@3.1.3: - resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - dev: false - /fflate@0.7.4: resolution: {integrity: sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==} dev: true diff --git a/src/diff.ts b/src/diff.ts index 11ece71..51af63f 100644 --- a/src/diff.ts +++ b/src/diff.ts @@ -1,5 +1,5 @@ import { HasUrlObject } from "./model"; -import equal from "fast-deep-equal/es6"; +import { dequal } from "dequal/lite"; /** * A special value which indicates that the difference between two objects is Irreconcilable. @@ -187,7 +187,7 @@ function diffPrimitive( const yKeys = Object.keys(y); const deletedKeys = setDifference(xKeys, yKeys); const addedKeys = setDifference(yKeys, xKeys); - const changedKeys = xKeys.filter((key) => !equal(x[key], y[key])); + const changedKeys = xKeys.filter((key) => !dequal(x[key], y[key])); const diffKeys = addedKeys.concat(changedKeys); return { ...Object.fromEntries(deletedKeys.map((key) => [key, undefined])),