Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cloud-walker
Last active February 28, 2021 06:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloud-walker/b13c8eeaef4394d631ae02748747e913 to your computer and use it in GitHub Desktop.
Save cloud-walker/b13c8eeaef4394d631ae02748747e913 to your computer and use it in GitHub Desktop.
TypeScript utils
export type Nully = null | undefined
export type Falsy = false | 0 | '' | Nully
import {Nully} from './common.ts'
export const isNotNully = <T>(value: T): value is Exclude<T, Nully> => value != null && value != undefined
import {Falsy} from './common.ts'
export const isTruthy = <T>(value: T): value is Exclude<T, Falsy> => !!value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment