README.md (2728B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # isError 22 23 > Test if a value is an [Error][mdn-error] object. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var isError = require( '@stdlib/assert/is-error' ); 41 ``` 42 43 #### isError( value ) 44 45 Tests if a `value` is an [`Error`][mdn-error] object. 46 47 ```javascript 48 var bool = isError( new Error( 'beep' ) ); 49 // returns true 50 ``` 51 52 </section> 53 54 <!-- /.usage --> 55 56 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 57 58 <section class="notes"> 59 60 </section> 61 62 <!-- /.notes --> 63 64 <!-- Package usage examples. --> 65 66 <section class="examples"> 67 68 ## Examples 69 70 <!-- eslint no-undef: "error" --> 71 72 ```javascript 73 var isError = require( '@stdlib/assert/is-error' ); 74 75 var bool = isError( new Error( 'error' ) ); 76 // returns true 77 78 bool = isError( new EvalError( 'eval error' ) ); 79 // returns true 80 81 bool = isError( new RangeError( 'range error' ) ); 82 // returns true 83 84 bool = isError( new ReferenceError( 'reference error' ) ); 85 // returns true 86 87 bool = isError( new SyntaxError( 'syntax error' ) ); 88 // returns true 89 90 bool = isError( new TypeError( 'type error' ) ); 91 // returns true 92 93 bool = isError( new URIError( 'URI error' ) ); 94 // returns true 95 96 bool = isError( {} ); 97 // returns false 98 99 bool = isError( null ); 100 // returns false 101 ``` 102 103 </section> 104 105 <!-- /.examples --> 106 107 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 108 109 <section class="references"> 110 111 </section> 112 113 <!-- /.references --> 114 115 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 116 117 <section class="links"> 118 119 [mdn-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error 120 121 </section> 122 123 <!-- /.links -->