Created
December 18, 2023 09:02
-
-
Save banyudu/2787db221933bbdd935f67b40da14096 to your computer and use it in GitHub Desktop.
Typescript truthy falsy guard
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
export const truthy = (v: any): v is true => { | |
return !!(v as boolean) | |
} | |
export const falsy = (v: any): v is false => { | |
return !(v as boolean) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment