Skip to content

Commit

Permalink
Use react-fast-compare instead of fast-deep-equal.
Browse files Browse the repository at this point in the history
  • Loading branch information
octet-stream committed Nov 9, 2023
1 parent f3d7c7a commit 109d262
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@typescript-eslint/parser": "6.10.0",
"ava": "5.3.1",
"c8": "8.0.1",
"cross-env": "^7.0.3",
"cross-env": "7.0.3",
"del-cli": "5.1.0",
"eslint": "8.53.0",
"eslint-config-airbnb-typescript": "17.1.0",
Expand All @@ -75,13 +75,13 @@
"sinon": "17.0.1",
"size-limit": "8.2.4",
"ts-node": "10.9.1",
"tsup": "^7.2.0",
"tsup": "7.2.0",
"typescript": "5.2.2"
},
"peerDependencies": {
"react": "18.x"
},
"dependencies": {
"fast-deep-equal": "3.1.3"
"react-fast-compare": "3.2.2"
}
}
15 changes: 10 additions & 5 deletions pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions src/useSuspender.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-throw-literal */ // Disable to supress errors on `throw new Promise`
/* eslint-disable no-shadow */ // Disabled because State exists only on type-level and we don't rely on the thing we override

import eq from "fast-deep-equal/es6/react.js"
import isEqual from "react-fast-compare"

// Note: const emum will inline State values as it used. It will be fine while it's private. If this type is ever going to be public - remove the `const` keyword as it might get hazardous.
// See: https://youtu.be/jjMbPt_H3RQ
Expand Down Expand Up @@ -150,7 +150,7 @@ export function createSuspender<
*/
function get(args: TArgs): Operation<TResult, TArgs> | undefined {
for (const operation of cache) {
if (eq(args, operation.args)) {
if (isEqual(args, operation.args)) {
return operation
}
}
Expand Down
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export default defineConfig(() => ({
outDir: "lib",
dts: true,
splitting: false,
external: ["formdata-node", "busboy"]
external: ["react-fast-compare"]
}))

0 comments on commit 109d262

Please sign in to comment.