@radicjs/kindof
v1.0.2
Published
typeof/kindof type guards/checkers
Readme
@radicjs/kindof
type checkers / guards
Installation
npm i @radicjs/kindofyarn add @radicjs/kindofAPI
export type KindsOf = 'number' | 'string' | 'boolean' | 'function' | 'regexp' | 'array' | 'date' | 'error' | 'object';
export const kindOf = (value: any):KindsOf
export const isNumber = (value: any): value is number =>{}
export const isString = (value: any): value is string =>{}
export const isBoolean = (value: any): value is boolean =>{}
export const isFunction = (value: any): value is Function =>{}
export const isRegExp = (value: any): value is RegExp =>{}
export const isArray = (value: any): value is Array =>{}
export const isDate = (value: any): value is Date => {}
export const isError = (value: any): value is Error =>{}
export const isObject = (value: any): value is object =>{}
export const isNothing = (value: any): value is undefined =>{}
export const isNumericString = (value: any): boolean => isString(value) && !isNaN(value as any);
export const isStringNumber = (value: any): value is string | number => isNumber(value) || isNumericString(value);
export const isNumberObject = (target: any): boolean => {}
export const isES6Promise = (p: any): p is PromiseLike<any> => {}
export const isNativePromise = (p: any): boolean => {}
export const isPromise = <T = any>(p: any): p is PromiseLike<T> => {}
export const isConstructor = (value: any): boolean => {}Example
kindOf('asfs') === 'string' // true
isString('asfs') === 'string' // trueSize
Total: 6.40 kB
Gzip: 2.55 kB
Coverage
St|File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --|-----------|---------|----------|---------|---------|------------------- 🟢|All files | 92.18 | 66.66 | 95.23 | 94.59 | 🟢| kindOf.ts| 92.18 | 66.66 | 95.23 | 94.59 |20,69
