From f9033faf62b896b8b85d31138ce1b832200846ea Mon Sep 17 00:00:00 2001 From: tonyboylehub Date: Fri, 25 Oct 2024 22:13:14 +0100 Subject: [PATCH] added change set --- .changeset/rare-deers-sparkle.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .changeset/rare-deers-sparkle.md 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.