diff --git a/.changeset/rare-deers-sparkle.md b/.changeset/rare-deers-sparkle.md new file mode 100644 index 0000000..8dda7bc --- /dev/null +++ b/.changeset/rare-deers-sparkle.md @@ -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 = (nullable: Nullable): Option => + nullable !== null ? some(nullable) : none(); +``` + +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 = (nullish: Nullish): Option => + nullish !== null && nullish !== undefined ? some(nullish) : none(); +``` + +- `Nullish` type added. +- `wrapNullish` function added. +- Tests for `wrapNullish` added.