const getType = ( payload ) : string => Object . prototype . toString . call ( payload ) . slice ( 8 , - 1 ) ; export const isUndefined = ( payload ) : payload is undefined => typeof payload === 'undefined' ; export const isNull = ( payload ) : payload is null => payload === null ; export const isPlainObject = ( payload ) : payload is { [ key ] : any ; } => { if ( getType ( payload ) !== 'Object' ) return false ; if ( Object . getPrototypeOf ( payload ) === null ) return true ; return ( payload . constructor === Object && Object . getPrototypeOf ( payload ) === Object . prototype ) ; } ; export const isEmptyObject = ( payload ) : payload is { } => isPlainObject ( payload ) && Object . keys ( payload ) . length === 0 ; export const isArray = ( payload ) : payload is any [ ] => Array . isArray ( payload ) ; export const isString = ( payload ) : payload is string => typeof payload === 'string' ; export const isNumber = ( payload ) : payload is number => typeof payload === 'number' && ! isNaN ( payload ) ; export const isBoolean = ( payload ) : payload is boolean => typeof payload === 'boolean' ; export const isRegExp = ( payload ) : payload is RegExp => payload instanceof RegExp ; export const isMap = ( payload ) : payload is Map < any , any > => payload instanceof Map ; export const isSet = ( payload ) : payload is Set < any > => payload instanceof Set ; export const isSymbol = ( payload ) : payload is symbol => getType ( payload ) === 'Symbol' ; export const isDate = ( payload ) : payload is Date => payload instanceof Date && ! isNaN ( payload . valueOf ( ) ) ; export const isError = ( payload ) : payload is Error => payload instanceof Error ; export const isNaNValue = ( payload ) : payload is typeof NaN => typeof payload === 'number' && isNaN ( payload ) ; export const isPrimitive = ( payload ) : payload is boolean | null | undefined | number | string | symbol => isBoolean ( payload ) || isNull ( payload ) || isUndefined ( payload ) || isNumber ( payload ) || isString ( payload ) || isSymbol ( payload ) ; export const isBigint = ( payload ) : payload is bigint => typeof payload === 'bigint' ; export const isInfinite = ( payload ) : payload is number => payload === Infinity || payload === - Infinity ; export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor ; export type TypedArray = InstanceType < TypedArrayConstructor > ; export const isTypedArray = ( payload ) : payload is TypedArray => ArrayBuffer . isView ( payload ) && ! ( payload instanceof DataView ) ;