const isType = (type: string | string[]) => (obj: unknown): obj is T => obj != null && (Array.isArray(type) ? type : [type]).some( (t) => getType(obj) === `[object ${t}]` ) export const getType = (obj: any) => Object.prototype.toString.call(obj) export const isFn = isType<(...args: any[]) => any>([ 'Function', 'AsyncFunction', 'GeneratorFunction', ]) export const isWindow = isType('Window') export const isHTMLElement = (obj: any): obj is HTMLElement => { return obj?.['nodeName'] || obj?.['tagName'] } export const isArr = Array.isArray export const isPlainObj = isType('Object') export const isStr = isType('String') export const isBool = isType('Boolean') export const isNum = isType('Number') export const isObj = (val: unknown): val is object => typeof val === 'object' export const isRegExp = isType('RegExp') export const isValid = (val: any) => val !== null && val !== undefined