Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 4, 2022
1 parent 5292c40 commit c50fd1d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.4.0

## Features

- Improve documentation

# 1.3.0

## Features
Expand Down
26 changes: 26 additions & 0 deletions src/main.d.ts
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

0 comments on commit c50fd1d

Please sign in to comment.