Skip to content

Commit

Permalink
added change set
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyboylehub committed Oct 25, 2024
1 parent f6d68a6 commit f9033fa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .changeset/rare-deers-sparkle.md
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.

0 comments on commit f9033fa

Please sign in to comment.