es.aggregate-error.cause.js 976 B

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