fix: Extension deep compare not quite working for some primitives (#5172)

fix: extension deep compare not quite working for some primitives
This commit is contained in:
Valya 2023-01-16 14:15:19 +00:00 committed by GitHub
parent 582865c7e9
commit 98017dc36f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,11 @@ function deepCompare(left: unknown, right: unknown): boolean {
return true;
}
// Explicitly return false if certain primitives don't equal each other
if (['number', 'string', 'bigint', 'boolean', 'symbol'].includes(typeof left) && left !== right) {
return false;
}
// Quickly check how many properties each has to avoid checking obviously mismatching
// objects
if (Object.keys(left as object).length !== Object.keys(right as object).length) {