Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flex-development/aggregate-error-ponyfill
ECMAScript Proposal spec-compliant ponyfill for AggregateError
https://github.com/flex-development/aggregate-error-ponyfill
aggregate-error ecmascript es-proposal polyfill ponyfill typescript
Last synced: 14 days ago
JSON representation
ECMAScript Proposal spec-compliant ponyfill for AggregateError
- Host: GitHub
- URL: https://github.com/flex-development/aggregate-error-ponyfill
- Owner: flex-development
- License: bsd-3-clause
- Created: 2022-08-27T03:01:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T21:07:58.000Z (about 1 year ago)
- Last Synced: 2025-01-03T23:35:03.724Z (19 days ago)
- Topics: aggregate-error, ecmascript, es-proposal, polyfill, ponyfill, typescript
- Language: JavaScript
- Homepage: https://github.com/flex-development/aggregate-error-ponyfill
- Size: 3.03 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/funding.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# aggregate-error-ponyfill
[![npm](https://img.shields.io/npm/v/@flex-development/aggregate-error-ponyfill.svg)](https://npmjs.com/package/@flex-development/aggregate-error-ponyfill)
[![codecov](https://codecov.io/gh/flex-development/aggregate-error-ponyfill/branch/main/graph/badge.svg?token=5V8UHBYRCS)](https://codecov.io/gh/flex-development/aggregate-error-ponyfill)
[![module type: cjs+esm](https://img.shields.io/badge/module%20type-cjs%2Besm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)
[![license](https://img.shields.io/github/license/flex-development/aggregate-error-ponyfill.svg)](LICENSE.md)
[![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits&logoColor=ffffff)](https://conventionalcommits.org/)
[![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript&logoColor=ffffff)](https://typescriptlang.org/)
[![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat&logo=vitest&logoColor=ffffff)](https://vitest.dev/)
[![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat&logo=yarn&logoColor=ffffff)](https://yarnpkg.com/)[`AggregateError`][1] [ponyfill][2].
## Contents
- [What is this?](#what-is-this)
- [When should I use this?](#when-should-i-use-this)
- [Install](#install)
- [Use](#use)
- [API](#api)
- [Types](#types)
- [Interfaces](#interfaces)
- [Contribute](#contribute)## What is this?
This package is an ECMAScript Proposal spec-compliant [ponyfill][2] for [`AggregateError`][1].
## When should I use this?
Use this package when you want to throw `AggregateError` objects in unsupported environments (`< es2021`).
## Install
```sh
yarn add @flex-development/aggregate-error-ponyfill
```From Git:
```sh
yarn add @flex-development/aggregate-error-ponyfill@flex-development/aggregate-error-ponyfill
```
See Git - Protocols | Yarn
for details on requesting a specific branch, commit, or tag.
## Use
```javascript
import AggregateError from '@flex-development/aggregate-error-ponyfill'try {
throw new AggregateError([new Error('some error')], 'oh no!')
} catch (e) {
console.debug(e instanceof AggregateError) // true
console.error(e.name) // 'AggregateError'
console.error(e.message) // 'oh no!'
console.error(e.errors) // [Error: 'some error']
}
```## API
This package exports no identifiers.
The default export is `AggregateError`.
###
`new AggregateError(errors: Iterable, message?: string, options?: Options)`
Wrap several errors in a single error so that multiple errors can be reported by an operation.
#### `errors`
An iterable of errors.
#### `message`
An optional human-readable description of the aggregate error.
#### `options`
An object that has the following properties:
##### `cause`
The specific cause of the aggregate error.
When catching and re-throwing an error with a more-specific or useful error message, this property can be used to pass
the original error.## Types
This package is fully typed with [TypeScript][3].
### Interfaces
- [`Options`](src/options.ts)
## Contribute
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AggregateError
[2]: https://github.com/sindresorhus/ponyfill
[3]: https://www.typescriptlang.org