1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-24 01:43:18 +00:00
musix-oss/node_modules/core-js/modules/esnext.aggregate-error.js

46 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-03-03 20:30:50 +00:00
'use strict';
var $ = require('../internals/export');
var DESCRIPTORS = require('../internals/descriptors');
var getPrototypeOf = require('../internals/object-get-prototype-of');
var setPrototypeOf = require('../internals/object-set-prototype-of');
var create = require('../internals/object-create');
var defineProperty = require('../internals/object-define-property');
var createPropertyDescriptor = require('../internals/create-property-descriptor');
var iterate = require('../internals/iterate');
var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
var InternalStateModule = require('../internals/internal-state');
var setInternalState = InternalStateModule.set;
var getInternalAggregateErrorState = InternalStateModule.getterFor('AggregateError');
var $AggregateError = function AggregateError(errors, message) {
var that = this;
if (!(that instanceof $AggregateError)) return new $AggregateError(errors, message);
if (setPrototypeOf) {
that = setPrototypeOf(new Error(message), getPrototypeOf(that));
}
var errorsArray = [];
iterate(errors, errorsArray.push, errorsArray);
if (DESCRIPTORS) setInternalState(that, { errors: errorsArray, type: 'AggregateError' });
else that.errors = errorsArray;
if (message !== undefined) createNonEnumerableProperty(that, 'message', String(message));
return that;
};
$AggregateError.prototype = create(Error.prototype, {
constructor: createPropertyDescriptor(5, $AggregateError),
message: createPropertyDescriptor(5, ''),
name: createPropertyDescriptor(5, 'AggregateError')
});
if (DESCRIPTORS) defineProperty.f($AggregateError.prototype, 'errors', {
get: function () {
return getInternalAggregateErrorState(this).errors;
},
configurable: true
});
$({ global: true }, {
AggregateError: $AggregateError
});