Skip to content
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

Symbols as keys #272

Merged
merged 3 commits into from
Aug 8, 2024
Merged

Symbols as keys #272

merged 3 commits into from
Aug 8, 2024

Conversation

Ayc0
Copy link
Contributor

@Ayc0 Ayc0 commented Aug 8, 2024

I noticed that isMatching wasn't working with symbols:

image

But the exact same code works with strings:

image

So I updated the matchPattern function to also iterate through symbols in addition to keys (Object.keys() skips symbols, but we can use Object.getOwnPropertySymbols() for those)

I also added a test that is failing without my changes, but passes after:

Before After
image image

Comment on lines +13 to +15
} else {
throw new Error('Expected obj to match the foo pattern!');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only wasn't enough as it was passing before (as it was stripping all symbols)

So I added the other if for the negative check

@gvergnaud
Copy link
Owner

Awesome, thank you!

@gvergnaud gvergnaud merged commit e74557d into gvergnaud:main Aug 8, 2024
@Ayc0 Ayc0 deleted the symbol branch August 8, 2024 15:00
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.

2 participants