The constructor
The object to check
Whether use loose checks. Default is true.
Performs a loose instance check by comparing class names up the prototype
chain if instanceof
initially fails. To disable this loose check,
pass false
as the 3rd argument.
import { isInstance } from 'tily/is/instance';
if (isInstance(Error, error)) {
console.log(error.stack);
}
Generics can be used to type the object being checked. This will default to the declaration passed to the 2nd argument.
isInstance<ParseError>(Error, error);
Loose checks can be useful if multiple copies of the same class declaration exists in the module tree. For example, multiple versions of the same package are imported.
The constructor
Generated using TypeDoc
Performs a loose instance check by comparing class names up the prototype chain if
instanceof
initially fails. To disable this loose check, passfalse
as the 3rd argument.Generics can be used to type the object being checked. This will default to the declaration passed to the 2nd argument.