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

feat: Add isZero helper #261

Merged
merged 4 commits into from
Jun 8, 2023
Merged

feat: Add isZero helper #261

merged 4 commits into from
Jun 8, 2023

Conversation

karelianpie
Copy link
Member

⚠️ Let me know if you can think of more edge cases

Description

isZero helper, should take almost anything and check if it's zero

Related Issue

Closes #255

Motivation and Context

We don't want to constantly be comparing stuff to 0n or 0, it's error prone and might not handle all cases. Therefore, we want a single function that can take almost anything and will check if it's zero.

How Has This Been Tested?

utils/isZero.test.ts

@karelianpie karelianpie requested a review from Majorfi June 6, 2023 12:30
@karelianpie karelianpie self-assigned this Jun 6, 2023
test.each([
[0, true],
['0', true],
['0.0', true],
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also accept 0,0?
Looks a bit overkill tbh but if we compare locale we could hit that

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it's an overkill, it's a great one! The idea here is that this is the helper function that you can give anything and it will let you know if it's zero :)

Added support for 0,0 with 4969719

Copy link
Contributor

@Majorfi Majorfi left a comment

Choose a reason for hiding this comment

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

Something I am not sure about

packages/web-lib/utils/isZero.ts Show resolved Hide resolved
@karelianpie karelianpie requested a review from Majorfi June 8, 2023 08:05
@Majorfi Majorfi merged commit db4133c into main Jun 8, 2023
@Majorfi Majorfi deleted the feat/is-zero branch June 8, 2023 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🟢 Done
Development

Successfully merging this pull request may close these issues.

feat: create a isZero function checker
2 participants