predictype

predictype v0.13.0


predictype / predicates/objects / objectInstanceType

Function: objectInstanceType()

objectInstanceType(source, oper): boolean

Defined in: predicates/objects/objectInstanceType.ts:28

Checks the type of an instance using the specified operation.

Parameters

source

any

The value to check.

oper

ObjectInstanceTypeOper

The type operation to perform.

Returns

boolean

True if the type check is valid according to the operator, otherwise false.

Throws

If the operation is not recognized.

Example

class User {}
const classCtor = User;
const plain = { id: 1 };

objectInstanceType(classCtor, 'instance_of_class'); // true
objectInstanceType(classCtor, 'instance_of_function'); // true
objectInstanceType(plain, 'instance_of_object'); // true

Remarks

Supported Operators: