isNotNil
A function that checks whether a given argument is neither null nor undefined, and if so, narrows the type to the original argument type.
Code
Interface
typescript
const isNotNil: <T>(val: T | null | undefined) => val is T
Usage
typescript
import { isNotNil } from '@modern-kit/utils';
isNotNil(1); // true
isNotNil(false); // true
isNotNil("str"); // true
isNotNil({}); // true
isNotNil(undefined); // false
isNotNil(null); // false