Skip to content

Commit

Permalink
fix: fix isEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Nov 3, 2024
1 parent 75c0137 commit 4f6c4a8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ export function isEqualWith(value: any, other: any, fn: (value: any, other: any)
return value.every((v, i) => baseIsEqual(v, other[i], cache))
}

if (
(toRawType(value) === 'String' && toRawType(other) === 'String') ||
(toRawType(value) === 'Number' && toRawType(other) === 'Number') ||
(toRawType(value) === 'Boolean' && toRawType(other) === 'Boolean') ||
(toRawType(value) === 'BigInt' && toRawType(other) === 'BigInt') ||
(toRawType(value) === 'Symbol' && toRawType(other) === 'Symbol')
) {
return value.valueOf() === other.valueOf()
}

if (isPlainObject(value) && isPlainObject(other)) {
const valueOwnKeys = [...Object.keys(value), ...Object.getOwnPropertySymbols(value)]
const otherOwnKeys = [...Object.keys(other), ...Object.getOwnPropertySymbols(other)]
Expand Down

0 comments on commit 4f6c4a8

Please sign in to comment.