getTypeOf
Returns common data structure and primitive types.
Import
import { getTypeOf } from '@fullstacksjs/toolbox';
Signature
function getTypeOf(value: unknown): TypeNames;
Examples
getTypeOf(new Map()) // 'map'
getTypeOf(new Set()) // 'set'
getTypeOf(null) // 'null'
getTypeOf(new Date()) // 'date'
getTypeOf([]) // 'array'
getTypeOf(Symbol('bar')) // 'symbol'
getTypeOf(1) // 'number'
getTypeOf({}) // 'object'
getTypeOf(new Error()) // 'object'
getTypeOf([].values()) // 'object'
getTypeOf(Promise.resolve(true)) // 'object'
getTypeOf(new RegExp('foo')) // 'regexp'
getTypeOf(10n) // 'bigint'
getTypeOf('foo') // 'string'
getTypeOf(new WeakMap()) // 'weakmap'
getTypeOf(new WeakSet()) // 'weakset'
getTypeOf(true) // 'boolean'
getTypeOf(() => true) // 'function'
getTypeOf(undefined) // 'undefined'