-
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
a803163
commit e04a2d0
Showing
2 changed files
with
12 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './json/index.js' | ||
export * from './lazy/index.js' | ||
export * from './locale/index.js' | ||
export * from './nullables/index.js' | ||
export * from './raise/index.js' | ||
export * from './records/index.js' |
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,11 @@ | ||
/** | ||
* Checks whenever a value is not nullable; same as value != null | ||
* | ||
* Useful for Array.filter(): | ||
* const arr: (string | undefined)[] = [...] | ||
* ❌ arr.filter(v => v != null) // type: (string | undefined)[] | ||
* ❌ arr.filter(v => typeof v === 'string') // type: (string | undefined)[] | ||
* ✅ arr.filter(isNonNullable) // type: string[] | ||
*/ | ||
export const isNonNullable = <T>(value: NonNullable<T> | undefined | null): value is NonNullable<T> => | ||
value != null |