From 54f63e1cf18d57c4a727675f91a49742a9bf1dd0 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Sat, 29 Oct 2022 18:27:06 -0700 Subject: [PATCH] feat: add `isNothing()` --- src/utils/common.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index 27a93845..c4df7027 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -10,7 +10,9 @@ import { ImmerState, hasMap, Archtype, - die + die, + NOTHING, + Nothing } from "../internal" /** Returns true if the given value is an Immer draft */ @@ -215,3 +217,7 @@ export function isFrozen(obj: any): boolean { // See #600, IE dies on non-objects in Object.isFrozen return Object.isFrozen(obj) } + +export function isNothing(value: unknown): value is Nothing { + return value === NOTHING +}