-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
refactor: replace dequal
w/ stable-hash
#99
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #99 +/- ##
=======================================
Coverage 96.22% 96.23%
=======================================
Files 91 91
Lines 4399 4410 +11
Branches 1497 1499 +2
=======================================
+ Hits 4233 4244 +11
Misses 160 160
Partials 6 6 ☔ View full report in Codecov by Sentry. |
Hm, it seems, that they will. Here is a small example: import assert from "node:assert";
import stableHash from "stable-hash";
const foo = {};
const hash = stableHash(foo);
foo.bar = "baz";
assert.notStrictEqual(hash, stableHash(foo));
But do we really need a meaningful hash? Besides, this hash is not a real hash (since it's variable length, so it's more like a stringifier) and on some of our tests the full context hash can be up to 400 characters long. However, changing just one character would be enough to invalidate the previous If you compare all the approaches, you get the following:
So we have three options:
|
Continues from #85.
Unlike
dequal
,stable-hash
uses shallow comparison and referential equality only (so mutable Object, Set, and Map won't have the same hash after mutation). Andstable-hash
outputs meaningful hash instead of version.cc @kosmotema