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: fromNullishNullable #809

Merged
merged 5 commits into from
Jan 20, 2025
Merged

feat: fromNullishNullable #809

merged 5 commits into from
Jan 20, 2025

Conversation

peterpeterparker
Copy link
Member

@peterpeterparker peterpeterparker commented Jan 13, 2025

Motivation

In Juno, I often encounter a pattern where an optional Candid variant of an optional Candid variant needs to be transformed into a nullish value. To simplify this, I introduced a utility (PR) to shorten the pattern since each fromNullable of an undefined value requires the chaining operation ?? [].

I took a quick look at the NNS dapp and OISY, and it seems to follow a similar pattern. Therefore, I considered adding the utility to @dfinity/utils.

Notes

Not against better naming?

Changes

  • Implement fromNullishNullable
  • Extract reused test data and add two blocks describe (in addition to the test for the new function)

@peterpeterparker peterpeterparker requested review from a team as code owners January 13, 2025 11:21
Copy link
Contributor

github-actions bot commented Jan 13, 2025

size-limit report 📦

Path Size
@dfinity/ckbtc 8.11 KB (0%)
@dfinity/cketh 3.68 KB (0%)
@dfinity/cmc 1.41 KB (0%)
@dfinity/ledger-icrc 4.33 KB (0%)
@dfinity/ledger-icp 15.43 KB (0%)
@dfinity/nns 37.06 KB (0%)
@dfinity/nns-proto 140.98 KB (0%)
@dfinity/sns 16.98 KB (0%)
@dfinity/utils 4.67 KB (+0.21% 🔺)
@dfinity/ic-management 3.19 KB (0%)

Copy link

@AntonioVentilii AntonioVentilii left a comment

Choose a reason for hiding this comment

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

Good one! I think we have a few places to use this, IIRC

Tks!

@peterpeterparker peterpeterparker merged commit 90d7241 into main Jan 20, 2025
11 checks passed
@peterpeterparker peterpeterparker deleted the feat/fromNullishNullable branch January 20, 2025 09:04
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