Skip to content

feat(shallow): add Date object comparison support #201

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MostafaRastegar
Copy link

  • Add instanceof Date check to compare dates by value instead of reference
  • Ensures Date objects with same timestamp are considered equal
  • Critical for state management scenarios where dates are recreated but represent same value
  • Maintains existing behavior for all other object types

Example:
const state1 = { lastLogin: new Date('2023-01-01'), user: 'John' }
const state2 = { lastLogin: new Date('2023-01-01'), user: 'John' }
shallow(state1, state2) // now returns true instead of false

- Add instanceof Date check to compare dates by value instead of reference
- Ensures Date objects with same timestamp are considered equal
- Critical for state management scenarios where dates are recreated but represent same value
- Maintains existing behavior for all other object types

Example:
const state1 = { lastLogin: new Date('2023-01-01'), user: 'John' }
const state2 = { lastLogin: new Date('2023-01-01'), user: 'John' }
shallow(state1, state2) // now returns true instead of false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant