-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb0c941
commit 7885d81
Showing
4 changed files
with
195 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2021-present the Fonction authors. All rights reserved. MIT license. | ||
import type { IsNull } from './isNull.ts' | ||
import { isNull } from './isNull.ts' | ||
import { IsUndefined, isUndefined } from './isUndefined.ts' | ||
import { or } from './or.ts' | ||
/** | ||
* Undefiled or null, or not. | ||
* | ||
* @typeParam T - Any value | ||
* | ||
* @public | ||
*/ | ||
type IsNil<T extends unknown> = IsUndefined<T> extends true | ||
? true | ||
: IsNull<T> extends true | ||
? true | ||
: false | ||
|
||
/** | ||
* Whatever argument is type of `undefined` or `null`. | ||
* | ||
* @param val - Input any value | ||
* @returns The result of type of `val` is `undefined` or `null` | ||
* | ||
* @example | ||
* ```ts | ||
* isNil(undefined) // true | ||
* isNil(null) // true | ||
* isNil([]) // false | ||
* ``` | ||
* | ||
* @public | ||
* | ||
*/ | ||
const isNil = (val: unknown): val is null | undefined => | ||
or(isUndefined(val), isNull(val)) | ||
|
||
export { isNil } | ||
export type { IsNil } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters