Skip to content

Commit

Permalink
add some Error.isError docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 27, 2024
1 parent e5ca044 commit b05b0ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog
##### Unreleased
- Added [`Error.isError` stage 3 proposal](https://github.com/tc39/proposal-is-error):
- Added built-ins:
- `Error.isError`
- We have no bulletproof way to polyfill this method / check if the object is an error, so it's an enough naive implementation that is marked as `.sham`
- Optimized `DataView.prototype.{ getFloat16, setFloat16 }` performance, [#1379](https://github.com/zloirock/core-js/pull/1379), thanks [**@LeviPesin**](https://github.com/LeviPesin)
- Dropped unneeded feature detection of non-standard `%TypedArray%.prototype.toSpliced`
- Dropped possible re-usage of some non-standard / early stage features (like `Math.scale`) available on global
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
- [`RegExp` escaping](#regexp-escaping)
- [`Math.sumPrecise`](#mathsumprecise)
- [`Symbol.metadata` for decorators metadata proposal](#symbolmetadata-for-decorators-metadata-proposal)
- [`Error.isError`](#erroriserror)
- [Stage 2.7 proposals](#stage-27-proposals)
- [`Iterator` sequencing](#iterator-sequencing)
- [Stage 2 proposals](#stage-2-proposals)
Expand Down Expand Up @@ -2641,6 +2642,33 @@ core-js/proposals/decorator-metadata-v2
core-js(-pure)/actual|full/symbol/metadata
core-js(-pure)/actual|full/function/metadata
```
```
##### [`Error.isError`](https://github.com/tc39/proposal-is-error)[⬆](#index)
Module [`esnext.error.is-error`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.error.is-error.js)
```ts
class Error {
static isError(value: any): boolean;
}
```
[*CommonJS entry points:*](#commonjs-api)
```
core-js/proposals/is-error
core-js(-pure)/actual|full/error/is-error
```
[*Example*](https://tinyurl.com/23nauwoz):
```js
Error.isError(new Error('error')); // => true
Error.isError(new TypeError('error')); // => true
Error.isError(new DOMException('error')); // => true

Error.isError(null); // => false
Error.isError({}); // => false
Error.isError(Object.create(Error.prototype)); // => false
```

> [!WARNING]
> We have no bulletproof way to polyfill this method / check if the object is an error, so it's an enough naive implementation.
#### Stage 2.7 proposals[](#index)
[*CommonJS entry points:*](#commonjs-api)
Expand Down

0 comments on commit b05b0ab

Please sign in to comment.