UNPKG

@xylabs/typeof

Version:

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

15 lines (13 loc) 258 B
import { typeOf } from './typeOf.ts' export const ifDefined = <T>(value: T, func: (value: T) => void) => { switch (typeOf(value)) { case 'undefined': case 'null': { break } default: { func(value) return value } } }