Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aggregate-error-ponyfill

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aggregate-error-ponyfill

AggregateError ponyfill.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
359
increased by25.52%
Maintainers
1
Weekly downloads
 
Created
Source

aggregate-error-ponyfill

Build Status BrowserStack Status

AggregateError ponyfill.

The AggregateError object represents an error when several errors need to be wrapped in a single error. It is thrown when multiple errors need to be reported by an operation, for example by Promise.any(), when all promises passed to it reject.

Install

npm install aggregate-error-ponyfill --save

Usage

import AggregateError from 'aggregate-error-ponyfill';

(async () => {
	try {
		await Promise.any([Promise.reject(new Error('some error'))]);
	} catch (e) {
		console.log(e instanceof AggregateError); // true
		console.log(e.message); // "All Promises rejected"
		console.log(e.name); // "AggregateError"
		console.log(e.errors); // [ Error: "some error" ]
	}
})();

try {
	throw new AggregateError([new Error('some error')], 'Hello');
} catch (e) {
	console.log(e instanceof AggregateError); // true
	console.log(e.message); // "Hello"
	console.log(e.name); // "AggregateError"
	console.log(e.errors); // [ Error: "some error" ]
}

You can use named export preferNative if you wish to use native implementation if it’s available. In all other cases, ponyfill will be used. Beware of caveats!

API

AggregateError(errors[, message])

Returns: AggregateError

Method description.

errors

Type: Iterable

An iterable of errors, may not actually be Error instances.

message

Type: string

An optional human-readable description of the aggregate error.

Browser support

Tested in IE11+ and all modern browsers.

It works in older IE versions such as IE9, but you can’t test for instanceof AggregateError due to proper subclassing of native classes.

Test

Test suite is taken and modified from es-shims/AggregateError polyfill.

For automated tests, run npm run test:automated (append :watch for watcher support).

License

MIT © Ivan Nikolić

Keywords

FAQs

Package last updated on 17 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc