-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6d68a6
commit f9033fa
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
'@metaplex-foundation/umi-options': minor | ||
--- | ||
|
||
`wrapNullable` didn't account for an undefined input and would result in a return value of `some(undefined)` causing `isNone` checks to not pass if `undefined` was the `nullable` value. | ||
|
||
```ts | ||
export const wrapNullable = <T>(nullable: Nullable<T>): Option<T> => | ||
nullable !== null ? some(nullable) : none<T>(); | ||
``` | ||
|
||
Added a `wrapNullish` function to check for both `null` and undefined which will return the value of `none()` if `null` or `undefined` is the presented `nullish` value. | ||
|
||
```ts | ||
export const wrapNullish = <T>(nullish: Nullish<T>): Option<T> => | ||
nullish !== null && nullish !== undefined ? some(nullish) : none<T>(); | ||
``` | ||
|
||
- `Nullish` type added. | ||
- `wrapNullish` function added. | ||
- Tests for `wrapNullish` added. |