isTypeError
Test if a value is a TypeError object.
Usage
var isTypeError = require( '@stdlib/assert/is-type-error' );
isTypeError( value )
Tests if a value is a TypeError object.
var bool = isTypeError( new TypeError( 'beep' ) ); // returns true
Notes
- This function should not be considered robust. While the function should always return
trueif provided aTypeError(or a descendant) object, false positives may occur due to the fact that theTypeErrorconstructor inherits fromErrorand has no internal class of its own. Hence,TypeErrorimpersonation is possible.
Examples
var isTypeError = require( '@stdlib/assert/is-type-error' ); var bool = isTypeError( new TypeError( 'type error' ) ); // returns true bool = isTypeError( new Error( 'error' ) ); // returns false bool = isTypeError( new EvalError( 'eval error' ) ); // returns false bool = isTypeError( new ReferenceError( 'reference error' ) ); // returns false bool = isTypeError( new SyntaxError( 'syntax error' ) ); // returns false bool = isTypeError( new RangeError( 'range error' ) ); // returns false bool = isTypeError( new URIError( 'URI error' ) ); // returns false bool = isTypeError( {} ); // returns false bool = isTypeError( null ); // returns false
See Also
@stdlib/assert/is-error: test if a value is an Error object.