isPrimitive()
isPrimitive()
isPrimitive()const isPrimitive = <
Type extends Primitive,
Payload extends object = object
>(
value: any,
type?: Primitives,
callback: ResultCallback<any, Payload> = resultCallback,
payload?: Payload
): value is Type =>
isStringType(type)
? {
bigint: isBigInt,
boolean: isBooleanType,
number: isNumberType,
null: isNull,
string: isStringType,
symbol: isSymbol,
undefined: isUndefined,
}[type](value, callback, payload)
: callback(
isNull(value) ||
(typeof value !== 'object' && typeof value !== 'function'),
value,
payload
);Generic type variables
TypeextendsPrimitive
TypeextendsPrimitivePayloadextendsobject=object
Payloadextendsobject=objectParameters
value: any
value: anytype?: Primitives
type?: Primitivescallback: ResultCallback<any, Payload>
callback: ResultCallback<any, Payload>payload?: Payload
payload?: PayloadReturn type
value is Type
value is TypeReturns
Example usage
Last updated