generated from ehmicky/template-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# 1.4.0 | ||
|
||
## Features | ||
|
||
- Improve documentation | ||
|
||
# 1.3.0 | ||
|
||
## Features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
/** | ||
* Check if a value is an `Error` instance. | ||
* | ||
* This is like `value instanceof Error` except it works across realms, such as | ||
* iframes or Node.js [`vm`](https://nodejs.org/api/vm.html). | ||
* | ||
* @example | ||
* ```js | ||
* isErrorInstance(new Error('')) // true | ||
* isErrorInstance('') // false | ||
* | ||
* const CrossRealmError = vm.runInNewContext('Error') | ||
* isErrorInstance(new CrossRealmError('')) // true | ||
* | ||
* isErrorInstance(new TypeError('')) // true | ||
* isErrorInstance(new AnyOtherError('')) // true | ||
* | ||
* isErrorInstance(new DOMException('')) // true | ||
* isErrorInstance(new DOMError('')) // true | ||
* | ||
* isErrorInstance(new Proxy(new Error(''), {})) // true | ||
* isErrorInstance( | ||
* new Proxy(new Error(''), { | ||
* getPrototypeOf() { | ||
* throw new Error('') | ||
* }, | ||
* }), | ||
* ) // false | ||
* ``` | ||
*/ | ||
// eslint-disable-next-line import/export | ||
export default function isErrorInstance(value: Error): true | ||
// eslint-disable-next-line import/export | ||
export default function isErrorInstance(value: any): false |