mirror of
https://github.com/ersinkoc/vld.git
synced 2026-04-26 22:45:52 +03:00
[PR #4] fix(VldArray): correct unique check for objects #3
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vld#3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/ersinkoc/vld/pull/4
State: closed
Merged: Yes
The
uniquecheck inVldArraywas previously usingJSON.stringifyto compare objects, which is unreliable because the order of keys in the resulting string is not guaranteed. This could lead to duplicate objects not being detected if their keys were in a different order.This commit fixes the issue by introducing a
stableStringifymethod that sorts the keys of an object before stringifying it. This ensures that the string representation of an object is always consistent, allowing for reliable duplicate detection.A new test case has been added to verify the fix and prevent regressions.