UNPKG

976 BJavaScriptView Raw
1'use strict';
2var $ = require('../internals/export');
3var getBuiltIn = require('../internals/get-built-in');
4var apply = require('../internals/function-apply');
5var fails = require('../internals/fails');
6var wrapErrorConstructorWithCause = require('../internals/wrap-error-constructor-with-cause');
7
8var AGGREGATE_ERROR = 'AggregateError';
9var $AggregateError = getBuiltIn(AGGREGATE_ERROR);
10
11var FORCED = !fails(function () {
12 return $AggregateError([1]).errors[0] !== 1;
13}) && fails(function () {
14 return $AggregateError([1], AGGREGATE_ERROR, { cause: 7 }).cause !== 7;
15});
16
17// https://tc39.es/ecma262/#sec-aggregate-error
18$({ global: true, constructor: true, arity: 2, forced: FORCED }, {
19 AggregateError: wrapErrorConstructorWithCause(AGGREGATE_ERROR, function (init) {
20 // eslint-disable-next-line no-unused-vars -- required for functions `.length`
21 return function AggregateError(errors, message) { return apply(init, this, arguments); };
22 }, FORCED, true)
23});