dinero.js 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3964 @@
1
+ define(function () { 'use strict';
2
+
3
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
+
5
+ function createCommonjsModule(fn, module) {
6
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
7
+ }
8
+
9
+ var check = function (it) {
10
+ return it && it.Math == Math && it;
11
+ };
12
+
13
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
14
+ var global_1 =
15
+ // eslint-disable-next-line no-undef
16
+ check(typeof globalThis == 'object' && globalThis) ||
17
+ check(typeof window == 'object' && window) ||
18
+ check(typeof self == 'object' && self) ||
19
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
20
+ // eslint-disable-next-line no-new-func
21
+ Function('return this')();
22
+
23
+ var fails = function (exec) {
24
+ try {
25
+ return !!exec();
26
+ } catch (error) {
27
+ return true;
28
+ }
29
+ };
30
+
31
+ // Thank's IE8 for his funny defineProperty
32
+ var descriptors = !fails(function () {
33
+ return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
34
+ });
35
+
36
+ var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
37
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
38
+
39
+ // Nashorn ~ JDK8 bug
40
+ var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
41
+
42
+ // `Object.prototype.propertyIsEnumerable` method implementation
43
+ // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
44
+ var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
45
+ var descriptor = getOwnPropertyDescriptor(this, V);
46
+ return !!descriptor && descriptor.enumerable;
47
+ } : nativePropertyIsEnumerable;
48
+
49
+ var objectPropertyIsEnumerable = {
50
+ f: f
51
+ };
52
+
53
+ var createPropertyDescriptor = function (bitmap, value) {
54
+ return {
55
+ enumerable: !(bitmap & 1),
56
+ configurable: !(bitmap & 2),
57
+ writable: !(bitmap & 4),
58
+ value: value
59
+ };
60
+ };
61
+
62
+ var toString = {}.toString;
63
+
64
+ var classofRaw = function (it) {
65
+ return toString.call(it).slice(8, -1);
66
+ };
67
+
68
+ var split = ''.split;
69
+
70
+ // fallback for non-array-like ES3 and non-enumerable old V8 strings
71
+ var indexedObject = fails(function () {
72
+ // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
73
+ // eslint-disable-next-line no-prototype-builtins
74
+ return !Object('z').propertyIsEnumerable(0);
75
+ }) ? function (it) {
76
+ return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
77
+ } : Object;
78
+
79
+ // `RequireObjectCoercible` abstract operation
80
+ // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
81
+ var requireObjectCoercible = function (it) {
82
+ if (it == undefined) throw TypeError("Can't call method on " + it);
83
+ return it;
84
+ };
85
+
86
+ // toObject with fallback for non-array-like ES3 strings
87
+
88
+
89
+
90
+ var toIndexedObject = function (it) {
91
+ return indexedObject(requireObjectCoercible(it));
92
+ };
93
+
94
+ var isObject = function (it) {
95
+ return typeof it === 'object' ? it !== null : typeof it === 'function';
96
+ };
97
+
98
+ // `ToPrimitive` abstract operation
99
+ // https://tc39.github.io/ecma262/#sec-toprimitive
100
+ // instead of the ES6 spec version, we didn't implement @@toPrimitive case
101
+ // and the second argument - flag - preferred type is a string
102
+ var toPrimitive = function (input, PREFERRED_STRING) {
103
+ if (!isObject(input)) return input;
104
+ var fn, val;
105
+ if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
106
+ if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
107
+ if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
108
+ throw TypeError("Can't convert object to primitive value");
109
+ };
110
+
111
+ var hasOwnProperty = {}.hasOwnProperty;
112
+
113
+ var has = function (it, key) {
114
+ return hasOwnProperty.call(it, key);
115
+ };
116
+
117
+ var document$1 = global_1.document;
118
+ // typeof document.createElement is 'object' in old IE
119
+ var EXISTS = isObject(document$1) && isObject(document$1.createElement);
120
+
121
+ var documentCreateElement = function (it) {
122
+ return EXISTS ? document$1.createElement(it) : {};
123
+ };
124
+
125
+ // Thank's IE8 for his funny defineProperty
126
+ var ie8DomDefine = !descriptors && !fails(function () {
127
+ return Object.defineProperty(documentCreateElement('div'), 'a', {
128
+ get: function () { return 7; }
129
+ }).a != 7;
130
+ });
131
+
132
+ var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
133
+
134
+ // `Object.getOwnPropertyDescriptor` method
135
+ // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
136
+ var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
137
+ O = toIndexedObject(O);
138
+ P = toPrimitive(P, true);
139
+ if (ie8DomDefine) try {
140
+ return nativeGetOwnPropertyDescriptor(O, P);
141
+ } catch (error) { /* empty */ }
142
+ if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
143
+ };
144
+
145
+ var objectGetOwnPropertyDescriptor = {
146
+ f: f$1
147
+ };
148
+
149
+ var anObject = function (it) {
150
+ if (!isObject(it)) {
151
+ throw TypeError(String(it) + ' is not an object');
152
+ } return it;
153
+ };
154
+
155
+ var nativeDefineProperty = Object.defineProperty;
156
+
157
+ // `Object.defineProperty` method
158
+ // https://tc39.github.io/ecma262/#sec-object.defineproperty
159
+ var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
160
+ anObject(O);
161
+ P = toPrimitive(P, true);
162
+ anObject(Attributes);
163
+ if (ie8DomDefine) try {
164
+ return nativeDefineProperty(O, P, Attributes);
165
+ } catch (error) { /* empty */ }
166
+ if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
167
+ if ('value' in Attributes) O[P] = Attributes.value;
168
+ return O;
169
+ };
170
+
171
+ var objectDefineProperty = {
172
+ f: f$2
173
+ };
174
+
175
+ var createNonEnumerableProperty = descriptors ? function (object, key, value) {
176
+ return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
177
+ } : function (object, key, value) {
178
+ object[key] = value;
179
+ return object;
180
+ };
181
+
182
+ var setGlobal = function (key, value) {
183
+ try {
184
+ createNonEnumerableProperty(global_1, key, value);
185
+ } catch (error) {
186
+ global_1[key] = value;
187
+ } return value;
188
+ };
189
+
190
+ var SHARED = '__core-js_shared__';
191
+ var store = global_1[SHARED] || setGlobal(SHARED, {});
192
+
193
+ var sharedStore = store;
194
+
195
+ var functionToString = Function.toString;
196
+
197
+ // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
198
+ if (typeof sharedStore.inspectSource != 'function') {
199
+ sharedStore.inspectSource = function (it) {
200
+ return functionToString.call(it);
201
+ };
202
+ }
203
+
204
+ var inspectSource = sharedStore.inspectSource;
205
+
206
+ var WeakMap = global_1.WeakMap;
207
+
208
+ var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));
209
+
210
+ var shared = createCommonjsModule(function (module) {
211
+ (module.exports = function (key, value) {
212
+ return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
213
+ })('versions', []).push({
214
+ version: '3.6.5',
215
+ mode: 'global',
216
+ copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
217
+ });
218
+ });
219
+
220
+ var id = 0;
221
+ var postfix = Math.random();
222
+
223
+ var uid = function (key) {
224
+ return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
225
+ };
226
+
227
+ var keys = shared('keys');
228
+
229
+ var sharedKey = function (key) {
230
+ return keys[key] || (keys[key] = uid(key));
231
+ };
232
+
233
+ var hiddenKeys = {};
234
+
235
+ var WeakMap$1 = global_1.WeakMap;
236
+ var set, get, has$1;
237
+
238
+ var enforce = function (it) {
239
+ return has$1(it) ? get(it) : set(it, {});
240
+ };
241
+
242
+ var getterFor = function (TYPE) {
243
+ return function (it) {
244
+ var state;
245
+ if (!isObject(it) || (state = get(it)).type !== TYPE) {
246
+ throw TypeError('Incompatible receiver, ' + TYPE + ' required');
247
+ } return state;
248
+ };
249
+ };
250
+
251
+ if (nativeWeakMap) {
252
+ var store$1 = new WeakMap$1();
253
+ var wmget = store$1.get;
254
+ var wmhas = store$1.has;
255
+ var wmset = store$1.set;
256
+ set = function (it, metadata) {
257
+ wmset.call(store$1, it, metadata);
258
+ return metadata;
259
+ };
260
+ get = function (it) {
261
+ return wmget.call(store$1, it) || {};
262
+ };
263
+ has$1 = function (it) {
264
+ return wmhas.call(store$1, it);
265
+ };
266
+ } else {
267
+ var STATE = sharedKey('state');
268
+ hiddenKeys[STATE] = true;
269
+ set = function (it, metadata) {
270
+ createNonEnumerableProperty(it, STATE, metadata);
271
+ return metadata;
272
+ };
273
+ get = function (it) {
274
+ return has(it, STATE) ? it[STATE] : {};
275
+ };
276
+ has$1 = function (it) {
277
+ return has(it, STATE);
278
+ };
279
+ }
280
+
281
+ var internalState = {
282
+ set: set,
283
+ get: get,
284
+ has: has$1,
285
+ enforce: enforce,
286
+ getterFor: getterFor
287
+ };
288
+
289
+ var redefine = createCommonjsModule(function (module) {
290
+ var getInternalState = internalState.get;
291
+ var enforceInternalState = internalState.enforce;
292
+ var TEMPLATE = String(String).split('String');
293
+
294
+ (module.exports = function (O, key, value, options) {
295
+ var unsafe = options ? !!options.unsafe : false;
296
+ var simple = options ? !!options.enumerable : false;
297
+ var noTargetGet = options ? !!options.noTargetGet : false;
298
+ if (typeof value == 'function') {
299
+ if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);
300
+ enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
301
+ }
302
+ if (O === global_1) {
303
+ if (simple) O[key] = value;
304
+ else setGlobal(key, value);
305
+ return;
306
+ } else if (!unsafe) {
307
+ delete O[key];
308
+ } else if (!noTargetGet && O[key]) {
309
+ simple = true;
310
+ }
311
+ if (simple) O[key] = value;
312
+ else createNonEnumerableProperty(O, key, value);
313
+ // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
314
+ })(Function.prototype, 'toString', function toString() {
315
+ return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
316
+ });
317
+ });
318
+
319
+ var path = global_1;
320
+
321
+ var aFunction = function (variable) {
322
+ return typeof variable == 'function' ? variable : undefined;
323
+ };
324
+
325
+ var getBuiltIn = function (namespace, method) {
326
+ return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace])
327
+ : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
328
+ };
329
+
330
+ var ceil = Math.ceil;
331
+ var floor = Math.floor;
332
+
333
+ // `ToInteger` abstract operation
334
+ // https://tc39.github.io/ecma262/#sec-tointeger
335
+ var toInteger = function (argument) {
336
+ return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
337
+ };
338
+
339
+ var min = Math.min;
340
+
341
+ // `ToLength` abstract operation
342
+ // https://tc39.github.io/ecma262/#sec-tolength
343
+ var toLength = function (argument) {
344
+ return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
345
+ };
346
+
347
+ var max = Math.max;
348
+ var min$1 = Math.min;
349
+
350
+ // Helper for a popular repeating case of the spec:
351
+ // Let integer be ? ToInteger(index).
352
+ // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
353
+ var toAbsoluteIndex = function (index, length) {
354
+ var integer = toInteger(index);
355
+ return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
356
+ };
357
+
358
+ // `Array.prototype.{ indexOf, includes }` methods implementation
359
+ var createMethod = function (IS_INCLUDES) {
360
+ return function ($this, el, fromIndex) {
361
+ var O = toIndexedObject($this);
362
+ var length = toLength(O.length);
363
+ var index = toAbsoluteIndex(fromIndex, length);
364
+ var value;
365
+ // Array#includes uses SameValueZero equality algorithm
366
+ // eslint-disable-next-line no-self-compare
367
+ if (IS_INCLUDES && el != el) while (length > index) {
368
+ value = O[index++];
369
+ // eslint-disable-next-line no-self-compare
370
+ if (value != value) return true;
371
+ // Array#indexOf ignores holes, Array#includes - not
372
+ } else for (;length > index; index++) {
373
+ if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
374
+ } return !IS_INCLUDES && -1;
375
+ };
376
+ };
377
+
378
+ var arrayIncludes = {
379
+ // `Array.prototype.includes` method
380
+ // https://tc39.github.io/ecma262/#sec-array.prototype.includes
381
+ includes: createMethod(true),
382
+ // `Array.prototype.indexOf` method
383
+ // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
384
+ indexOf: createMethod(false)
385
+ };
386
+
387
+ var indexOf = arrayIncludes.indexOf;
388
+
389
+
390
+ var objectKeysInternal = function (object, names) {
391
+ var O = toIndexedObject(object);
392
+ var i = 0;
393
+ var result = [];
394
+ var key;
395
+ for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
396
+ // Don't enum bug & hidden keys
397
+ while (names.length > i) if (has(O, key = names[i++])) {
398
+ ~indexOf(result, key) || result.push(key);
399
+ }
400
+ return result;
401
+ };
402
+
403
+ // IE8- don't enum bug keys
404
+ var enumBugKeys = [
405
+ 'constructor',
406
+ 'hasOwnProperty',
407
+ 'isPrototypeOf',
408
+ 'propertyIsEnumerable',
409
+ 'toLocaleString',
410
+ 'toString',
411
+ 'valueOf'
412
+ ];
413
+
414
+ var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
415
+
416
+ // `Object.getOwnPropertyNames` method
417
+ // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
418
+ var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
419
+ return objectKeysInternal(O, hiddenKeys$1);
420
+ };
421
+
422
+ var objectGetOwnPropertyNames = {
423
+ f: f$3
424
+ };
425
+
426
+ var f$4 = Object.getOwnPropertySymbols;
427
+
428
+ var objectGetOwnPropertySymbols = {
429
+ f: f$4
430
+ };
431
+
432
+ // all object keys, includes non-enumerable and symbols
433
+ var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
434
+ var keys = objectGetOwnPropertyNames.f(anObject(it));
435
+ var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
436
+ return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
437
+ };
438
+
439
+ var copyConstructorProperties = function (target, source) {
440
+ var keys = ownKeys(source);
441
+ var defineProperty = objectDefineProperty.f;
442
+ var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
443
+ for (var i = 0; i < keys.length; i++) {
444
+ var key = keys[i];
445
+ if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
446
+ }
447
+ };
448
+
449
+ var replacement = /#|\.prototype\./;
450
+
451
+ var isForced = function (feature, detection) {
452
+ var value = data[normalize(feature)];
453
+ return value == POLYFILL ? true
454
+ : value == NATIVE ? false
455
+ : typeof detection == 'function' ? fails(detection)
456
+ : !!detection;
457
+ };
458
+
459
+ var normalize = isForced.normalize = function (string) {
460
+ return String(string).replace(replacement, '.').toLowerCase();
461
+ };
462
+
463
+ var data = isForced.data = {};
464
+ var NATIVE = isForced.NATIVE = 'N';
465
+ var POLYFILL = isForced.POLYFILL = 'P';
466
+
467
+ var isForced_1 = isForced;
468
+
469
+ var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
470
+
471
+
472
+
473
+
474
+
475
+
476
+ /*
477
+ options.target - name of the target object
478
+ options.global - target is the global object
479
+ options.stat - export as static methods of target
480
+ options.proto - export as prototype methods of target
481
+ options.real - real prototype method for the `pure` version
482
+ options.forced - export even if the native feature is available
483
+ options.bind - bind methods to the target, required for the `pure` version
484
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
485
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
486
+ options.sham - add a flag to not completely full polyfills
487
+ options.enumerable - export as enumerable property
488
+ options.noTargetGet - prevent calling a getter on target
489
+ */
490
+ var _export = function (options, source) {
491
+ var TARGET = options.target;
492
+ var GLOBAL = options.global;
493
+ var STATIC = options.stat;
494
+ var FORCED, target, key, targetProperty, sourceProperty, descriptor;
495
+ if (GLOBAL) {
496
+ target = global_1;
497
+ } else if (STATIC) {
498
+ target = global_1[TARGET] || setGlobal(TARGET, {});
499
+ } else {
500
+ target = (global_1[TARGET] || {}).prototype;
501
+ }
502
+ if (target) for (key in source) {
503
+ sourceProperty = source[key];
504
+ if (options.noTargetGet) {
505
+ descriptor = getOwnPropertyDescriptor$1(target, key);
506
+ targetProperty = descriptor && descriptor.value;
507
+ } else targetProperty = target[key];
508
+ FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
509
+ // contained in target
510
+ if (!FORCED && targetProperty !== undefined) {
511
+ if (typeof sourceProperty === typeof targetProperty) continue;
512
+ copyConstructorProperties(sourceProperty, targetProperty);
513
+ }
514
+ // add a flag to not completely full polyfills
515
+ if (options.sham || (targetProperty && targetProperty.sham)) {
516
+ createNonEnumerableProperty(sourceProperty, 'sham', true);
517
+ }
518
+ // extend global
519
+ redefine(target, key, sourceProperty, options);
520
+ }
521
+ };
522
+
523
+ var aFunction$1 = function (it) {
524
+ if (typeof it != 'function') {
525
+ throw TypeError(String(it) + ' is not a function');
526
+ } return it;
527
+ };
528
+
529
+ // optional / simple context binding
530
+ var functionBindContext = function (fn, that, length) {
531
+ aFunction$1(fn);
532
+ if (that === undefined) return fn;
533
+ switch (length) {
534
+ case 0: return function () {
535
+ return fn.call(that);
536
+ };
537
+ case 1: return function (a) {
538
+ return fn.call(that, a);
539
+ };
540
+ case 2: return function (a, b) {
541
+ return fn.call(that, a, b);
542
+ };
543
+ case 3: return function (a, b, c) {
544
+ return fn.call(that, a, b, c);
545
+ };
546
+ }
547
+ return function (/* ...args */) {
548
+ return fn.apply(that, arguments);
549
+ };
550
+ };
551
+
552
+ // `ToObject` abstract operation
553
+ // https://tc39.github.io/ecma262/#sec-toobject
554
+ var toObject = function (argument) {
555
+ return Object(requireObjectCoercible(argument));
556
+ };
557
+
558
+ // `IsArray` abstract operation
559
+ // https://tc39.github.io/ecma262/#sec-isarray
560
+ var isArray = Array.isArray || function isArray(arg) {
561
+ return classofRaw(arg) == 'Array';
562
+ };
563
+
564
+ var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
565
+ // Chrome 38 Symbol has incorrect toString conversion
566
+ // eslint-disable-next-line no-undef
567
+ return !String(Symbol());
568
+ });
569
+
570
+ var useSymbolAsUid = nativeSymbol
571
+ // eslint-disable-next-line no-undef
572
+ && !Symbol.sham
573
+ // eslint-disable-next-line no-undef
574
+ && typeof Symbol.iterator == 'symbol';
575
+
576
+ var WellKnownSymbolsStore = shared('wks');
577
+ var Symbol$1 = global_1.Symbol;
578
+ var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
579
+
580
+ var wellKnownSymbol = function (name) {
581
+ if (!has(WellKnownSymbolsStore, name)) {
582
+ if (nativeSymbol && has(Symbol$1, name)) WellKnownSymbolsStore[name] = Symbol$1[name];
583
+ else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
584
+ } return WellKnownSymbolsStore[name];
585
+ };
586
+
587
+ var SPECIES = wellKnownSymbol('species');
588
+
589
+ // `ArraySpeciesCreate` abstract operation
590
+ // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
591
+ var arraySpeciesCreate = function (originalArray, length) {
592
+ var C;
593
+ if (isArray(originalArray)) {
594
+ C = originalArray.constructor;
595
+ // cross-realm fallback
596
+ if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
597
+ else if (isObject(C)) {
598
+ C = C[SPECIES];
599
+ if (C === null) C = undefined;
600
+ }
601
+ } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
602
+ };
603
+
604
+ var push = [].push;
605
+
606
+ // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
607
+ var createMethod$1 = function (TYPE) {
608
+ var IS_MAP = TYPE == 1;
609
+ var IS_FILTER = TYPE == 2;
610
+ var IS_SOME = TYPE == 3;
611
+ var IS_EVERY = TYPE == 4;
612
+ var IS_FIND_INDEX = TYPE == 6;
613
+ var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
614
+ return function ($this, callbackfn, that, specificCreate) {
615
+ var O = toObject($this);
616
+ var self = indexedObject(O);
617
+ var boundFunction = functionBindContext(callbackfn, that, 3);
618
+ var length = toLength(self.length);
619
+ var index = 0;
620
+ var create = specificCreate || arraySpeciesCreate;
621
+ var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
622
+ var value, result;
623
+ for (;length > index; index++) if (NO_HOLES || index in self) {
624
+ value = self[index];
625
+ result = boundFunction(value, index, O);
626
+ if (TYPE) {
627
+ if (IS_MAP) target[index] = result; // map
628
+ else if (result) switch (TYPE) {
629
+ case 3: return true; // some
630
+ case 5: return value; // find
631
+ case 6: return index; // findIndex
632
+ case 2: push.call(target, value); // filter
633
+ } else if (IS_EVERY) return false; // every
634
+ }
635
+ }
636
+ return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
637
+ };
638
+ };
639
+
640
+ var arrayIteration = {
641
+ // `Array.prototype.forEach` method
642
+ // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
643
+ forEach: createMethod$1(0),
644
+ // `Array.prototype.map` method
645
+ // https://tc39.github.io/ecma262/#sec-array.prototype.map
646
+ map: createMethod$1(1),
647
+ // `Array.prototype.filter` method
648
+ // https://tc39.github.io/ecma262/#sec-array.prototype.filter
649
+ filter: createMethod$1(2),
650
+ // `Array.prototype.some` method
651
+ // https://tc39.github.io/ecma262/#sec-array.prototype.some
652
+ some: createMethod$1(3),
653
+ // `Array.prototype.every` method
654
+ // https://tc39.github.io/ecma262/#sec-array.prototype.every
655
+ every: createMethod$1(4),
656
+ // `Array.prototype.find` method
657
+ // https://tc39.github.io/ecma262/#sec-array.prototype.find
658
+ find: createMethod$1(5),
659
+ // `Array.prototype.findIndex` method
660
+ // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
661
+ findIndex: createMethod$1(6)
662
+ };
663
+
664
+ var arrayMethodIsStrict = function (METHOD_NAME, argument) {
665
+ var method = [][METHOD_NAME];
666
+ return !!method && fails(function () {
667
+ // eslint-disable-next-line no-useless-call,no-throw-literal
668
+ method.call(null, argument || function () { throw 1; }, 1);
669
+ });
670
+ };
671
+
672
+ var defineProperty = Object.defineProperty;
673
+ var cache = {};
674
+
675
+ var thrower = function (it) { throw it; };
676
+
677
+ var arrayMethodUsesToLength = function (METHOD_NAME, options) {
678
+ if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];
679
+ if (!options) options = {};
680
+ var method = [][METHOD_NAME];
681
+ var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
682
+ var argument0 = has(options, 0) ? options[0] : thrower;
683
+ var argument1 = has(options, 1) ? options[1] : undefined;
684
+
685
+ return cache[METHOD_NAME] = !!method && !fails(function () {
686
+ if (ACCESSORS && !descriptors) return true;
687
+ var O = { length: -1 };
688
+
689
+ if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower });
690
+ else O[1] = 1;
691
+
692
+ method.call(O, argument0, argument1);
693
+ });
694
+ };
695
+
696
+ var $every = arrayIteration.every;
697
+
698
+
699
+
700
+ var STRICT_METHOD = arrayMethodIsStrict('every');
701
+ var USES_TO_LENGTH = arrayMethodUsesToLength('every');
702
+
703
+ // `Array.prototype.every` method
704
+ // https://tc39.github.io/ecma262/#sec-array.prototype.every
705
+ _export({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {
706
+ every: function every(callbackfn /* , thisArg */) {
707
+ return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
708
+ }
709
+ });
710
+
711
+ var call = Function.call;
712
+
713
+ var entryUnbind = function (CONSTRUCTOR, METHOD, length) {
714
+ return functionBindContext(call, global_1[CONSTRUCTOR].prototype[METHOD], length);
715
+ };
716
+
717
+ var every = entryUnbind('Array', 'every');
718
+
719
+ // `Object.keys` method
720
+ // https://tc39.github.io/ecma262/#sec-object.keys
721
+ var objectKeys = Object.keys || function keys(O) {
722
+ return objectKeysInternal(O, enumBugKeys);
723
+ };
724
+
725
+ // `Object.defineProperties` method
726
+ // https://tc39.github.io/ecma262/#sec-object.defineproperties
727
+ var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
728
+ anObject(O);
729
+ var keys = objectKeys(Properties);
730
+ var length = keys.length;
731
+ var index = 0;
732
+ var key;
733
+ while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]);
734
+ return O;
735
+ };
736
+
737
+ var html = getBuiltIn('document', 'documentElement');
738
+
739
+ var GT = '>';
740
+ var LT = '<';
741
+ var PROTOTYPE = 'prototype';
742
+ var SCRIPT = 'script';
743
+ var IE_PROTO = sharedKey('IE_PROTO');
744
+
745
+ var EmptyConstructor = function () { /* empty */ };
746
+
747
+ var scriptTag = function (content) {
748
+ return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
749
+ };
750
+
751
+ // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
752
+ var NullProtoObjectViaActiveX = function (activeXDocument) {
753
+ activeXDocument.write(scriptTag(''));
754
+ activeXDocument.close();
755
+ var temp = activeXDocument.parentWindow.Object;
756
+ activeXDocument = null; // avoid memory leak
757
+ return temp;
758
+ };
759
+
760
+ // Create object with fake `null` prototype: use iframe Object with cleared prototype
761
+ var NullProtoObjectViaIFrame = function () {
762
+ // Thrash, waste and sodomy: IE GC bug
763
+ var iframe = documentCreateElement('iframe');
764
+ var JS = 'java' + SCRIPT + ':';
765
+ var iframeDocument;
766
+ iframe.style.display = 'none';
767
+ html.appendChild(iframe);
768
+ // https://github.com/zloirock/core-js/issues/475
769
+ iframe.src = String(JS);
770
+ iframeDocument = iframe.contentWindow.document;
771
+ iframeDocument.open();
772
+ iframeDocument.write(scriptTag('document.F=Object'));
773
+ iframeDocument.close();
774
+ return iframeDocument.F;
775
+ };
776
+
777
+ // Check for document.domain and active x support
778
+ // No need to use active x approach when document.domain is not set
779
+ // see https://github.com/es-shims/es5-shim/issues/150
780
+ // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
781
+ // avoid IE GC bug
782
+ var activeXDocument;
783
+ var NullProtoObject = function () {
784
+ try {
785
+ /* global ActiveXObject */
786
+ activeXDocument = document.domain && new ActiveXObject('htmlfile');
787
+ } catch (error) { /* ignore */ }
788
+ NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
789
+ var length = enumBugKeys.length;
790
+ while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
791
+ return NullProtoObject();
792
+ };
793
+
794
+ hiddenKeys[IE_PROTO] = true;
795
+
796
+ // `Object.create` method
797
+ // https://tc39.github.io/ecma262/#sec-object.create
798
+ var objectCreate = Object.create || function create(O, Properties) {
799
+ var result;
800
+ if (O !== null) {
801
+ EmptyConstructor[PROTOTYPE] = anObject(O);
802
+ result = new EmptyConstructor();
803
+ EmptyConstructor[PROTOTYPE] = null;
804
+ // add "__proto__" for Object.getPrototypeOf polyfill
805
+ result[IE_PROTO] = O;
806
+ } else result = NullProtoObject();
807
+ return Properties === undefined ? result : objectDefineProperties(result, Properties);
808
+ };
809
+
810
+ var UNSCOPABLES = wellKnownSymbol('unscopables');
811
+ var ArrayPrototype = Array.prototype;
812
+
813
+ // Array.prototype[@@unscopables]
814
+ // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
815
+ if (ArrayPrototype[UNSCOPABLES] == undefined) {
816
+ objectDefineProperty.f(ArrayPrototype, UNSCOPABLES, {
817
+ configurable: true,
818
+ value: objectCreate(null)
819
+ });
820
+ }
821
+
822
+ // add a key to Array.prototype[@@unscopables]
823
+ var addToUnscopables = function (key) {
824
+ ArrayPrototype[UNSCOPABLES][key] = true;
825
+ };
826
+
827
+ var $findIndex = arrayIteration.findIndex;
828
+
829
+
830
+
831
+ var FIND_INDEX = 'findIndex';
832
+ var SKIPS_HOLES = true;
833
+
834
+ var USES_TO_LENGTH$1 = arrayMethodUsesToLength(FIND_INDEX);
835
+
836
+ // Shouldn't skip holes
837
+ if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });
838
+
839
+ // `Array.prototype.findIndex` method
840
+ // https://tc39.github.io/ecma262/#sec-array.prototype.findindex
841
+ _export({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH$1 }, {
842
+ findIndex: function findIndex(callbackfn /* , that = undefined */) {
843
+ return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
844
+ }
845
+ });
846
+
847
+ // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
848
+ addToUnscopables(FIND_INDEX);
849
+
850
+ var findIndex = entryUnbind('Array', 'findIndex');
851
+
852
+ var $find = arrayIteration.find;
853
+
854
+
855
+
856
+ var FIND = 'find';
857
+ var SKIPS_HOLES$1 = true;
858
+
859
+ var USES_TO_LENGTH$2 = arrayMethodUsesToLength(FIND);
860
+
861
+ // Shouldn't skip holes
862
+ if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES$1 = false; });
863
+
864
+ // `Array.prototype.find` method
865
+ // https://tc39.github.io/ecma262/#sec-array.prototype.find
866
+ _export({ target: 'Array', proto: true, forced: SKIPS_HOLES$1 || !USES_TO_LENGTH$2 }, {
867
+ find: function find(callbackfn /* , that = undefined */) {
868
+ return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
869
+ }
870
+ });
871
+
872
+ // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
873
+ addToUnscopables(FIND);
874
+
875
+ var find = entryUnbind('Array', 'find');
876
+
877
+ var iterators = {};
878
+
879
+ var correctPrototypeGetter = !fails(function () {
880
+ function F() { /* empty */ }
881
+ F.prototype.constructor = null;
882
+ return Object.getPrototypeOf(new F()) !== F.prototype;
883
+ });
884
+
885
+ var IE_PROTO$1 = sharedKey('IE_PROTO');
886
+ var ObjectPrototype = Object.prototype;
887
+
888
+ // `Object.getPrototypeOf` method
889
+ // https://tc39.github.io/ecma262/#sec-object.getprototypeof
890
+ var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) {
891
+ O = toObject(O);
892
+ if (has(O, IE_PROTO$1)) return O[IE_PROTO$1];
893
+ if (typeof O.constructor == 'function' && O instanceof O.constructor) {
894
+ return O.constructor.prototype;
895
+ } return O instanceof Object ? ObjectPrototype : null;
896
+ };
897
+
898
+ var ITERATOR = wellKnownSymbol('iterator');
899
+ var BUGGY_SAFARI_ITERATORS = false;
900
+
901
+ var returnThis = function () { return this; };
902
+
903
+ // `%IteratorPrototype%` object
904
+ // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
905
+ var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
906
+
907
+ if ([].keys) {
908
+ arrayIterator = [].keys();
909
+ // Safari 8 has buggy iterators w/o `next`
910
+ if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
911
+ else {
912
+ PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
913
+ if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
914
+ }
915
+ }
916
+
917
+ if (IteratorPrototype == undefined) IteratorPrototype = {};
918
+
919
+ // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
920
+ if ( !has(IteratorPrototype, ITERATOR)) {
921
+ createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
922
+ }
923
+
924
+ var iteratorsCore = {
925
+ IteratorPrototype: IteratorPrototype,
926
+ BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
927
+ };
928
+
929
+ var defineProperty$1 = objectDefineProperty.f;
930
+
931
+
932
+
933
+ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
934
+
935
+ var setToStringTag = function (it, TAG, STATIC) {
936
+ if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
937
+ defineProperty$1(it, TO_STRING_TAG, { configurable: true, value: TAG });
938
+ }
939
+ };
940
+
941
+ var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
942
+
943
+
944
+
945
+
946
+
947
+ var returnThis$1 = function () { return this; };
948
+
949
+ var createIteratorConstructor = function (IteratorConstructor, NAME, next) {
950
+ var TO_STRING_TAG = NAME + ' Iterator';
951
+ IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(1, next) });
952
+ setToStringTag(IteratorConstructor, TO_STRING_TAG, false);
953
+ iterators[TO_STRING_TAG] = returnThis$1;
954
+ return IteratorConstructor;
955
+ };
956
+
957
+ var aPossiblePrototype = function (it) {
958
+ if (!isObject(it) && it !== null) {
959
+ throw TypeError("Can't set " + String(it) + ' as a prototype');
960
+ } return it;
961
+ };
962
+
963
+ // `Object.setPrototypeOf` method
964
+ // https://tc39.github.io/ecma262/#sec-object.setprototypeof
965
+ // Works with __proto__ only. Old v8 can't work with null proto objects.
966
+ /* eslint-disable no-proto */
967
+ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
968
+ var CORRECT_SETTER = false;
969
+ var test = {};
970
+ var setter;
971
+ try {
972
+ setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
973
+ setter.call(test, []);
974
+ CORRECT_SETTER = test instanceof Array;
975
+ } catch (error) { /* empty */ }
976
+ return function setPrototypeOf(O, proto) {
977
+ anObject(O);
978
+ aPossiblePrototype(proto);
979
+ if (CORRECT_SETTER) setter.call(O, proto);
980
+ else O.__proto__ = proto;
981
+ return O;
982
+ };
983
+ }() : undefined);
984
+
985
+ var IteratorPrototype$2 = iteratorsCore.IteratorPrototype;
986
+ var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS;
987
+ var ITERATOR$1 = wellKnownSymbol('iterator');
988
+ var KEYS = 'keys';
989
+ var VALUES = 'values';
990
+ var ENTRIES = 'entries';
991
+
992
+ var returnThis$2 = function () { return this; };
993
+
994
+ var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
995
+ createIteratorConstructor(IteratorConstructor, NAME, next);
996
+
997
+ var getIterationMethod = function (KIND) {
998
+ if (KIND === DEFAULT && defaultIterator) return defaultIterator;
999
+ if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND];
1000
+ switch (KIND) {
1001
+ case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
1002
+ case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
1003
+ case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
1004
+ } return function () { return new IteratorConstructor(this); };
1005
+ };
1006
+
1007
+ var TO_STRING_TAG = NAME + ' Iterator';
1008
+ var INCORRECT_VALUES_NAME = false;
1009
+ var IterablePrototype = Iterable.prototype;
1010
+ var nativeIterator = IterablePrototype[ITERATOR$1]
1011
+ || IterablePrototype['@@iterator']
1012
+ || DEFAULT && IterablePrototype[DEFAULT];
1013
+ var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT);
1014
+ var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
1015
+ var CurrentIteratorPrototype, methods, KEY;
1016
+
1017
+ // fix native
1018
+ if (anyNativeIterator) {
1019
+ CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
1020
+ if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) {
1021
+ if ( objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) {
1022
+ if (objectSetPrototypeOf) {
1023
+ objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2);
1024
+ } else if (typeof CurrentIteratorPrototype[ITERATOR$1] != 'function') {
1025
+ createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR$1, returnThis$2);
1026
+ }
1027
+ }
1028
+ // Set @@toStringTag to native iterators
1029
+ setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true);
1030
+ }
1031
+ }
1032
+
1033
+ // fix Array#{values, @@iterator}.name in V8 / FF
1034
+ if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
1035
+ INCORRECT_VALUES_NAME = true;
1036
+ defaultIterator = function values() { return nativeIterator.call(this); };
1037
+ }
1038
+
1039
+ // define iterator
1040
+ if ( IterablePrototype[ITERATOR$1] !== defaultIterator) {
1041
+ createNonEnumerableProperty(IterablePrototype, ITERATOR$1, defaultIterator);
1042
+ }
1043
+ iterators[NAME] = defaultIterator;
1044
+
1045
+ // export additional methods
1046
+ if (DEFAULT) {
1047
+ methods = {
1048
+ values: getIterationMethod(VALUES),
1049
+ keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
1050
+ entries: getIterationMethod(ENTRIES)
1051
+ };
1052
+ if (FORCED) for (KEY in methods) {
1053
+ if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1054
+ redefine(IterablePrototype, KEY, methods[KEY]);
1055
+ }
1056
+ } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods);
1057
+ }
1058
+
1059
+ return methods;
1060
+ };
1061
+
1062
+ var ARRAY_ITERATOR = 'Array Iterator';
1063
+ var setInternalState = internalState.set;
1064
+ var getInternalState = internalState.getterFor(ARRAY_ITERATOR);
1065
+
1066
+ // `Array.prototype.entries` method
1067
+ // https://tc39.github.io/ecma262/#sec-array.prototype.entries
1068
+ // `Array.prototype.keys` method
1069
+ // https://tc39.github.io/ecma262/#sec-array.prototype.keys
1070
+ // `Array.prototype.values` method
1071
+ // https://tc39.github.io/ecma262/#sec-array.prototype.values
1072
+ // `Array.prototype[@@iterator]` method
1073
+ // https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
1074
+ // `CreateArrayIterator` internal method
1075
+ // https://tc39.github.io/ecma262/#sec-createarrayiterator
1076
+ var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
1077
+ setInternalState(this, {
1078
+ type: ARRAY_ITERATOR,
1079
+ target: toIndexedObject(iterated), // target
1080
+ index: 0, // next index
1081
+ kind: kind // kind
1082
+ });
1083
+ // `%ArrayIteratorPrototype%.next` method
1084
+ // https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
1085
+ }, function () {
1086
+ var state = getInternalState(this);
1087
+ var target = state.target;
1088
+ var kind = state.kind;
1089
+ var index = state.index++;
1090
+ if (!target || index >= target.length) {
1091
+ state.target = undefined;
1092
+ return { value: undefined, done: true };
1093
+ }
1094
+ if (kind == 'keys') return { value: index, done: false };
1095
+ if (kind == 'values') return { value: target[index], done: false };
1096
+ return { value: [index, target[index]], done: false };
1097
+ }, 'values');
1098
+
1099
+ // argumentsList[@@iterator] is %ArrayProto_values%
1100
+ // https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
1101
+ // https://tc39.github.io/ecma262/#sec-createmappedargumentsobject
1102
+ iterators.Arguments = iterators.Array;
1103
+
1104
+ // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
1105
+ addToUnscopables('keys');
1106
+ addToUnscopables('values');
1107
+ addToUnscopables('entries');
1108
+
1109
+ var keys$1 = entryUnbind('Array', 'keys');
1110
+
1111
+ var $some = arrayIteration.some;
1112
+
1113
+
1114
+
1115
+ var STRICT_METHOD$1 = arrayMethodIsStrict('some');
1116
+ var USES_TO_LENGTH$3 = arrayMethodUsesToLength('some');
1117
+
1118
+ // `Array.prototype.some` method
1119
+ // https://tc39.github.io/ecma262/#sec-array.prototype.some
1120
+ _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$1 || !USES_TO_LENGTH$3 }, {
1121
+ some: function some(callbackfn /* , thisArg */) {
1122
+ return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
1123
+ }
1124
+ });
1125
+
1126
+ var some = entryUnbind('Array', 'some');
1127
+
1128
+ var nativeAssign = Object.assign;
1129
+ var defineProperty$2 = Object.defineProperty;
1130
+
1131
+ // `Object.assign` method
1132
+ // https://tc39.github.io/ecma262/#sec-object.assign
1133
+ var objectAssign = !nativeAssign || fails(function () {
1134
+ // should have correct order of operations (Edge bug)
1135
+ if (descriptors && nativeAssign({ b: 1 }, nativeAssign(defineProperty$2({}, 'a', {
1136
+ enumerable: true,
1137
+ get: function () {
1138
+ defineProperty$2(this, 'b', {
1139
+ value: 3,
1140
+ enumerable: false
1141
+ });
1142
+ }
1143
+ }), { b: 2 })).b !== 1) return true;
1144
+ // should work with symbols and should have deterministic property order (V8 bug)
1145
+ var A = {};
1146
+ var B = {};
1147
+ // eslint-disable-next-line no-undef
1148
+ var symbol = Symbol();
1149
+ var alphabet = 'abcdefghijklmnopqrst';
1150
+ A[symbol] = 7;
1151
+ alphabet.split('').forEach(function (chr) { B[chr] = chr; });
1152
+ return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
1153
+ }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
1154
+ var T = toObject(target);
1155
+ var argumentsLength = arguments.length;
1156
+ var index = 1;
1157
+ var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
1158
+ var propertyIsEnumerable = objectPropertyIsEnumerable.f;
1159
+ while (argumentsLength > index) {
1160
+ var S = indexedObject(arguments[index++]);
1161
+ var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
1162
+ var length = keys.length;
1163
+ var j = 0;
1164
+ var key;
1165
+ while (length > j) {
1166
+ key = keys[j++];
1167
+ if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key];
1168
+ }
1169
+ } return T;
1170
+ } : nativeAssign;
1171
+
1172
+ // `Object.assign` method
1173
+ // https://tc39.github.io/ecma262/#sec-object.assign
1174
+ _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, {
1175
+ assign: objectAssign
1176
+ });
1177
+
1178
+ var assign = path.Object.assign;
1179
+
1180
+ var propertyIsEnumerable = objectPropertyIsEnumerable.f;
1181
+
1182
+ // `Object.{ entries, values }` methods implementation
1183
+ var createMethod$2 = function (TO_ENTRIES) {
1184
+ return function (it) {
1185
+ var O = toIndexedObject(it);
1186
+ var keys = objectKeys(O);
1187
+ var length = keys.length;
1188
+ var i = 0;
1189
+ var result = [];
1190
+ var key;
1191
+ while (length > i) {
1192
+ key = keys[i++];
1193
+ if (!descriptors || propertyIsEnumerable.call(O, key)) {
1194
+ result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
1195
+ }
1196
+ }
1197
+ return result;
1198
+ };
1199
+ };
1200
+
1201
+ var objectToArray = {
1202
+ // `Object.entries` method
1203
+ // https://tc39.github.io/ecma262/#sec-object.entries
1204
+ entries: createMethod$2(true),
1205
+ // `Object.values` method
1206
+ // https://tc39.github.io/ecma262/#sec-object.values
1207
+ values: createMethod$2(false)
1208
+ };
1209
+
1210
+ var $entries = objectToArray.entries;
1211
+
1212
+ // `Object.entries` method
1213
+ // https://tc39.github.io/ecma262/#sec-object.entries
1214
+ _export({ target: 'Object', stat: true }, {
1215
+ entries: function entries(O) {
1216
+ return $entries(O);
1217
+ }
1218
+ });
1219
+
1220
+ var entries = path.Object.entries;
1221
+
1222
+ var floor$1 = Math.floor;
1223
+
1224
+ // `Number.isInteger` method implementation
1225
+ // https://tc39.github.io/ecma262/#sec-number.isinteger
1226
+ var isInteger = function isInteger(it) {
1227
+ return !isObject(it) && isFinite(it) && floor$1(it) === it;
1228
+ };
1229
+
1230
+ // `Number.isInteger` method
1231
+ // https://tc39.github.io/ecma262/#sec-number.isinteger
1232
+ _export({ target: 'Number', stat: true }, {
1233
+ isInteger: isInteger
1234
+ });
1235
+
1236
+ var isInteger$1 = path.Number.isInteger;
1237
+
1238
+ // `Math.sign` method implementation
1239
+ // https://tc39.github.io/ecma262/#sec-math.sign
1240
+ var mathSign = Math.sign || function sign(x) {
1241
+ // eslint-disable-next-line no-self-compare
1242
+ return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
1243
+ };
1244
+
1245
+ // `Math.sign` method
1246
+ // https://tc39.github.io/ecma262/#sec-math.sign
1247
+ _export({ target: 'Math', stat: true }, {
1248
+ sign: mathSign
1249
+ });
1250
+
1251
+ var sign = path.Math.sign;
1252
+
1253
+ var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
1254
+ var test = {};
1255
+
1256
+ test[TO_STRING_TAG$1] = 'z';
1257
+
1258
+ var toStringTagSupport = String(test) === '[object z]';
1259
+
1260
+ var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag');
1261
+ // ES3 wrong here
1262
+ var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1263
+
1264
+ // fallback for IE11 Script Access Denied error
1265
+ var tryGet = function (it, key) {
1266
+ try {
1267
+ return it[key];
1268
+ } catch (error) { /* empty */ }
1269
+ };
1270
+
1271
+ // getting tag from ES6+ `Object.prototype.toString`
1272
+ var classof = toStringTagSupport ? classofRaw : function (it) {
1273
+ var O, tag, result;
1274
+ return it === undefined ? 'Undefined' : it === null ? 'Null'
1275
+ // @@toStringTag case
1276
+ : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$2)) == 'string' ? tag
1277
+ // builtinTag case
1278
+ : CORRECT_ARGUMENTS ? classofRaw(O)
1279
+ // ES3 arguments fallback
1280
+ : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
1281
+ };
1282
+
1283
+ // `Object.prototype.toString` method implementation
1284
+ // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
1285
+ var objectToString = toStringTagSupport ? {}.toString : function toString() {
1286
+ return '[object ' + classof(this) + ']';
1287
+ };
1288
+
1289
+ // `Object.prototype.toString` method
1290
+ // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
1291
+ if (!toStringTagSupport) {
1292
+ redefine(Object.prototype, 'toString', objectToString, { unsafe: true });
1293
+ }
1294
+
1295
+ // `String.prototype.{ codePointAt, at }` methods implementation
1296
+ var createMethod$3 = function (CONVERT_TO_STRING) {
1297
+ return function ($this, pos) {
1298
+ var S = String(requireObjectCoercible($this));
1299
+ var position = toInteger(pos);
1300
+ var size = S.length;
1301
+ var first, second;
1302
+ if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
1303
+ first = S.charCodeAt(position);
1304
+ return first < 0xD800 || first > 0xDBFF || position + 1 === size
1305
+ || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
1306
+ ? CONVERT_TO_STRING ? S.charAt(position) : first
1307
+ : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
1308
+ };
1309
+ };
1310
+
1311
+ var stringMultibyte = {
1312
+ // `String.prototype.codePointAt` method
1313
+ // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
1314
+ codeAt: createMethod$3(false),
1315
+ // `String.prototype.at` method
1316
+ // https://github.com/mathiasbynens/String.prototype.at
1317
+ charAt: createMethod$3(true)
1318
+ };
1319
+
1320
+ var charAt = stringMultibyte.charAt;
1321
+
1322
+
1323
+
1324
+ var STRING_ITERATOR = 'String Iterator';
1325
+ var setInternalState$1 = internalState.set;
1326
+ var getInternalState$1 = internalState.getterFor(STRING_ITERATOR);
1327
+
1328
+ // `String.prototype[@@iterator]` method
1329
+ // https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
1330
+ defineIterator(String, 'String', function (iterated) {
1331
+ setInternalState$1(this, {
1332
+ type: STRING_ITERATOR,
1333
+ string: String(iterated),
1334
+ index: 0
1335
+ });
1336
+ // `%StringIteratorPrototype%.next` method
1337
+ // https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next
1338
+ }, function next() {
1339
+ var state = getInternalState$1(this);
1340
+ var string = state.string;
1341
+ var index = state.index;
1342
+ var point;
1343
+ if (index >= string.length) return { value: undefined, done: true };
1344
+ point = charAt(string, index);
1345
+ state.index += point.length;
1346
+ return { value: point, done: false };
1347
+ });
1348
+
1349
+ // iterable DOM collections
1350
+ // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
1351
+ var domIterables = {
1352
+ CSSRuleList: 0,
1353
+ CSSStyleDeclaration: 0,
1354
+ CSSValueList: 0,
1355
+ ClientRectList: 0,
1356
+ DOMRectList: 0,
1357
+ DOMStringList: 0,
1358
+ DOMTokenList: 1,
1359
+ DataTransferItemList: 0,
1360
+ FileList: 0,
1361
+ HTMLAllCollection: 0,
1362
+ HTMLCollection: 0,
1363
+ HTMLFormElement: 0,
1364
+ HTMLSelectElement: 0,
1365
+ MediaList: 0,
1366
+ MimeTypeArray: 0,
1367
+ NamedNodeMap: 0,
1368
+ NodeList: 1,
1369
+ PaintRequestList: 0,
1370
+ Plugin: 0,
1371
+ PluginArray: 0,
1372
+ SVGLengthList: 0,
1373
+ SVGNumberList: 0,
1374
+ SVGPathSegList: 0,
1375
+ SVGPointList: 0,
1376
+ SVGStringList: 0,
1377
+ SVGTransformList: 0,
1378
+ SourceBufferList: 0,
1379
+ StyleSheetList: 0,
1380
+ TextTrackCueList: 0,
1381
+ TextTrackList: 0,
1382
+ TouchList: 0
1383
+ };
1384
+
1385
+ var ITERATOR$2 = wellKnownSymbol('iterator');
1386
+ var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag');
1387
+ var ArrayValues = es_array_iterator.values;
1388
+
1389
+ for (var COLLECTION_NAME in domIterables) {
1390
+ var Collection = global_1[COLLECTION_NAME];
1391
+ var CollectionPrototype = Collection && Collection.prototype;
1392
+ if (CollectionPrototype) {
1393
+ // some Chrome versions have non-configurable methods on DOMTokenList
1394
+ if (CollectionPrototype[ITERATOR$2] !== ArrayValues) try {
1395
+ createNonEnumerableProperty(CollectionPrototype, ITERATOR$2, ArrayValues);
1396
+ } catch (error) {
1397
+ CollectionPrototype[ITERATOR$2] = ArrayValues;
1398
+ }
1399
+ if (!CollectionPrototype[TO_STRING_TAG$3]) {
1400
+ createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$3, COLLECTION_NAME);
1401
+ }
1402
+ if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) {
1403
+ // some Chrome versions have non-configurable methods on DOMTokenList
1404
+ if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try {
1405
+ createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]);
1406
+ } catch (error) {
1407
+ CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME];
1408
+ }
1409
+ }
1410
+ }
1411
+ }
1412
+
1413
+ var nativePromiseConstructor = global_1.Promise;
1414
+
1415
+ var redefineAll = function (target, src, options) {
1416
+ for (var key in src) redefine(target, key, src[key], options);
1417
+ return target;
1418
+ };
1419
+
1420
+ var SPECIES$1 = wellKnownSymbol('species');
1421
+
1422
+ var setSpecies = function (CONSTRUCTOR_NAME) {
1423
+ var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
1424
+ var defineProperty = objectDefineProperty.f;
1425
+
1426
+ if (descriptors && Constructor && !Constructor[SPECIES$1]) {
1427
+ defineProperty(Constructor, SPECIES$1, {
1428
+ configurable: true,
1429
+ get: function () { return this; }
1430
+ });
1431
+ }
1432
+ };
1433
+
1434
+ var anInstance = function (it, Constructor, name) {
1435
+ if (!(it instanceof Constructor)) {
1436
+ throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
1437
+ } return it;
1438
+ };
1439
+
1440
+ var ITERATOR$3 = wellKnownSymbol('iterator');
1441
+ var ArrayPrototype$1 = Array.prototype;
1442
+
1443
+ // check on default Array iterator
1444
+ var isArrayIteratorMethod = function (it) {
1445
+ return it !== undefined && (iterators.Array === it || ArrayPrototype$1[ITERATOR$3] === it);
1446
+ };
1447
+
1448
+ var ITERATOR$4 = wellKnownSymbol('iterator');
1449
+
1450
+ var getIteratorMethod = function (it) {
1451
+ if (it != undefined) return it[ITERATOR$4]
1452
+ || it['@@iterator']
1453
+ || iterators[classof(it)];
1454
+ };
1455
+
1456
+ // call something on iterator step with safe closing on error
1457
+ var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
1458
+ try {
1459
+ return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
1460
+ // 7.4.6 IteratorClose(iterator, completion)
1461
+ } catch (error) {
1462
+ var returnMethod = iterator['return'];
1463
+ if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
1464
+ throw error;
1465
+ }
1466
+ };
1467
+
1468
+ var iterate_1 = createCommonjsModule(function (module) {
1469
+ var Result = function (stopped, result) {
1470
+ this.stopped = stopped;
1471
+ this.result = result;
1472
+ };
1473
+
1474
+ var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
1475
+ var boundFunction = functionBindContext(fn, that, AS_ENTRIES ? 2 : 1);
1476
+ var iterator, iterFn, index, length, result, next, step;
1477
+
1478
+ if (IS_ITERATOR) {
1479
+ iterator = iterable;
1480
+ } else {
1481
+ iterFn = getIteratorMethod(iterable);
1482
+ if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
1483
+ // optimisation for array iterators
1484
+ if (isArrayIteratorMethod(iterFn)) {
1485
+ for (index = 0, length = toLength(iterable.length); length > index; index++) {
1486
+ result = AS_ENTRIES
1487
+ ? boundFunction(anObject(step = iterable[index])[0], step[1])
1488
+ : boundFunction(iterable[index]);
1489
+ if (result && result instanceof Result) return result;
1490
+ } return new Result(false);
1491
+ }
1492
+ iterator = iterFn.call(iterable);
1493
+ }
1494
+
1495
+ next = iterator.next;
1496
+ while (!(step = next.call(iterator)).done) {
1497
+ result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
1498
+ if (typeof result == 'object' && result && result instanceof Result) return result;
1499
+ } return new Result(false);
1500
+ };
1501
+
1502
+ iterate.stop = function (result) {
1503
+ return new Result(true, result);
1504
+ };
1505
+ });
1506
+
1507
+ var ITERATOR$5 = wellKnownSymbol('iterator');
1508
+ var SAFE_CLOSING = false;
1509
+
1510
+ try {
1511
+ var called = 0;
1512
+ var iteratorWithReturn = {
1513
+ next: function () {
1514
+ return { done: !!called++ };
1515
+ },
1516
+ 'return': function () {
1517
+ SAFE_CLOSING = true;
1518
+ }
1519
+ };
1520
+ iteratorWithReturn[ITERATOR$5] = function () {
1521
+ return this;
1522
+ };
1523
+ // eslint-disable-next-line no-throw-literal
1524
+ Array.from(iteratorWithReturn, function () { throw 2; });
1525
+ } catch (error) { /* empty */ }
1526
+
1527
+ var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
1528
+ if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
1529
+ var ITERATION_SUPPORT = false;
1530
+ try {
1531
+ var object = {};
1532
+ object[ITERATOR$5] = function () {
1533
+ return {
1534
+ next: function () {
1535
+ return { done: ITERATION_SUPPORT = true };
1536
+ }
1537
+ };
1538
+ };
1539
+ exec(object);
1540
+ } catch (error) { /* empty */ }
1541
+ return ITERATION_SUPPORT;
1542
+ };
1543
+
1544
+ var SPECIES$2 = wellKnownSymbol('species');
1545
+
1546
+ // `SpeciesConstructor` abstract operation
1547
+ // https://tc39.github.io/ecma262/#sec-speciesconstructor
1548
+ var speciesConstructor = function (O, defaultConstructor) {
1549
+ var C = anObject(O).constructor;
1550
+ var S;
1551
+ return C === undefined || (S = anObject(C)[SPECIES$2]) == undefined ? defaultConstructor : aFunction$1(S);
1552
+ };
1553
+
1554
+ var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
1555
+
1556
+ var engineIsIos = /(iphone|ipod|ipad).*applewebkit/i.test(engineUserAgent);
1557
+
1558
+ var location = global_1.location;
1559
+ var set$1 = global_1.setImmediate;
1560
+ var clear = global_1.clearImmediate;
1561
+ var process = global_1.process;
1562
+ var MessageChannel = global_1.MessageChannel;
1563
+ var Dispatch = global_1.Dispatch;
1564
+ var counter = 0;
1565
+ var queue = {};
1566
+ var ONREADYSTATECHANGE = 'onreadystatechange';
1567
+ var defer, channel, port;
1568
+
1569
+ var run = function (id) {
1570
+ // eslint-disable-next-line no-prototype-builtins
1571
+ if (queue.hasOwnProperty(id)) {
1572
+ var fn = queue[id];
1573
+ delete queue[id];
1574
+ fn();
1575
+ }
1576
+ };
1577
+
1578
+ var runner = function (id) {
1579
+ return function () {
1580
+ run(id);
1581
+ };
1582
+ };
1583
+
1584
+ var listener = function (event) {
1585
+ run(event.data);
1586
+ };
1587
+
1588
+ var post = function (id) {
1589
+ // old engines have not location.origin
1590
+ global_1.postMessage(id + '', location.protocol + '//' + location.host);
1591
+ };
1592
+
1593
+ // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
1594
+ if (!set$1 || !clear) {
1595
+ set$1 = function setImmediate(fn) {
1596
+ var args = [];
1597
+ var i = 1;
1598
+ while (arguments.length > i) args.push(arguments[i++]);
1599
+ queue[++counter] = function () {
1600
+ // eslint-disable-next-line no-new-func
1601
+ (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
1602
+ };
1603
+ defer(counter);
1604
+ return counter;
1605
+ };
1606
+ clear = function clearImmediate(id) {
1607
+ delete queue[id];
1608
+ };
1609
+ // Node.js 0.8-
1610
+ if (classofRaw(process) == 'process') {
1611
+ defer = function (id) {
1612
+ process.nextTick(runner(id));
1613
+ };
1614
+ // Sphere (JS game engine) Dispatch API
1615
+ } else if (Dispatch && Dispatch.now) {
1616
+ defer = function (id) {
1617
+ Dispatch.now(runner(id));
1618
+ };
1619
+ // Browsers with MessageChannel, includes WebWorkers
1620
+ // except iOS - https://github.com/zloirock/core-js/issues/624
1621
+ } else if (MessageChannel && !engineIsIos) {
1622
+ channel = new MessageChannel();
1623
+ port = channel.port2;
1624
+ channel.port1.onmessage = listener;
1625
+ defer = functionBindContext(port.postMessage, port, 1);
1626
+ // Browsers with postMessage, skip WebWorkers
1627
+ // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
1628
+ } else if (
1629
+ global_1.addEventListener &&
1630
+ typeof postMessage == 'function' &&
1631
+ !global_1.importScripts &&
1632
+ !fails(post) &&
1633
+ location.protocol !== 'file:'
1634
+ ) {
1635
+ defer = post;
1636
+ global_1.addEventListener('message', listener, false);
1637
+ // IE8-
1638
+ } else if (ONREADYSTATECHANGE in documentCreateElement('script')) {
1639
+ defer = function (id) {
1640
+ html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () {
1641
+ html.removeChild(this);
1642
+ run(id);
1643
+ };
1644
+ };
1645
+ // Rest old browsers
1646
+ } else {
1647
+ defer = function (id) {
1648
+ setTimeout(runner(id), 0);
1649
+ };
1650
+ }
1651
+ }
1652
+
1653
+ var task = {
1654
+ set: set$1,
1655
+ clear: clear
1656
+ };
1657
+
1658
+ var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
1659
+
1660
+ var macrotask = task.set;
1661
+
1662
+
1663
+ var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver;
1664
+ var process$1 = global_1.process;
1665
+ var Promise$1 = global_1.Promise;
1666
+ var IS_NODE = classofRaw(process$1) == 'process';
1667
+ // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
1668
+ var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global_1, 'queueMicrotask');
1669
+ var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
1670
+
1671
+ var flush, head, last, notify, toggle, node, promise, then;
1672
+
1673
+ // modern engines have queueMicrotask method
1674
+ if (!queueMicrotask) {
1675
+ flush = function () {
1676
+ var parent, fn;
1677
+ if (IS_NODE && (parent = process$1.domain)) parent.exit();
1678
+ while (head) {
1679
+ fn = head.fn;
1680
+ head = head.next;
1681
+ try {
1682
+ fn();
1683
+ } catch (error) {
1684
+ if (head) notify();
1685
+ else last = undefined;
1686
+ throw error;
1687
+ }
1688
+ } last = undefined;
1689
+ if (parent) parent.enter();
1690
+ };
1691
+
1692
+ // Node.js
1693
+ if (IS_NODE) {
1694
+ notify = function () {
1695
+ process$1.nextTick(flush);
1696
+ };
1697
+ // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
1698
+ } else if (MutationObserver && !engineIsIos) {
1699
+ toggle = true;
1700
+ node = document.createTextNode('');
1701
+ new MutationObserver(flush).observe(node, { characterData: true });
1702
+ notify = function () {
1703
+ node.data = toggle = !toggle;
1704
+ };
1705
+ // environments with maybe non-completely correct, but existent Promise
1706
+ } else if (Promise$1 && Promise$1.resolve) {
1707
+ // Promise.resolve without an argument throws an error in LG WebOS 2
1708
+ promise = Promise$1.resolve(undefined);
1709
+ then = promise.then;
1710
+ notify = function () {
1711
+ then.call(promise, flush);
1712
+ };
1713
+ // for other environments - macrotask based on:
1714
+ // - setImmediate
1715
+ // - MessageChannel
1716
+ // - window.postMessag
1717
+ // - onreadystatechange
1718
+ // - setTimeout
1719
+ } else {
1720
+ notify = function () {
1721
+ // strange IE + webpack dev server bug - use .call(global)
1722
+ macrotask.call(global_1, flush);
1723
+ };
1724
+ }
1725
+ }
1726
+
1727
+ var microtask = queueMicrotask || function (fn) {
1728
+ var task = { fn: fn, next: undefined };
1729
+ if (last) last.next = task;
1730
+ if (!head) {
1731
+ head = task;
1732
+ notify();
1733
+ } last = task;
1734
+ };
1735
+
1736
+ var PromiseCapability = function (C) {
1737
+ var resolve, reject;
1738
+ this.promise = new C(function ($$resolve, $$reject) {
1739
+ if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
1740
+ resolve = $$resolve;
1741
+ reject = $$reject;
1742
+ });
1743
+ this.resolve = aFunction$1(resolve);
1744
+ this.reject = aFunction$1(reject);
1745
+ };
1746
+
1747
+ // 25.4.1.5 NewPromiseCapability(C)
1748
+ var f$5 = function (C) {
1749
+ return new PromiseCapability(C);
1750
+ };
1751
+
1752
+ var newPromiseCapability = {
1753
+ f: f$5
1754
+ };
1755
+
1756
+ var promiseResolve = function (C, x) {
1757
+ anObject(C);
1758
+ if (isObject(x) && x.constructor === C) return x;
1759
+ var promiseCapability = newPromiseCapability.f(C);
1760
+ var resolve = promiseCapability.resolve;
1761
+ resolve(x);
1762
+ return promiseCapability.promise;
1763
+ };
1764
+
1765
+ var hostReportErrors = function (a, b) {
1766
+ var console = global_1.console;
1767
+ if (console && console.error) {
1768
+ arguments.length === 1 ? console.error(a) : console.error(a, b);
1769
+ }
1770
+ };
1771
+
1772
+ var perform = function (exec) {
1773
+ try {
1774
+ return { error: false, value: exec() };
1775
+ } catch (error) {
1776
+ return { error: true, value: error };
1777
+ }
1778
+ };
1779
+
1780
+ var process$2 = global_1.process;
1781
+ var versions = process$2 && process$2.versions;
1782
+ var v8 = versions && versions.v8;
1783
+ var match, version;
1784
+
1785
+ if (v8) {
1786
+ match = v8.split('.');
1787
+ version = match[0] + match[1];
1788
+ } else if (engineUserAgent) {
1789
+ match = engineUserAgent.match(/Edge\/(\d+)/);
1790
+ if (!match || match[1] >= 74) {
1791
+ match = engineUserAgent.match(/Chrome\/(\d+)/);
1792
+ if (match) version = match[1];
1793
+ }
1794
+ }
1795
+
1796
+ var engineV8Version = version && +version;
1797
+
1798
+ var task$1 = task.set;
1799
+
1800
+
1801
+
1802
+
1803
+
1804
+
1805
+
1806
+
1807
+
1808
+
1809
+ var SPECIES$3 = wellKnownSymbol('species');
1810
+ var PROMISE = 'Promise';
1811
+ var getInternalState$2 = internalState.get;
1812
+ var setInternalState$2 = internalState.set;
1813
+ var getInternalPromiseState = internalState.getterFor(PROMISE);
1814
+ var PromiseConstructor = nativePromiseConstructor;
1815
+ var TypeError$1 = global_1.TypeError;
1816
+ var document$2 = global_1.document;
1817
+ var process$3 = global_1.process;
1818
+ var $fetch = getBuiltIn('fetch');
1819
+ var newPromiseCapability$1 = newPromiseCapability.f;
1820
+ var newGenericPromiseCapability = newPromiseCapability$1;
1821
+ var IS_NODE$1 = classofRaw(process$3) == 'process';
1822
+ var DISPATCH_EVENT = !!(document$2 && document$2.createEvent && global_1.dispatchEvent);
1823
+ var UNHANDLED_REJECTION = 'unhandledrejection';
1824
+ var REJECTION_HANDLED = 'rejectionhandled';
1825
+ var PENDING = 0;
1826
+ var FULFILLED = 1;
1827
+ var REJECTED = 2;
1828
+ var HANDLED = 1;
1829
+ var UNHANDLED = 2;
1830
+ var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
1831
+
1832
+ var FORCED = isForced_1(PROMISE, function () {
1833
+ var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
1834
+ if (!GLOBAL_CORE_JS_PROMISE) {
1835
+ // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
1836
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
1837
+ // We can't detect it synchronously, so just check versions
1838
+ if (engineV8Version === 66) return true;
1839
+ // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
1840
+ if (!IS_NODE$1 && typeof PromiseRejectionEvent != 'function') return true;
1841
+ }
1842
+ // We can't use @@species feature detection in V8 since it causes
1843
+ // deoptimization and performance degradation
1844
+ // https://github.com/zloirock/core-js/issues/679
1845
+ if (engineV8Version >= 51 && /native code/.test(PromiseConstructor)) return false;
1846
+ // Detect correctness of subclassing with @@species support
1847
+ var promise = PromiseConstructor.resolve(1);
1848
+ var FakePromise = function (exec) {
1849
+ exec(function () { /* empty */ }, function () { /* empty */ });
1850
+ };
1851
+ var constructor = promise.constructor = {};
1852
+ constructor[SPECIES$3] = FakePromise;
1853
+ return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
1854
+ });
1855
+
1856
+ var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
1857
+ PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
1858
+ });
1859
+
1860
+ // helpers
1861
+ var isThenable = function (it) {
1862
+ var then;
1863
+ return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
1864
+ };
1865
+
1866
+ var notify$1 = function (promise, state, isReject) {
1867
+ if (state.notified) return;
1868
+ state.notified = true;
1869
+ var chain = state.reactions;
1870
+ microtask(function () {
1871
+ var value = state.value;
1872
+ var ok = state.state == FULFILLED;
1873
+ var index = 0;
1874
+ // variable length - can't use forEach
1875
+ while (chain.length > index) {
1876
+ var reaction = chain[index++];
1877
+ var handler = ok ? reaction.ok : reaction.fail;
1878
+ var resolve = reaction.resolve;
1879
+ var reject = reaction.reject;
1880
+ var domain = reaction.domain;
1881
+ var result, then, exited;
1882
+ try {
1883
+ if (handler) {
1884
+ if (!ok) {
1885
+ if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);
1886
+ state.rejection = HANDLED;
1887
+ }
1888
+ if (handler === true) result = value;
1889
+ else {
1890
+ if (domain) domain.enter();
1891
+ result = handler(value); // can throw
1892
+ if (domain) {
1893
+ domain.exit();
1894
+ exited = true;
1895
+ }
1896
+ }
1897
+ if (result === reaction.promise) {
1898
+ reject(TypeError$1('Promise-chain cycle'));
1899
+ } else if (then = isThenable(result)) {
1900
+ then.call(result, resolve, reject);
1901
+ } else resolve(result);
1902
+ } else reject(value);
1903
+ } catch (error) {
1904
+ if (domain && !exited) domain.exit();
1905
+ reject(error);
1906
+ }
1907
+ }
1908
+ state.reactions = [];
1909
+ state.notified = false;
1910
+ if (isReject && !state.rejection) onUnhandled(promise, state);
1911
+ });
1912
+ };
1913
+
1914
+ var dispatchEvent = function (name, promise, reason) {
1915
+ var event, handler;
1916
+ if (DISPATCH_EVENT) {
1917
+ event = document$2.createEvent('Event');
1918
+ event.promise = promise;
1919
+ event.reason = reason;
1920
+ event.initEvent(name, false, true);
1921
+ global_1.dispatchEvent(event);
1922
+ } else event = { promise: promise, reason: reason };
1923
+ if (handler = global_1['on' + name]) handler(event);
1924
+ else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
1925
+ };
1926
+
1927
+ var onUnhandled = function (promise, state) {
1928
+ task$1.call(global_1, function () {
1929
+ var value = state.value;
1930
+ var IS_UNHANDLED = isUnhandled(state);
1931
+ var result;
1932
+ if (IS_UNHANDLED) {
1933
+ result = perform(function () {
1934
+ if (IS_NODE$1) {
1935
+ process$3.emit('unhandledRejection', value, promise);
1936
+ } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
1937
+ });
1938
+ // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
1939
+ state.rejection = IS_NODE$1 || isUnhandled(state) ? UNHANDLED : HANDLED;
1940
+ if (result.error) throw result.value;
1941
+ }
1942
+ });
1943
+ };
1944
+
1945
+ var isUnhandled = function (state) {
1946
+ return state.rejection !== HANDLED && !state.parent;
1947
+ };
1948
+
1949
+ var onHandleUnhandled = function (promise, state) {
1950
+ task$1.call(global_1, function () {
1951
+ if (IS_NODE$1) {
1952
+ process$3.emit('rejectionHandled', promise);
1953
+ } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
1954
+ });
1955
+ };
1956
+
1957
+ var bind = function (fn, promise, state, unwrap) {
1958
+ return function (value) {
1959
+ fn(promise, state, value, unwrap);
1960
+ };
1961
+ };
1962
+
1963
+ var internalReject = function (promise, state, value, unwrap) {
1964
+ if (state.done) return;
1965
+ state.done = true;
1966
+ if (unwrap) state = unwrap;
1967
+ state.value = value;
1968
+ state.state = REJECTED;
1969
+ notify$1(promise, state, true);
1970
+ };
1971
+
1972
+ var internalResolve = function (promise, state, value, unwrap) {
1973
+ if (state.done) return;
1974
+ state.done = true;
1975
+ if (unwrap) state = unwrap;
1976
+ try {
1977
+ if (promise === value) throw TypeError$1("Promise can't be resolved itself");
1978
+ var then = isThenable(value);
1979
+ if (then) {
1980
+ microtask(function () {
1981
+ var wrapper = { done: false };
1982
+ try {
1983
+ then.call(value,
1984
+ bind(internalResolve, promise, wrapper, state),
1985
+ bind(internalReject, promise, wrapper, state)
1986
+ );
1987
+ } catch (error) {
1988
+ internalReject(promise, wrapper, error, state);
1989
+ }
1990
+ });
1991
+ } else {
1992
+ state.value = value;
1993
+ state.state = FULFILLED;
1994
+ notify$1(promise, state, false);
1995
+ }
1996
+ } catch (error) {
1997
+ internalReject(promise, { done: false }, error, state);
1998
+ }
1999
+ };
2000
+
2001
+ // constructor polyfill
2002
+ if (FORCED) {
2003
+ // 25.4.3.1 Promise(executor)
2004
+ PromiseConstructor = function Promise(executor) {
2005
+ anInstance(this, PromiseConstructor, PROMISE);
2006
+ aFunction$1(executor);
2007
+ Internal.call(this);
2008
+ var state = getInternalState$2(this);
2009
+ try {
2010
+ executor(bind(internalResolve, this, state), bind(internalReject, this, state));
2011
+ } catch (error) {
2012
+ internalReject(this, state, error);
2013
+ }
2014
+ };
2015
+ // eslint-disable-next-line no-unused-vars
2016
+ Internal = function Promise(executor) {
2017
+ setInternalState$2(this, {
2018
+ type: PROMISE,
2019
+ done: false,
2020
+ notified: false,
2021
+ parent: false,
2022
+ reactions: [],
2023
+ rejection: false,
2024
+ state: PENDING,
2025
+ value: undefined
2026
+ });
2027
+ };
2028
+ Internal.prototype = redefineAll(PromiseConstructor.prototype, {
2029
+ // `Promise.prototype.then` method
2030
+ // https://tc39.github.io/ecma262/#sec-promise.prototype.then
2031
+ then: function then(onFulfilled, onRejected) {
2032
+ var state = getInternalPromiseState(this);
2033
+ var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
2034
+ reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
2035
+ reaction.fail = typeof onRejected == 'function' && onRejected;
2036
+ reaction.domain = IS_NODE$1 ? process$3.domain : undefined;
2037
+ state.parent = true;
2038
+ state.reactions.push(reaction);
2039
+ if (state.state != PENDING) notify$1(this, state, false);
2040
+ return reaction.promise;
2041
+ },
2042
+ // `Promise.prototype.catch` method
2043
+ // https://tc39.github.io/ecma262/#sec-promise.prototype.catch
2044
+ 'catch': function (onRejected) {
2045
+ return this.then(undefined, onRejected);
2046
+ }
2047
+ });
2048
+ OwnPromiseCapability = function () {
2049
+ var promise = new Internal();
2050
+ var state = getInternalState$2(promise);
2051
+ this.promise = promise;
2052
+ this.resolve = bind(internalResolve, promise, state);
2053
+ this.reject = bind(internalReject, promise, state);
2054
+ };
2055
+ newPromiseCapability.f = newPromiseCapability$1 = function (C) {
2056
+ return C === PromiseConstructor || C === PromiseWrapper
2057
+ ? new OwnPromiseCapability(C)
2058
+ : newGenericPromiseCapability(C);
2059
+ };
2060
+
2061
+ if ( typeof nativePromiseConstructor == 'function') {
2062
+ nativeThen = nativePromiseConstructor.prototype.then;
2063
+
2064
+ // wrap native Promise#then for native async functions
2065
+ redefine(nativePromiseConstructor.prototype, 'then', function then(onFulfilled, onRejected) {
2066
+ var that = this;
2067
+ return new PromiseConstructor(function (resolve, reject) {
2068
+ nativeThen.call(that, resolve, reject);
2069
+ }).then(onFulfilled, onRejected);
2070
+ // https://github.com/zloirock/core-js/issues/640
2071
+ }, { unsafe: true });
2072
+
2073
+ // wrap fetch result
2074
+ if (typeof $fetch == 'function') _export({ global: true, enumerable: true, forced: true }, {
2075
+ // eslint-disable-next-line no-unused-vars
2076
+ fetch: function fetch(input /* , init */) {
2077
+ return promiseResolve(PromiseConstructor, $fetch.apply(global_1, arguments));
2078
+ }
2079
+ });
2080
+ }
2081
+ }
2082
+
2083
+ _export({ global: true, wrap: true, forced: FORCED }, {
2084
+ Promise: PromiseConstructor
2085
+ });
2086
+
2087
+ setToStringTag(PromiseConstructor, PROMISE, false);
2088
+ setSpecies(PROMISE);
2089
+
2090
+ PromiseWrapper = getBuiltIn(PROMISE);
2091
+
2092
+ // statics
2093
+ _export({ target: PROMISE, stat: true, forced: FORCED }, {
2094
+ // `Promise.reject` method
2095
+ // https://tc39.github.io/ecma262/#sec-promise.reject
2096
+ reject: function reject(r) {
2097
+ var capability = newPromiseCapability$1(this);
2098
+ capability.reject.call(undefined, r);
2099
+ return capability.promise;
2100
+ }
2101
+ });
2102
+
2103
+ _export({ target: PROMISE, stat: true, forced: FORCED }, {
2104
+ // `Promise.resolve` method
2105
+ // https://tc39.github.io/ecma262/#sec-promise.resolve
2106
+ resolve: function resolve(x) {
2107
+ return promiseResolve( this, x);
2108
+ }
2109
+ });
2110
+
2111
+ _export({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
2112
+ // `Promise.all` method
2113
+ // https://tc39.github.io/ecma262/#sec-promise.all
2114
+ all: function all(iterable) {
2115
+ var C = this;
2116
+ var capability = newPromiseCapability$1(C);
2117
+ var resolve = capability.resolve;
2118
+ var reject = capability.reject;
2119
+ var result = perform(function () {
2120
+ var $promiseResolve = aFunction$1(C.resolve);
2121
+ var values = [];
2122
+ var counter = 0;
2123
+ var remaining = 1;
2124
+ iterate_1(iterable, function (promise) {
2125
+ var index = counter++;
2126
+ var alreadyCalled = false;
2127
+ values.push(undefined);
2128
+ remaining++;
2129
+ $promiseResolve.call(C, promise).then(function (value) {
2130
+ if (alreadyCalled) return;
2131
+ alreadyCalled = true;
2132
+ values[index] = value;
2133
+ --remaining || resolve(values);
2134
+ }, reject);
2135
+ });
2136
+ --remaining || resolve(values);
2137
+ });
2138
+ if (result.error) reject(result.value);
2139
+ return capability.promise;
2140
+ },
2141
+ // `Promise.race` method
2142
+ // https://tc39.github.io/ecma262/#sec-promise.race
2143
+ race: function race(iterable) {
2144
+ var C = this;
2145
+ var capability = newPromiseCapability$1(C);
2146
+ var reject = capability.reject;
2147
+ var result = perform(function () {
2148
+ var $promiseResolve = aFunction$1(C.resolve);
2149
+ iterate_1(iterable, function (promise) {
2150
+ $promiseResolve.call(C, promise).then(capability.resolve, reject);
2151
+ });
2152
+ });
2153
+ if (result.error) reject(result.value);
2154
+ return capability.promise;
2155
+ }
2156
+ });
2157
+
2158
+ // `Promise.allSettled` method
2159
+ // https://github.com/tc39/proposal-promise-allSettled
2160
+ _export({ target: 'Promise', stat: true }, {
2161
+ allSettled: function allSettled(iterable) {
2162
+ var C = this;
2163
+ var capability = newPromiseCapability.f(C);
2164
+ var resolve = capability.resolve;
2165
+ var reject = capability.reject;
2166
+ var result = perform(function () {
2167
+ var promiseResolve = aFunction$1(C.resolve);
2168
+ var values = [];
2169
+ var counter = 0;
2170
+ var remaining = 1;
2171
+ iterate_1(iterable, function (promise) {
2172
+ var index = counter++;
2173
+ var alreadyCalled = false;
2174
+ values.push(undefined);
2175
+ remaining++;
2176
+ promiseResolve.call(C, promise).then(function (value) {
2177
+ if (alreadyCalled) return;
2178
+ alreadyCalled = true;
2179
+ values[index] = { status: 'fulfilled', value: value };
2180
+ --remaining || resolve(values);
2181
+ }, function (e) {
2182
+ if (alreadyCalled) return;
2183
+ alreadyCalled = true;
2184
+ values[index] = { status: 'rejected', reason: e };
2185
+ --remaining || resolve(values);
2186
+ });
2187
+ });
2188
+ --remaining || resolve(values);
2189
+ });
2190
+ if (result.error) reject(result.value);
2191
+ return capability.promise;
2192
+ }
2193
+ });
2194
+
2195
+ // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
2196
+ var NON_GENERIC = !!nativePromiseConstructor && fails(function () {
2197
+ nativePromiseConstructor.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
2198
+ });
2199
+
2200
+ // `Promise.prototype.finally` method
2201
+ // https://tc39.github.io/ecma262/#sec-promise.prototype.finally
2202
+ _export({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
2203
+ 'finally': function (onFinally) {
2204
+ var C = speciesConstructor(this, getBuiltIn('Promise'));
2205
+ var isFunction = typeof onFinally == 'function';
2206
+ return this.then(
2207
+ isFunction ? function (x) {
2208
+ return promiseResolve(C, onFinally()).then(function () { return x; });
2209
+ } : onFinally,
2210
+ isFunction ? function (e) {
2211
+ return promiseResolve(C, onFinally()).then(function () { throw e; });
2212
+ } : onFinally
2213
+ );
2214
+ }
2215
+ });
2216
+
2217
+ // patch native Promise.prototype for native async functions
2218
+ if ( typeof nativePromiseConstructor == 'function' && !nativePromiseConstructor.prototype['finally']) {
2219
+ redefine(nativePromiseConstructor.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);
2220
+ }
2221
+
2222
+ var promise$1 = path.Promise;
2223
+
2224
+ var setInternalState$3 = internalState.set;
2225
+ var getInternalAggregateErrorState = internalState.getterFor('AggregateError');
2226
+
2227
+ var $AggregateError = function AggregateError(errors, message) {
2228
+ var that = this;
2229
+ if (!(that instanceof $AggregateError)) return new $AggregateError(errors, message);
2230
+ if (objectSetPrototypeOf) {
2231
+ that = objectSetPrototypeOf(new Error(message), objectGetPrototypeOf(that));
2232
+ }
2233
+ var errorsArray = [];
2234
+ iterate_1(errors, errorsArray.push, errorsArray);
2235
+ if (descriptors) setInternalState$3(that, { errors: errorsArray, type: 'AggregateError' });
2236
+ else that.errors = errorsArray;
2237
+ if (message !== undefined) createNonEnumerableProperty(that, 'message', String(message));
2238
+ return that;
2239
+ };
2240
+
2241
+ $AggregateError.prototype = objectCreate(Error.prototype, {
2242
+ constructor: createPropertyDescriptor(5, $AggregateError),
2243
+ message: createPropertyDescriptor(5, ''),
2244
+ name: createPropertyDescriptor(5, 'AggregateError')
2245
+ });
2246
+
2247
+ if (descriptors) objectDefineProperty.f($AggregateError.prototype, 'errors', {
2248
+ get: function () {
2249
+ return getInternalAggregateErrorState(this).errors;
2250
+ },
2251
+ configurable: true
2252
+ });
2253
+
2254
+ _export({ global: true }, {
2255
+ AggregateError: $AggregateError
2256
+ });
2257
+
2258
+ // `Promise.try` method
2259
+ // https://github.com/tc39/proposal-promise-try
2260
+ _export({ target: 'Promise', stat: true }, {
2261
+ 'try': function (callbackfn) {
2262
+ var promiseCapability = newPromiseCapability.f(this);
2263
+ var result = perform(callbackfn);
2264
+ (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
2265
+ return promiseCapability.promise;
2266
+ }
2267
+ });
2268
+
2269
+ var PROMISE_ANY_ERROR = 'No one promise resolved';
2270
+
2271
+ // `Promise.any` method
2272
+ // https://github.com/tc39/proposal-promise-any
2273
+ _export({ target: 'Promise', stat: true }, {
2274
+ any: function any(iterable) {
2275
+ var C = this;
2276
+ var capability = newPromiseCapability.f(C);
2277
+ var resolve = capability.resolve;
2278
+ var reject = capability.reject;
2279
+ var result = perform(function () {
2280
+ var promiseResolve = aFunction$1(C.resolve);
2281
+ var errors = [];
2282
+ var counter = 0;
2283
+ var remaining = 1;
2284
+ var alreadyResolved = false;
2285
+ iterate_1(iterable, function (promise) {
2286
+ var index = counter++;
2287
+ var alreadyRejected = false;
2288
+ errors.push(undefined);
2289
+ remaining++;
2290
+ promiseResolve.call(C, promise).then(function (value) {
2291
+ if (alreadyRejected || alreadyResolved) return;
2292
+ alreadyResolved = true;
2293
+ resolve(value);
2294
+ }, function (e) {
2295
+ if (alreadyRejected || alreadyResolved) return;
2296
+ alreadyRejected = true;
2297
+ errors[index] = e;
2298
+ --remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
2299
+ });
2300
+ });
2301
+ --remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
2302
+ });
2303
+ if (result.error) reject(result.value);
2304
+ return capability.promise;
2305
+ }
2306
+ });
2307
+
2308
+ /**
2309
+ * Default values for all Dinero objects.
2310
+ *
2311
+ * You can override default values for all subsequent Dinero objects by changing them directly on the global `Dinero` object.
2312
+ * Existing instances won't be affected.
2313
+ *
2314
+ * @property {Number} defaultAmount - The default amount for new Dinero objects (see {@link module:Dinero Dinero} for format).
2315
+ * @property {String} defaultCurrency - The default currency for new Dinero objects (see {@link module:Dinero Dinero} for format).
2316
+ * @property {Number} defaultPrecision - The default precision for new Dinero objects (see {@link module:Dinero Dinero} for format).
2317
+ *
2318
+ * @example
2319
+ * // Will set currency to 'EUR' for all Dinero objects.
2320
+ * Dinero.defaultCurrency = 'EUR'
2321
+ *
2322
+ * @type {Object}
2323
+ */
2324
+ var Defaults = {
2325
+ defaultAmount: 0,
2326
+ defaultCurrency: 'USD',
2327
+ defaultPrecision: 2
2328
+ };
2329
+ /**
2330
+ * Global settings for all Dinero objects.
2331
+ *
2332
+ * You can override global values for all subsequent Dinero objects by changing them directly on the global `Dinero` object.
2333
+ * Existing instances won't be affected.
2334
+ *
2335
+ * @property {String} globalLocale - The global locale for new Dinero objects (see {@link module:Dinero~setLocale setLocale} for format).
2336
+ * @property {String} globalFormat - The global format for new Dinero objects (see {@link module:Dinero~toFormat toFormat} for format).
2337
+ * @property {String} globalRoundingMode - The global rounding mode for new Dinero objects (see {@link module:Dinero~multiply multiply} or {@link module:Dinero~divide divide} for format).
2338
+ * @property {String} globalFormatRoundingMode - The global rounding mode to format new Dinero objects (see {@link module:Dinero~toFormat toFormat} or {@link module:Dinero~toRoundedUnit toRoundedUnit} for format).
2339
+ * @property {(String|Promise)} globalExchangeRatesApi.endpoint - The global exchange rate API endpoint for new Dinero objects, or the global promise that resolves to the exchanges rates (see {@link module:Dinero~convert convert} for format).
2340
+ * @property {String} globalExchangeRatesApi.propertyPath - The global exchange rate API property path for new Dinero objects (see {@link module:Dinero~convert convert} for format).
2341
+ * @property {Object} globalExchangeRatesApi.headers - The global exchange rate API headers for new Dinero objects (see {@link module:Dinero~convert convert} for format).
2342
+ *
2343
+ * @example
2344
+ * // Will set locale to 'fr-FR' for all Dinero objects.
2345
+ * Dinero.globalLocale = 'fr-FR'
2346
+ * @example
2347
+ * // Will set global exchange rate API parameters for all Dinero objects.
2348
+ * Dinero.globalExchangeRatesApi = {
2349
+ * endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
2350
+ * propertyPath: 'data.rates.{{to}}',
2351
+ * headers: {
2352
+ * 'user-key': 'xxxxxxxxx'
2353
+ * }
2354
+ * }
2355
+ *
2356
+ * @type {Object}
2357
+ */
2358
+
2359
+ var Globals = {
2360
+ globalLocale: 'en-US',
2361
+ globalFormat: '$0,0.00',
2362
+ globalRoundingMode: 'HALF_EVEN',
2363
+ globalFormatRoundingMode: 'HALF_AWAY_FROM_ZERO',
2364
+ globalExchangeRatesApi: {
2365
+ endpoint: undefined,
2366
+ headers: undefined,
2367
+ propertyPath: undefined
2368
+ }
2369
+ };
2370
+
2371
+ function _typeof(obj) {
2372
+ "@babel/helpers - typeof";
2373
+
2374
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
2375
+ _typeof = function (obj) {
2376
+ return typeof obj;
2377
+ };
2378
+ } else {
2379
+ _typeof = function (obj) {
2380
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2381
+ };
2382
+ }
2383
+
2384
+ return _typeof(obj);
2385
+ }
2386
+
2387
+ function _toArray(arr) {
2388
+ return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
2389
+ }
2390
+
2391
+ function _arrayWithHoles(arr) {
2392
+ if (Array.isArray(arr)) return arr;
2393
+ }
2394
+
2395
+ function _iterableToArray(iter) {
2396
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
2397
+ }
2398
+
2399
+ function _unsupportedIterableToArray(o, minLen) {
2400
+ if (!o) return;
2401
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
2402
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2403
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2404
+ if (n === "Map" || n === "Set") return Array.from(o);
2405
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
2406
+ }
2407
+
2408
+ function _arrayLikeToArray(arr, len) {
2409
+ if (len == null || len > arr.length) len = arr.length;
2410
+
2411
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2412
+
2413
+ return arr2;
2414
+ }
2415
+
2416
+ function _nonIterableRest() {
2417
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2418
+ }
2419
+
2420
+ /**
2421
+ * Static methods for Dinero.
2422
+ * @ignore
2423
+ *
2424
+ * @type {Object}
2425
+ */
2426
+ var Static = {
2427
+ /**
2428
+ * Returns an array of Dinero objects, normalized to the same precision (the highest).
2429
+ *
2430
+ * @memberof module:Dinero
2431
+ * @method
2432
+ *
2433
+ * @param {Dinero[]} objects - An array of Dinero objects
2434
+ *
2435
+ * @example
2436
+ * // returns an array of Dinero objects
2437
+ * // both with a precision of 3
2438
+ * // and an amount of 1000
2439
+ * Dinero.normalizePrecision([
2440
+ * Dinero({ amount: 100, precision: 2 }),
2441
+ * Dinero({ amount: 1000, precision: 3 })
2442
+ * ])
2443
+ *
2444
+ * @return {Dinero[]}
2445
+ */
2446
+ normalizePrecision: function normalizePrecision(objects) {
2447
+ var highestPrecision = objects.reduce(function (a, b) {
2448
+ return Math.max(a.getPrecision(), b.getPrecision());
2449
+ });
2450
+ return objects.map(function (object) {
2451
+ return object.getPrecision() !== highestPrecision ? object.convertPrecision(highestPrecision) : object;
2452
+ });
2453
+ },
2454
+
2455
+ /**
2456
+ * Returns the smallest Dinero object from an array of Dinero objects
2457
+ *
2458
+ * @memberof module:Dinero
2459
+ * @method
2460
+ *
2461
+ * @param {Dinero[]} objects - An array of Dinero objects
2462
+ *
2463
+ * @example
2464
+ * // returns the smallest Dinero object with amount of 500 from an array of Dinero objects with different precisions
2465
+ * Dinero.minimum([
2466
+ * Dinero({ amount: 500, precision: 3 }),
2467
+ * Dinero({ amount: 100, precision: 2 })
2468
+ * ])
2469
+ * @example
2470
+ * // returns the smallest Dinero object with amount of 50 from an array of Dinero objects
2471
+ * Dinero.minimum([
2472
+ * Dinero({ amount: 50 }),
2473
+ * Dinero({ amount: 100 })
2474
+ * ])
2475
+ *
2476
+ * @return {Dinero[]}
2477
+ */
2478
+ minimum: function minimum(objects) {
2479
+ var _objects = _toArray(objects),
2480
+ firstObject = _objects[0],
2481
+ tailObjects = _objects.slice(1);
2482
+
2483
+ var currentMinimum = firstObject;
2484
+ tailObjects.forEach(function (obj) {
2485
+ currentMinimum = currentMinimum.lessThan(obj) ? currentMinimum : obj;
2486
+ });
2487
+ return currentMinimum;
2488
+ },
2489
+
2490
+ /**
2491
+ * Returns the biggest Dinero object from an array of Dinero objects
2492
+ *
2493
+ * @memberof module:Dinero
2494
+ * @method
2495
+ *
2496
+ * @param {Dinero[]} objects - An array of Dinero objects
2497
+ *
2498
+ * @example
2499
+ * // returns the biggest Dinero object with amount of 20, from an array of Dinero objects with different precisions
2500
+ * Dinero.maximum([
2501
+ * Dinero({ amount: 20, precision: 2 }),
2502
+ * Dinero({ amount: 150, precision: 3 })
2503
+ * ])
2504
+ * @example
2505
+ * // returns the biggest Dinero object with amount of 100, from an array of Dinero objects
2506
+ * Dinero.maximum([
2507
+ * Dinero({ amount: 100 }),
2508
+ * Dinero({ amount: 50 })
2509
+ * ])
2510
+ *
2511
+ * @return {Dinero[]}
2512
+ */
2513
+ maximum: function maximum(objects) {
2514
+ var _objects2 = _toArray(objects),
2515
+ firstObject = _objects2[0],
2516
+ tailObjects = _objects2.slice(1);
2517
+
2518
+ var currentMaximum = firstObject;
2519
+ tailObjects.forEach(function (obj) {
2520
+ currentMaximum = currentMaximum.greaterThan(obj) ? currentMaximum : obj;
2521
+ });
2522
+ return currentMaximum;
2523
+ }
2524
+ };
2525
+
2526
+ /**
2527
+ * Returns whether a value is numeric.
2528
+ * @ignore
2529
+ *
2530
+ * @param {} value - The value to test.
2531
+ *
2532
+ * @return {Boolean}
2533
+ */
2534
+ function isNumeric(value) {
2535
+ return !isNaN(parseInt(value)) && isFinite(value);
2536
+ }
2537
+ /**
2538
+ * Returns whether a value is a percentage.
2539
+ * @ignore
2540
+ *
2541
+ * @param {} percentage - The percentage to test.
2542
+ *
2543
+ * @return {Boolean}
2544
+ */
2545
+
2546
+ function isPercentage(percentage) {
2547
+ return isNumeric(percentage) && percentage <= 100 && percentage >= 0;
2548
+ }
2549
+ /**
2550
+ * Returns whether an array of ratios is valid.
2551
+ * @ignore
2552
+ *
2553
+ * @param {} ratios - The ratios to test.
2554
+ *
2555
+ * @return {Boolean}
2556
+ */
2557
+
2558
+ function areValidRatios(ratios) {
2559
+ return ratios.length > 0 && ratios.every(function (ratio) {
2560
+ return ratio >= 0;
2561
+ }) && ratios.some(function (ratio) {
2562
+ return ratio > 0;
2563
+ });
2564
+ }
2565
+ /**
2566
+ * Returns whether a value is even.
2567
+ * @ignore
2568
+ *
2569
+ * @param {Number} value - The value to test.
2570
+ *
2571
+ * @return {Boolean}
2572
+ */
2573
+
2574
+ function isEven(value) {
2575
+ return value % 2 === 0;
2576
+ }
2577
+ /**
2578
+ * Returns whether a value is a float.
2579
+ * @ignore
2580
+ *
2581
+ * @param {} value - The value to test.
2582
+ *
2583
+ * @return {Boolean}
2584
+ */
2585
+
2586
+ function isFloat(value) {
2587
+ return isNumeric(value) && !Number.isInteger(value);
2588
+ }
2589
+ /**
2590
+ * Returns how many fraction digits a number has.
2591
+ * @ignore
2592
+ *
2593
+ * @param {Number} [number=0] - The number to test.
2594
+ *
2595
+ * @return {Number}
2596
+ */
2597
+
2598
+ function countFractionDigits() {
2599
+ var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2600
+ var stringRepresentation = number.toString();
2601
+
2602
+ if (stringRepresentation.indexOf('e-') > 0) {
2603
+ // It's too small for a normal string representation, e.g. 1e-7 instead of 0.00000001
2604
+ return parseInt(stringRepresentation.split('e-')[1]);
2605
+ } else {
2606
+ var fractionDigits = stringRepresentation.split('.')[1];
2607
+ return fractionDigits ? fractionDigits.length : 0;
2608
+ }
2609
+ }
2610
+ /**
2611
+ * Returns whether a number is half.
2612
+ * @ignore
2613
+ *
2614
+ * @param {Number} number - The number to test.
2615
+ *
2616
+ * @return {Number}
2617
+ */
2618
+
2619
+ function isHalf(number) {
2620
+ return Math.abs(number) % 1 === 0.5;
2621
+ }
2622
+ /**
2623
+ * Fetches a JSON resource.
2624
+ * @ignore
2625
+ *
2626
+ * @param {String} url - The resource to fetch.
2627
+ * @param {Object} [options.headers] - The headers to pass.
2628
+ *
2629
+ * @throws {Error} If `request.status` is lesser than 200 or greater or equal to 400.
2630
+ * @throws {Error} If network fails.
2631
+ *
2632
+ * @return {JSON}
2633
+ */
2634
+
2635
+ function getJSON(url) {
2636
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2637
+ return new Promise(function (resolve, reject) {
2638
+ var request = Object.assign(new XMLHttpRequest(), {
2639
+ onreadystatechange: function onreadystatechange() {
2640
+ if (request.readyState === 4) {
2641
+ if (request.status >= 200 && request.status < 400) resolve(JSON.parse(request.responseText));else reject(new Error(request.statusText));
2642
+ }
2643
+ },
2644
+ onerror: function onerror() {
2645
+ reject(new Error('Network error'));
2646
+ }
2647
+ });
2648
+ request.open('GET', url, true);
2649
+ setXHRHeaders(request, options.headers);
2650
+ request.send();
2651
+ });
2652
+ }
2653
+ /**
2654
+ * Returns an XHR object with attached headers.
2655
+ * @ignore
2656
+ *
2657
+ * @param {XMLHttpRequest} xhr - The XHR request to set headers to.
2658
+ * @param {Object} headers - The headers to set.
2659
+ *
2660
+ * @return {XMLHttpRequest}
2661
+ */
2662
+
2663
+ function setXHRHeaders(xhr) {
2664
+ var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2665
+
2666
+ for (var header in headers) {
2667
+ xhr.setRequestHeader(header, headers[header]);
2668
+ }
2669
+
2670
+ return xhr;
2671
+ }
2672
+ /**
2673
+ * Returns whether a value is undefined.
2674
+ * @ignore
2675
+ *
2676
+ * @param {} value - The value to test.
2677
+ *
2678
+ * @return {Boolean}
2679
+ */
2680
+
2681
+ function isUndefined(value) {
2682
+ return typeof value === 'undefined';
2683
+ }
2684
+ /**
2685
+ * Returns an object flattened to one level deep.
2686
+ * @ignore
2687
+ *
2688
+ * @param {Object} object - The object to flatten.
2689
+ * @param {String} separator - The separator to use between flattened nodes.
2690
+ *
2691
+ * @return {Object}
2692
+ */
2693
+
2694
+ function flattenObject(object) {
2695
+ var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.';
2696
+ var finalObject = {};
2697
+ Object.entries(object).forEach(function (item) {
2698
+ if (_typeof(item[1]) === 'object') {
2699
+ var flatObject = flattenObject(item[1]);
2700
+ Object.entries(flatObject).forEach(function (node) {
2701
+ finalObject[item[0] + separator + node[0]] = node[1];
2702
+ });
2703
+ } else {
2704
+ finalObject[item[0]] = item[1];
2705
+ }
2706
+ });
2707
+ return finalObject;
2708
+ }
2709
+ /**
2710
+ * Returns whether a value is thenable.
2711
+ * @ignore
2712
+ *
2713
+ * @param {} value - The value to test.
2714
+ *
2715
+ * @return {Boolean}
2716
+ */
2717
+
2718
+ function isThenable$1(value) {
2719
+ return Boolean(value) && (_typeof(value) === 'object' || typeof value === 'function') && typeof value.then === 'function';
2720
+ }
2721
+
2722
+ function Calculator() {
2723
+ var floatMultiply = function floatMultiply(a, b) {
2724
+ var getFactor = function getFactor(number) {
2725
+ return Math.pow(10, countFractionDigits(number));
2726
+ };
2727
+
2728
+ var factor = Math.max(getFactor(a), getFactor(b));
2729
+ return Math.round(a * factor) * Math.round(b * factor) / (factor * factor);
2730
+ };
2731
+
2732
+ var roundingModes = {
2733
+ HALF_ODD: function HALF_ODD(number) {
2734
+ var rounded = Math.round(number);
2735
+ return isHalf(number) ? isEven(rounded) ? rounded - 1 : rounded : rounded;
2736
+ },
2737
+ HALF_EVEN: function HALF_EVEN(number) {
2738
+ var rounded = Math.round(number);
2739
+ return isHalf(number) ? isEven(rounded) ? rounded : rounded - 1 : rounded;
2740
+ },
2741
+ HALF_UP: function HALF_UP(number) {
2742
+ return Math.round(number);
2743
+ },
2744
+ HALF_DOWN: function HALF_DOWN(number) {
2745
+ return isHalf(number) ? Math.floor(number) : Math.round(number);
2746
+ },
2747
+ HALF_TOWARDS_ZERO: function HALF_TOWARDS_ZERO(number) {
2748
+ return isHalf(number) ? Math.sign(number) * Math.floor(Math.abs(number)) : Math.round(number);
2749
+ },
2750
+ HALF_AWAY_FROM_ZERO: function HALF_AWAY_FROM_ZERO(number) {
2751
+ return isHalf(number) ? Math.sign(number) * Math.ceil(Math.abs(number)) : Math.round(number);
2752
+ },
2753
+ DOWN: function DOWN(number) {
2754
+ return Math.floor(number);
2755
+ }
2756
+ };
2757
+ return {
2758
+ /**
2759
+ * Returns the sum of two numbers.
2760
+ * @ignore
2761
+ *
2762
+ * @param {Number} a - The first number to add.
2763
+ * @param {Number} b - The second number to add.
2764
+ *
2765
+ * @return {Number}
2766
+ */
2767
+ add: function add(a, b) {
2768
+ return a + b;
2769
+ },
2770
+
2771
+ /**
2772
+ * Returns the difference of two numbers.
2773
+ * @ignore
2774
+ *
2775
+ * @param {Number} a - The first number to subtract.
2776
+ * @param {Number} b - The second number to subtract.
2777
+ *
2778
+ * @return {Number}
2779
+ */
2780
+ subtract: function subtract(a, b) {
2781
+ return a - b;
2782
+ },
2783
+
2784
+ /**
2785
+ * Returns the product of two numbers.
2786
+ * @ignore
2787
+ *
2788
+ * @param {Number} a - The first number to multiply.
2789
+ * @param {Number} b - The second number to multiply.
2790
+ *
2791
+ * @return {Number}
2792
+ */
2793
+ multiply: function multiply(a, b) {
2794
+ return isFloat(a) || isFloat(b) ? floatMultiply(a, b) : a * b;
2795
+ },
2796
+
2797
+ /**
2798
+ * Returns the quotient of two numbers.
2799
+ * @ignore
2800
+ *
2801
+ * @param {Number} a - The first number to divide.
2802
+ * @param {Number} b - The second number to divide.
2803
+ *
2804
+ * @return {Number}
2805
+ */
2806
+ divide: function divide(a, b) {
2807
+ return a / b;
2808
+ },
2809
+
2810
+ /**
2811
+ * Returns the remainder of two numbers.
2812
+ * @ignore
2813
+ *
2814
+ * @param {Number} a - The first number to divide.
2815
+ * @param {Number} b - The second number to divide.
2816
+ *
2817
+ * @return {Number}
2818
+ */
2819
+ modulo: function modulo(a, b) {
2820
+ return a % b;
2821
+ },
2822
+
2823
+ /**
2824
+ * Returns a rounded number based off a specific rounding mode.
2825
+ * @ignore
2826
+ *
2827
+ * @param {Number} number - The number to round.
2828
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use.
2829
+ *
2830
+ * @returns {Number}
2831
+ */
2832
+ round: function round(number) {
2833
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HALF_EVEN';
2834
+ return roundingModes[roundingMode](number);
2835
+ }
2836
+ };
2837
+ }
2838
+
2839
+ var calculator = Calculator();
2840
+ function Format(format) {
2841
+ var matches = /^(?:(\$|USD)?0(?:(,)0)?(\.)?(0+)?|0(?:(,)0)?(\.)?(0+)?\s?(dollar)?)$/gm.exec(format);
2842
+ return {
2843
+ /**
2844
+ * Returns the matches.
2845
+ * @ignore
2846
+ *
2847
+ * @return {Array}
2848
+ */
2849
+ getMatches: function getMatches() {
2850
+ return matches !== null ? matches.slice(1).filter(function (match) {
2851
+ return !isUndefined(match);
2852
+ }) : [];
2853
+ },
2854
+
2855
+ /**
2856
+ * Returns the amount of fraction digits to display.
2857
+ * @ignore
2858
+ *
2859
+ * @return {Number}
2860
+ */
2861
+ getMinimumFractionDigits: function getMinimumFractionDigits() {
2862
+ var decimalPosition = function decimalPosition(match) {
2863
+ return match === '.';
2864
+ };
2865
+
2866
+ return !isUndefined(this.getMatches().find(decimalPosition)) ? this.getMatches()[calculator.add(this.getMatches().findIndex(decimalPosition), 1)].split('').length : 0;
2867
+ },
2868
+
2869
+ /**
2870
+ * Returns the currency display mode.
2871
+ * @ignore
2872
+ *
2873
+ * @return {String}
2874
+ */
2875
+ getCurrencyDisplay: function getCurrencyDisplay() {
2876
+ var modes = {
2877
+ USD: 'code',
2878
+ dollar: 'name',
2879
+ $: 'symbol'
2880
+ };
2881
+ return modes[this.getMatches().find(function (match) {
2882
+ return match === 'USD' || match === 'dollar' || match === '$';
2883
+ })];
2884
+ },
2885
+
2886
+ /**
2887
+ * Returns the formatting style.
2888
+ * @ignore
2889
+ *
2890
+ * @return {String}
2891
+ */
2892
+ getStyle: function getStyle() {
2893
+ return !isUndefined(this.getCurrencyDisplay(this.getMatches())) ? 'currency' : 'decimal';
2894
+ },
2895
+
2896
+ /**
2897
+ * Returns whether grouping should be used or not.
2898
+ * @ignore
2899
+ *
2900
+ * @return {Boolean}
2901
+ */
2902
+ getUseGrouping: function getUseGrouping() {
2903
+ return !isUndefined(this.getMatches().find(function (match) {
2904
+ return match === ',';
2905
+ }));
2906
+ }
2907
+ };
2908
+ }
2909
+
2910
+ function CurrencyConverter(options) {
2911
+ /* istanbul ignore next */
2912
+ var mergeTags = function mergeTags() {
2913
+ var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2914
+ var tags = arguments.length > 1 ? arguments[1] : undefined;
2915
+
2916
+ for (var tag in tags) {
2917
+ string = string.replace("{{".concat(tag, "}}"), tags[tag]);
2918
+ }
2919
+
2920
+ return string;
2921
+ };
2922
+ /* istanbul ignore next */
2923
+
2924
+
2925
+ var getRatesFromRestApi = function getRatesFromRestApi(from, to) {
2926
+ return getJSON(mergeTags(options.endpoint, {
2927
+ from: from,
2928
+ to: to
2929
+ }), {
2930
+ headers: options.headers
2931
+ });
2932
+ };
2933
+
2934
+ return {
2935
+ /**
2936
+ * Returns the exchange rate.
2937
+ * @ignore
2938
+ *
2939
+ * @param {String} from - The base currency.
2940
+ * @param {String} to - The destination currency.
2941
+ *
2942
+ * @return {Promise}
2943
+ */
2944
+ getExchangeRate: function getExchangeRate(from, to) {
2945
+ return (isThenable$1(options.endpoint) ? options.endpoint : getRatesFromRestApi(from, to)).then(function (data) {
2946
+ return flattenObject(data)[mergeTags(options.propertyPath, {
2947
+ from: from,
2948
+ to: to
2949
+ })];
2950
+ });
2951
+ }
2952
+ };
2953
+ }
2954
+
2955
+ /**
2956
+ * Performs an assertion.
2957
+ * @ignore
2958
+ *
2959
+ * @param {Boolean} condition - The expression to assert.
2960
+ * @param {String} errorMessage - The message to throw if the assertion fails
2961
+ * @param {ErrorConstructor} [ErrorType=Error] - The error to throw if the assertion fails.
2962
+ *
2963
+ * @throws {Error} If `condition` returns `false`.
2964
+ */
2965
+
2966
+ function assert(condition, errorMessage) {
2967
+ var ErrorType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Error;
2968
+ if (!condition) throw new ErrorType(errorMessage);
2969
+ }
2970
+ /**
2971
+ * Asserts a value is a percentage.
2972
+ * @ignore
2973
+ *
2974
+ * @param {} percentage - The percentage to test.
2975
+ *
2976
+ * @throws {RangeError} If `percentage` is out of range.
2977
+ */
2978
+
2979
+ function assertPercentage(percentage) {
2980
+ assert(isPercentage(percentage), 'You must provide a numeric value between 0 and 100.', RangeError);
2981
+ }
2982
+ /**
2983
+ * Asserts an array of ratios is valid.
2984
+ * @ignore
2985
+ *
2986
+ * @param {} ratios - The ratios to test.
2987
+ *
2988
+ * @throws {TypeError} If `ratios` are invalid.
2989
+ */
2990
+
2991
+ function assertValidRatios(ratios) {
2992
+ assert(areValidRatios(ratios), 'You must provide a non-empty array of numeric values greater than 0.', TypeError);
2993
+ }
2994
+ /**
2995
+ * Asserts a value is an integer.
2996
+ * @ignore
2997
+ *
2998
+ * @param {} number - The value to test.
2999
+ *
3000
+ * @throws {TypeError}
3001
+ */
3002
+
3003
+ function assertInteger(number) {
3004
+ assert(Number.isInteger(number), 'You must provide an integer.', TypeError);
3005
+ }
3006
+
3007
+ var calculator$1 = Calculator();
3008
+ /**
3009
+ * A Dinero object is an immutable data structure representing a specific monetary value.
3010
+ * It comes with methods for creating, parsing, manipulating, testing, transforming and formatting them.
3011
+ *
3012
+ * A Dinero object has:
3013
+ *
3014
+ * * An `amount`, expressed in minor currency units, as an integer.
3015
+ * * A `currency`, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
3016
+ * * A `precision`, expressed as an integer, to represent the number of decimal places in the `amount`.
3017
+ * This is helpful when you want to represent fractional minor currency units (e.g.: $10.4545).
3018
+ * You can also use it to represent a currency with a different [exponent](https://en.wikipedia.org/wiki/ISO_4217#Treatment_of_minor_currency_units_.28the_.22exponent.22.29) than `2` (e.g.: Iraqi dinar with 1000 fils in 1 dinar (exponent of `3`), Japanese yen with no sub-units (exponent of `0`)).
3019
+ * * An optional `locale` property that affects how output strings are formatted.
3020
+ *
3021
+ * Here's an overview of the public API:
3022
+ *
3023
+ * * **Access:** {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~getCurrency getCurrency}, {@link module:Dinero~getLocale getLocale} and {@link module:Dinero~getPrecision getPrecision}.
3024
+ * * **Manipulation:** {@link module:Dinero~add add}, {@link module:Dinero~subtract subtract}, {@link module:Dinero~multiply multiply}, {@link module:Dinero~divide divide}, {@link module:Dinero~percentage percentage}, {@link module:Dinero~allocate allocate} and {@link module:Dinero~convert convert}.
3025
+ * * **Testing:** {@link module:Dinero~equalsTo equalsTo}, {@link module:Dinero~lessThan lessThan}, {@link module:Dinero~lessThanOrEqual lessThanOrEqual}, {@link module:Dinero~greaterThan greaterThan}, {@link module:Dinero~greaterThanOrEqual greaterThanOrEqual}, {@link module:Dinero~isZero isZero}, {@link module:Dinero~isPositive isPositive}, {@link module:Dinero~isNegative isNegative}, {@link module:Dinero~hasSubUnits hasSubUnits}, {@link module:Dinero~hasSameCurrency hasSameCurrency} and {@link module:Dinero~hasSameAmount hasSameAmount}.
3026
+ * * **Configuration:** {@link module:Dinero~setLocale setLocale}.
3027
+ * * **Conversion & formatting:** {@link module:Dinero~toFormat toFormat}, {@link module:Dinero~toUnit toUnit}, {@link module:Dinero~toRoundedUnit toRoundedUnit}, {@link module:Dinero~toObject toObject}, {@link module:Dinero~toJSON toJSON}, {@link module:Dinero~convertPrecision convertPrecision} and {@link module:Dinero.normalizePrecision normalizePrecision}.
3028
+ *
3029
+ * Dinero.js uses `number`s under the hood, so it's constrained by the [double-precision floating-point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format). Using values over [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MAX_SAFE_INTEGER) or below [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MIN_SAFE_INTEGER) will yield unpredictable results.
3030
+ * Same goes with performing calculations: once the internal `amount` value exceeds those limits, precision is no longer guaranteed.
3031
+ *
3032
+ * @module Dinero
3033
+ * @param {Number} [options.amount=0] - The amount in minor currency units (as an integer).
3034
+ * @param {String} [options.currency='USD'] - An ISO 4217 currency code.
3035
+ * @param {String} [options.precision=2] - The number of decimal places to represent.
3036
+ *
3037
+ * @throws {TypeError} If `amount` or `precision` is invalid. Integers over [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MAX_SAFE_INTEGER) or below [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MIN_SAFE_INTEGER) are considered valid, even though they can lead to imprecise amounts.
3038
+ *
3039
+ * @return {Object}
3040
+ */
3041
+
3042
+ var Dinero = function Dinero(options) {
3043
+ var _Object$assign = Object.assign({}, {
3044
+ amount: Dinero.defaultAmount,
3045
+ currency: Dinero.defaultCurrency,
3046
+ precision: Dinero.defaultPrecision
3047
+ }, options),
3048
+ amount = _Object$assign.amount,
3049
+ currency = _Object$assign.currency,
3050
+ precision = _Object$assign.precision;
3051
+
3052
+ assertInteger(amount);
3053
+ assertInteger(precision);
3054
+ var globalLocale = Dinero.globalLocale,
3055
+ globalFormat = Dinero.globalFormat,
3056
+ globalRoundingMode = Dinero.globalRoundingMode,
3057
+ globalFormatRoundingMode = Dinero.globalFormatRoundingMode;
3058
+ var globalExchangeRatesApi = Object.assign({}, Dinero.globalExchangeRatesApi);
3059
+ /**
3060
+ * Uses ES5 function notation so `this` can be passed through call, apply and bind
3061
+ * @ignore
3062
+ */
3063
+
3064
+ var create = function create(options) {
3065
+ var obj = Object.assign({}, Object.assign({}, {
3066
+ amount: amount,
3067
+ currency: currency,
3068
+ precision: precision
3069
+ }, options), Object.assign({}, {
3070
+ locale: this.locale
3071
+ }, options));
3072
+ return Object.assign(Dinero({
3073
+ amount: obj.amount,
3074
+ currency: obj.currency,
3075
+ precision: obj.precision
3076
+ }), {
3077
+ locale: obj.locale
3078
+ });
3079
+ };
3080
+ /**
3081
+ * Uses ES5 function notation so `this` can be passed through call, apply and bind
3082
+ * @ignore
3083
+ */
3084
+
3085
+
3086
+ var assertSameCurrency = function assertSameCurrency(comparator) {
3087
+ assert(this.hasSameCurrency(comparator), 'You must provide a Dinero instance with the same currency.', TypeError);
3088
+ };
3089
+
3090
+ return {
3091
+ /**
3092
+ * Returns the amount.
3093
+ *
3094
+ * @example
3095
+ * // returns 500
3096
+ * Dinero({ amount: 500 }).getAmount()
3097
+ *
3098
+ * @return {Number}
3099
+ */
3100
+ getAmount: function getAmount() {
3101
+ return amount;
3102
+ },
3103
+
3104
+ /**
3105
+ * Returns the currency.
3106
+ *
3107
+ * @example
3108
+ * // returns 'EUR'
3109
+ * Dinero({ currency: 'EUR' }).getCurrency()
3110
+ *
3111
+ * @return {String}
3112
+ */
3113
+ getCurrency: function getCurrency() {
3114
+ return currency;
3115
+ },
3116
+
3117
+ /**
3118
+ * Returns the locale.
3119
+ *
3120
+ * @example
3121
+ * // returns 'fr-FR'
3122
+ * Dinero().setLocale('fr-FR').getLocale()
3123
+ *
3124
+ * @return {String}
3125
+ */
3126
+ getLocale: function getLocale() {
3127
+ return this.locale || globalLocale;
3128
+ },
3129
+
3130
+ /**
3131
+ * Returns a new Dinero object with an embedded locale.
3132
+ *
3133
+ * @param {String} newLocale - The new locale as an {@link http://tools.ietf.org/html/rfc5646 BCP 47 language tag}.
3134
+ *
3135
+ * @example
3136
+ * // Returns a Dinero object with locale 'ja-JP'
3137
+ * Dinero().setLocale('ja-JP')
3138
+ *
3139
+ * @return {Dinero}
3140
+ */
3141
+ setLocale: function setLocale(newLocale) {
3142
+ return create.call(this, {
3143
+ locale: newLocale
3144
+ });
3145
+ },
3146
+
3147
+ /**
3148
+ * Returns the precision.
3149
+ *
3150
+ * @example
3151
+ * // returns 3
3152
+ * Dinero({ precision: 3 }).getPrecision()
3153
+ *
3154
+ * @return {Number}
3155
+ */
3156
+ getPrecision: function getPrecision() {
3157
+ return precision;
3158
+ },
3159
+
3160
+ /**
3161
+ * Returns a new Dinero object with a new precision and a converted amount.
3162
+ *
3163
+ * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3164
+ * This can be necessary when you need to convert objects to a smaller precision.
3165
+ *
3166
+ * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent conversions for safer results.
3167
+ * You can also specify a different `roundingMode` to better fit your needs.
3168
+ *
3169
+ * @param {Number} newPrecision - The new precision.
3170
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3171
+ *
3172
+ * @example
3173
+ * // Returns a Dinero object with precision 3 and amount 1000
3174
+ * Dinero({ amount: 100, precision: 2 }).convertPrecision(3)
3175
+ *
3176
+ * @throws {TypeError} If `newPrecision` is invalid.
3177
+ *
3178
+ * @return {Dinero}
3179
+ */
3180
+ convertPrecision: function convertPrecision(newPrecision) {
3181
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3182
+ assertInteger(newPrecision);
3183
+ var precision = this.getPrecision();
3184
+ var isNewPrecisionLarger = newPrecision > precision;
3185
+ var operation = isNewPrecisionLarger ? calculator$1.multiply : calculator$1.divide;
3186
+ var terms = isNewPrecisionLarger ? [newPrecision, precision] : [precision, newPrecision];
3187
+ var factor = Math.pow(10, calculator$1.subtract.apply(calculator$1, terms));
3188
+ return create.call(this, {
3189
+ amount: calculator$1.round(operation(this.getAmount(), factor), roundingMode),
3190
+ precision: newPrecision
3191
+ });
3192
+ },
3193
+
3194
+ /**
3195
+ * Returns a new Dinero object that represents the sum of this and an other Dinero object.
3196
+ *
3197
+ * If Dinero objects have a different `precision`, they will be first converted to the highest.
3198
+ *
3199
+ * @param {Dinero} addend - The Dinero object to add.
3200
+ *
3201
+ * @example
3202
+ * // returns a Dinero object with amount 600
3203
+ * Dinero({ amount: 400 }).add(Dinero({ amount: 200 }))
3204
+ * @example
3205
+ * // returns a Dinero object with amount 144545 and precision 4
3206
+ * Dinero({ amount: 400 }).add(Dinero({ amount: 104545, precision: 4 }))
3207
+ *
3208
+ * @throws {TypeError} If `addend` has a different currency.
3209
+ *
3210
+ * @return {Dinero}
3211
+ */
3212
+ add: function add(addend) {
3213
+ assertSameCurrency.call(this, addend);
3214
+ var addends = Dinero.normalizePrecision([this, addend]);
3215
+ return create.call(this, {
3216
+ amount: calculator$1.add(addends[0].getAmount(), addends[1].getAmount()),
3217
+ precision: addends[0].getPrecision()
3218
+ });
3219
+ },
3220
+
3221
+ /**
3222
+ * Returns a new Dinero object that represents the difference of this and an other Dinero object.
3223
+ *
3224
+ * If Dinero objects have a different `precision`, they will be first converted to the highest.
3225
+ *
3226
+ * @param {Dinero} subtrahend - The Dinero object to subtract.
3227
+ *
3228
+ * @example
3229
+ * // returns a Dinero object with amount 200
3230
+ * Dinero({ amount: 400 }).subtract(Dinero({ amount: 200 }))
3231
+ * @example
3232
+ * // returns a Dinero object with amount 64545 and precision 4
3233
+ * Dinero({ amount: 104545, precision: 4 }).subtract(Dinero({ amount: 400 }))
3234
+ *
3235
+ * @throws {TypeError} If `subtrahend` has a different currency.
3236
+ *
3237
+ * @return {Dinero}
3238
+ */
3239
+ subtract: function subtract(subtrahend) {
3240
+ assertSameCurrency.call(this, subtrahend);
3241
+ var subtrahends = Dinero.normalizePrecision([this, subtrahend]);
3242
+ return create.call(this, {
3243
+ amount: calculator$1.subtract(subtrahends[0].getAmount(), subtrahends[1].getAmount()),
3244
+ precision: subtrahends[0].getPrecision()
3245
+ });
3246
+ },
3247
+
3248
+ /**
3249
+ * Returns a new Dinero object that represents the multiplied value by the given factor.
3250
+ *
3251
+ * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3252
+ *
3253
+ * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
3254
+ * You can also specify a different `roundingMode` to better fit your needs.
3255
+ *
3256
+ * @param {Number} multiplier - The factor to multiply by.
3257
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3258
+ *
3259
+ * @example
3260
+ * // returns a Dinero object with amount 1600
3261
+ * Dinero({ amount: 400 }).multiply(4)
3262
+ * @example
3263
+ * // returns a Dinero object with amount 800
3264
+ * Dinero({ amount: 400 }).multiply(2.001)
3265
+ * @example
3266
+ * // returns a Dinero object with amount 801
3267
+ * Dinero({ amount: 400 }).multiply(2.00125, 'HALF_UP')
3268
+ *
3269
+ * @return {Dinero}
3270
+ */
3271
+ multiply: function multiply(multiplier) {
3272
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3273
+ return create.call(this, {
3274
+ amount: calculator$1.round(calculator$1.multiply(this.getAmount(), multiplier), roundingMode)
3275
+ });
3276
+ },
3277
+
3278
+ /**
3279
+ * Returns a new Dinero object that represents the divided value by the given factor.
3280
+ *
3281
+ * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3282
+ *
3283
+ * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
3284
+ * You can also specify a different `roundingMode` to better fit your needs.
3285
+ *
3286
+ * As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
3287
+ *
3288
+ * @param {Number} divisor - The factor to divide by.
3289
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3290
+ *
3291
+ * @example
3292
+ * // returns a Dinero object with amount 100
3293
+ * Dinero({ amount: 400 }).divide(4)
3294
+ * @example
3295
+ * // returns a Dinero object with amount 52
3296
+ * Dinero({ amount: 105 }).divide(2)
3297
+ * @example
3298
+ * // returns a Dinero object with amount 53
3299
+ * Dinero({ amount: 105 }).divide(2, 'HALF_UP')
3300
+ *
3301
+ * @return {Dinero}
3302
+ */
3303
+ divide: function divide(divisor) {
3304
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3305
+ return create.call(this, {
3306
+ amount: calculator$1.round(calculator$1.divide(this.getAmount(), divisor), roundingMode)
3307
+ });
3308
+ },
3309
+
3310
+ /**
3311
+ * Returns a new Dinero object that represents a percentage of this.
3312
+ *
3313
+ * As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
3314
+ *
3315
+ * @param {Number} percentage - The percentage to extract (between 0 and 100).
3316
+ * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3317
+ *
3318
+ * @example
3319
+ * // returns a Dinero object with amount 5000
3320
+ * Dinero({ amount: 10000 }).percentage(50)
3321
+ * @example
3322
+ * // returns a Dinero object with amount 29
3323
+ * Dinero({ amount: 57 }).percentage(50, "HALF_ODD")
3324
+ *
3325
+ * @throws {RangeError} If `percentage` is out of range.
3326
+ *
3327
+ * @return {Dinero}
3328
+ */
3329
+ percentage: function percentage(_percentage) {
3330
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3331
+ assertPercentage(_percentage);
3332
+ return this.multiply(calculator$1.divide(_percentage, 100), roundingMode);
3333
+ },
3334
+
3335
+ /**
3336
+ * Allocates the amount of a Dinero object according to a list of ratios.
3337
+ *
3338
+ * Sometimes you need to split monetary values but percentages can't cut it without adding or losing pennies.
3339
+ * A good example is invoicing: let's say you need to bill $1,000.03 and you want a 50% downpayment.
3340
+ * If you use {@link module:Dinero~percentage percentage}, you'll get an accurate Dinero object but the amount won't be billable: you can't split a penny.
3341
+ * If you round it, you'll bill a penny extra.
3342
+ * With {@link module:Dinero~allocate allocate}, you can split a monetary amount then distribute the remainder as evenly as possible.
3343
+ *
3344
+ * You can use percentage style or ratio style for `ratios`: `[25, 75]` and `[1, 3]` will do the same thing.
3345
+ *
3346
+ * Since v1.8.0, you can use zero ratios (such as [0, 50, 50]). If there's a remainder to distribute, zero ratios are skipped and return a Dinero object with amount zero.
3347
+ *
3348
+ * @param {Number[]} ratios - The ratios to allocate the money to.
3349
+ *
3350
+ * @example
3351
+ * // returns an array of two Dinero objects
3352
+ * // the first one with an amount of 502
3353
+ * // the second one with an amount of 501
3354
+ * Dinero({ amount: 1003 }).allocate([50, 50])
3355
+ * @example
3356
+ * // returns an array of two Dinero objects
3357
+ * // the first one with an amount of 25
3358
+ * // the second one with an amount of 75
3359
+ * Dinero({ amount: 100 }).allocate([1, 3])
3360
+ * @example
3361
+ * // since version 1.8.0
3362
+ * // returns an array of three Dinero objects
3363
+ * // the first one with an amount of 0
3364
+ * // the second one with an amount of 502
3365
+ * // the third one with an amount of 501
3366
+ * Dinero({ amount: 1003 }).allocate([0, 50, 50])
3367
+ *
3368
+ * @throws {TypeError} If ratios are invalid.
3369
+ *
3370
+ * @return {Dinero[]}
3371
+ */
3372
+ allocate: function allocate(ratios) {
3373
+ var _this = this;
3374
+
3375
+ assertValidRatios(ratios);
3376
+ var total = ratios.reduce(function (a, b) {
3377
+ return calculator$1.add(a, b);
3378
+ });
3379
+ var remainder = this.getAmount();
3380
+ var shares = ratios.map(function (ratio) {
3381
+ var share = Math.floor(calculator$1.divide(calculator$1.multiply(_this.getAmount(), ratio), total));
3382
+ remainder = calculator$1.subtract(remainder, share);
3383
+ return create.call(_this, {
3384
+ amount: share
3385
+ });
3386
+ });
3387
+ var i = 0;
3388
+
3389
+ while (remainder > 0) {
3390
+ if (ratios[i] > 0) {
3391
+ shares[i] = shares[i].add(create.call(this, {
3392
+ amount: 1
3393
+ }));
3394
+ remainder = calculator$1.subtract(remainder, 1);
3395
+ }
3396
+
3397
+ i += 1;
3398
+ }
3399
+
3400
+ return shares;
3401
+ },
3402
+
3403
+ /**
3404
+ * Returns a Promise containing a new Dinero object converted to another currency.
3405
+ *
3406
+ * You have two options to provide the exchange rates:
3407
+ *
3408
+ * 1. **Use an exchange rate REST API, and let Dinero handle the fetching and conversion.**
3409
+ * This is a simple option if you have access to an exchange rate REST API and want Dinero to do the rest.
3410
+ * 2. **Fetch the exchange rates on your own and provide them directly.**
3411
+ * This is useful if you're fetching your rates from somewhere else (a file, a database), use a different protocol or query language than REST (SOAP, GraphQL) or want to fetch rates once and cache them instead of making new requests every time.
3412
+ *
3413
+ * **If you want to use a REST API**, you must provide a third-party endpoint yourself. Dinero doesn't come bundled with an exchange rates endpoint.
3414
+ *
3415
+ * Here are some exchange rate APIs you can use:
3416
+ *
3417
+ * * [Fixer](https://fixer.io)
3418
+ * * [Open Exchange Rates](https://openexchangerates.org)
3419
+ * * [Coinbase](https://api.coinbase.com/v2/exchange-rates)
3420
+ * * More [foreign](https://github.com/toddmotto/public-apis#currency-exchange) and [crypto](https://github.com/toddmotto/public-apis#cryptocurrency) exchange rate APIs.
3421
+ *
3422
+ * **If you want to fetch your own rates and provide them directly**, you need to pass a promise that resolves to the exchanges rates.
3423
+ *
3424
+ * In both cases, you need to specify at least:
3425
+ *
3426
+ * * a **destination currency**: the currency in which you want to convert your Dinero object. You can specify it with `currency`.
3427
+ * * an **endpoint**: the API URL to query exchange rates, with parameters, or a promise that resolves to the exchange rates. You can specify it with `options.endpoint`.
3428
+ * * a **property path**: the path to access the wanted rate in your API's JSON response (or the custom promise's payload). For example, with a response of:
3429
+ * ```json
3430
+ * {
3431
+ * "data": {
3432
+ * "base": "USD",
3433
+ * "destination": "EUR",
3434
+ * "rate": "0.827728919"
3435
+ * }
3436
+ * }
3437
+ * ```
3438
+ * Then the property path is `'data.rate'`. You can specify it with `options.propertyPath`.
3439
+ *
3440
+ * The base currency (the one of your Dinero object) and the destination currency can be used as "merge tags" with the mustache syntax, respectively `{{from}}` and `{{to}}`.
3441
+ * You can use these tags to refer to these values in `options.endpoint` and `options.propertyPath`.
3442
+ *
3443
+ * For example, if you need to specify the base currency as a query parameter, you can do the following:
3444
+ *
3445
+ * ```js
3446
+ * {
3447
+ * endpoint: 'https://yourexchangerates.api/latest?base={{from}}'
3448
+ * }
3449
+ * ```
3450
+ *
3451
+ * @param {String} currency - The destination currency, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
3452
+ * @param {(String|Promise)} options.endpoint - The API endpoint to retrieve exchange rates. You can substitute this with a promise that resolves to the exchanges rates if you already have them.
3453
+ * @param {String} [options.propertyPath='rates.{{to}}'] - The property path to the rate.
3454
+ * @param {Object} [options.headers] - The HTTP headers to provide, if needed.
3455
+ * @param {String} [options.roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3456
+ *
3457
+ * @example
3458
+ * // your global API parameters
3459
+ * Dinero.globalExchangeRatesApi = { ... }
3460
+ *
3461
+ * // returns a Promise containing a Dinero object with the destination currency
3462
+ * // and the initial amount converted to the new currency.
3463
+ * Dinero({ amount: 500 }).convert('EUR')
3464
+ * @example
3465
+ * // returns a Promise containing a Dinero object,
3466
+ * // with specific API parameters and rounding mode for this specific instance.
3467
+ * Dinero({ amount: 500 })
3468
+ * .convert('XBT', {
3469
+ * endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
3470
+ * propertyPath: 'data.rates.{{to}}',
3471
+ * headers: {
3472
+ * 'user-key': 'xxxxxxxxx'
3473
+ * },
3474
+ * roundingMode: 'HALF_UP'
3475
+ * })
3476
+ * @example
3477
+ * // usage with exchange rates provided as a custom promise
3478
+ * // using the default `propertyPath` format (so it doesn't have to be specified)
3479
+ * const rates = {
3480
+ * rates: {
3481
+ * EUR: 0.81162
3482
+ * }
3483
+ * }
3484
+ *
3485
+ * Dinero({ amount: 500 })
3486
+ * .convert('EUR', {
3487
+ * endpoint: new Promise(resolve => resolve(rates))
3488
+ * })
3489
+ * @example
3490
+ * // usage with Promise.prototype.then and Promise.prototype.catch
3491
+ * Dinero({ amount: 500 })
3492
+ * .convert('EUR')
3493
+ * .then(dinero => {
3494
+ * dinero.getCurrency() // returns 'EUR'
3495
+ * })
3496
+ * .catch(err => {
3497
+ * // handle errors
3498
+ * })
3499
+ * @example
3500
+ * // usage with async/await
3501
+ * (async () => {
3502
+ * const price = await Dinero({ amount: 500 }).convert('EUR')
3503
+ * price.getCurrency() // returns 'EUR'
3504
+ * })()
3505
+ *
3506
+ * @return {Promise}
3507
+ */
3508
+ convert: function convert(currency) {
3509
+ var _this2 = this;
3510
+
3511
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
3512
+ _ref$endpoint = _ref.endpoint,
3513
+ endpoint = _ref$endpoint === void 0 ? globalExchangeRatesApi.endpoint : _ref$endpoint,
3514
+ _ref$propertyPath = _ref.propertyPath,
3515
+ propertyPath = _ref$propertyPath === void 0 ? globalExchangeRatesApi.propertyPath || 'rates.{{to}}' : _ref$propertyPath,
3516
+ _ref$headers = _ref.headers,
3517
+ headers = _ref$headers === void 0 ? globalExchangeRatesApi.headers : _ref$headers,
3518
+ _ref$roundingMode = _ref.roundingMode,
3519
+ roundingMode = _ref$roundingMode === void 0 ? globalRoundingMode : _ref$roundingMode;
3520
+
3521
+ var options = Object.assign({}, {
3522
+ endpoint: endpoint,
3523
+ propertyPath: propertyPath,
3524
+ headers: headers,
3525
+ roundingMode: roundingMode
3526
+ });
3527
+ return CurrencyConverter(options).getExchangeRate(this.getCurrency(), currency).then(function (rate) {
3528
+ assert(!isUndefined(rate), "No rate was found for the destination currency \"".concat(currency, "\"."), TypeError);
3529
+ return create.call(_this2, {
3530
+ amount: calculator$1.round(calculator$1.multiply(_this2.getAmount(), parseFloat(rate)), options.roundingMode),
3531
+ currency: currency
3532
+ });
3533
+ });
3534
+ },
3535
+
3536
+ /**
3537
+ * Checks whether the value represented by this object equals to the other.
3538
+ *
3539
+ * @param {Dinero} comparator - The Dinero object to compare to.
3540
+ *
3541
+ * @example
3542
+ * // returns true
3543
+ * Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
3544
+ * @example
3545
+ * // returns false
3546
+ * Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
3547
+ * @example
3548
+ * // returns false
3549
+ * Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
3550
+ * @example
3551
+ * // returns false
3552
+ * Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
3553
+ * @example
3554
+ * // returns true
3555
+ * Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
3556
+ * @example
3557
+ * // returns false
3558
+ * Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
3559
+ *
3560
+ * @return {Boolean}
3561
+ */
3562
+ equalsTo: function equalsTo(comparator) {
3563
+ return this.hasSameAmount(comparator) && this.hasSameCurrency(comparator);
3564
+ },
3565
+
3566
+ /**
3567
+ * Checks whether the value represented by this object is less than the other.
3568
+ *
3569
+ * @param {Dinero} comparator - The Dinero object to compare to.
3570
+ *
3571
+ * @example
3572
+ * // returns true
3573
+ * Dinero({ amount: 500 }).lessThan(Dinero({ amount: 800 }))
3574
+ * @example
3575
+ * // returns false
3576
+ * Dinero({ amount: 800 }).lessThan(Dinero({ amount: 500 }))
3577
+ * @example
3578
+ * // returns true
3579
+ * Dinero({ amount: 5000, precision: 3 }).lessThan(Dinero({ amount: 800 }))
3580
+ * @example
3581
+ * // returns false
3582
+ * Dinero({ amount: 800 }).lessThan(Dinero({ amount: 5000, precision: 3 }))
3583
+ *
3584
+ * @throws {TypeError} If `comparator` has a different currency.
3585
+ *
3586
+ * @return {Boolean}
3587
+ */
3588
+ lessThan: function lessThan(comparator) {
3589
+ assertSameCurrency.call(this, comparator);
3590
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3591
+ return comparators[0].getAmount() < comparators[1].getAmount();
3592
+ },
3593
+
3594
+ /**
3595
+ * Checks whether the value represented by this object is less than or equal to the other.
3596
+ *
3597
+ * @param {Dinero} comparator - The Dinero object to compare to.
3598
+ *
3599
+ * @example
3600
+ * // returns true
3601
+ * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 800 }))
3602
+ * @example
3603
+ * // returns true
3604
+ * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 500 }))
3605
+ * @example
3606
+ * // returns false
3607
+ * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 300 }))
3608
+ * @example
3609
+ * // returns true
3610
+ * Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 800 }))
3611
+ * @example
3612
+ * // returns true
3613
+ * Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 500 }))
3614
+ * @example
3615
+ * // returns false
3616
+ * Dinero({ amount: 800 }).lessThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3617
+ *
3618
+ * @throws {TypeError} If `comparator` has a different currency.
3619
+ *
3620
+ * @return {Boolean}
3621
+ */
3622
+ lessThanOrEqual: function lessThanOrEqual(comparator) {
3623
+ assertSameCurrency.call(this, comparator);
3624
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3625
+ return comparators[0].getAmount() <= comparators[1].getAmount();
3626
+ },
3627
+
3628
+ /**
3629
+ * Checks whether the value represented by this object is greater than the other.
3630
+ *
3631
+ * @param {Dinero} comparator - The Dinero object to compare to.
3632
+ *
3633
+ * @example
3634
+ * // returns false
3635
+ * Dinero({ amount: 500 }).greaterThan(Dinero({ amount: 800 }))
3636
+ * @example
3637
+ * // returns true
3638
+ * Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 500 }))
3639
+ * @example
3640
+ * // returns true
3641
+ * Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 5000, precision: 3 }))
3642
+ * @example
3643
+ * // returns false
3644
+ * Dinero({ amount: 5000, precision: 3 }).greaterThan(Dinero({ amount: 800 }))
3645
+ *
3646
+ * @throws {TypeError} If `comparator` has a different currency.
3647
+ *
3648
+ * @return {Boolean}
3649
+ */
3650
+ greaterThan: function greaterThan(comparator) {
3651
+ assertSameCurrency.call(this, comparator);
3652
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3653
+ return comparators[0].getAmount() > comparators[1].getAmount();
3654
+ },
3655
+
3656
+ /**
3657
+ * Checks whether the value represented by this object is greater than or equal to the other.
3658
+ *
3659
+ * @param {Dinero} comparator - The Dinero object to compare to.
3660
+ *
3661
+ * @example
3662
+ * // returns true
3663
+ * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 300 }))
3664
+ * @example
3665
+ * // returns true
3666
+ * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 500 }))
3667
+ * @example
3668
+ * // returns false
3669
+ * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 800 }))
3670
+ * @example
3671
+ * // returns true
3672
+ * Dinero({ amount: 800 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3673
+ * @example
3674
+ * // returns true
3675
+ * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3676
+ * @example
3677
+ * // returns false
3678
+ * Dinero({ amount: 5000, precision: 3 }).greaterThanOrEqual(Dinero({ amount: 800 }))
3679
+ *
3680
+ * @throws {TypeError} If `comparator` has a different currency.
3681
+ *
3682
+ * @return {Boolean}
3683
+ */
3684
+ greaterThanOrEqual: function greaterThanOrEqual(comparator) {
3685
+ assertSameCurrency.call(this, comparator);
3686
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3687
+ return comparators[0].getAmount() >= comparators[1].getAmount();
3688
+ },
3689
+
3690
+ /**
3691
+ * Checks if the value represented by this object is zero.
3692
+ *
3693
+ * @example
3694
+ * // returns true
3695
+ * Dinero({ amount: 0 }).isZero()
3696
+ * @example
3697
+ * // returns false
3698
+ * Dinero({ amount: 100 }).isZero()
3699
+ *
3700
+ * @return {Boolean}
3701
+ */
3702
+ isZero: function isZero() {
3703
+ return this.getAmount() === 0;
3704
+ },
3705
+
3706
+ /**
3707
+ * Checks if the value represented by this object is positive.
3708
+ *
3709
+ * @example
3710
+ * // returns false
3711
+ * Dinero({ amount: -10 }).isPositive()
3712
+ * @example
3713
+ * // returns true
3714
+ * Dinero({ amount: 10 }).isPositive()
3715
+ * @example
3716
+ * // returns true
3717
+ * Dinero({ amount: 0 }).isPositive()
3718
+ *
3719
+ * @return {Boolean}
3720
+ */
3721
+ isPositive: function isPositive() {
3722
+ return this.getAmount() >= 0;
3723
+ },
3724
+
3725
+ /**
3726
+ * Checks if the value represented by this object is negative.
3727
+ *
3728
+ * @example
3729
+ * // returns true
3730
+ * Dinero({ amount: -10 }).isNegative()
3731
+ * @example
3732
+ * // returns false
3733
+ * Dinero({ amount: 10 }).isNegative()
3734
+ * @example
3735
+ * // returns false
3736
+ * Dinero({ amount: 0 }).isNegative()
3737
+ *
3738
+ * @return {Boolean}
3739
+ */
3740
+ isNegative: function isNegative() {
3741
+ return this.getAmount() < 0;
3742
+ },
3743
+
3744
+ /**
3745
+ * Checks if this has minor currency units.
3746
+ * Deprecates {@link module:Dinero~hasCents hasCents}.
3747
+ *
3748
+ * @example
3749
+ * // returns false
3750
+ * Dinero({ amount: 1100 }).hasSubUnits()
3751
+ * @example
3752
+ * // returns true
3753
+ * Dinero({ amount: 1150 }).hasSubUnits()
3754
+ *
3755
+ * @return {Boolean}
3756
+ */
3757
+ hasSubUnits: function hasSubUnits() {
3758
+ return calculator$1.modulo(this.getAmount(), Math.pow(10, precision)) !== 0;
3759
+ },
3760
+
3761
+ /**
3762
+ * Checks if this has minor currency units.
3763
+ *
3764
+ * @deprecated since version 1.4.0, will be removed in 2.0.0
3765
+ * Use {@link module:Dinero~hasSubUnits hasSubUnits} instead.
3766
+ *
3767
+ * @example
3768
+ * // returns false
3769
+ * Dinero({ amount: 1100 }).hasCents()
3770
+ * @example
3771
+ * // returns true
3772
+ * Dinero({ amount: 1150 }).hasCents()
3773
+ *
3774
+ * @return {Boolean}
3775
+ */
3776
+ hasCents: function hasCents() {
3777
+ return calculator$1.modulo(this.getAmount(), Math.pow(10, precision)) !== 0;
3778
+ },
3779
+
3780
+ /**
3781
+ * Checks whether the currency represented by this object equals to the other.
3782
+ *
3783
+ * @param {Dinero} comparator - The Dinero object to compare to.
3784
+ *
3785
+ * @example
3786
+ * // returns true
3787
+ * Dinero({ amount: 2000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'EUR' }))
3788
+ * @example
3789
+ * // returns false
3790
+ * Dinero({ amount: 1000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'USD' }))
3791
+ *
3792
+ * @return {Boolean}
3793
+ */
3794
+ hasSameCurrency: function hasSameCurrency(comparator) {
3795
+ return this.getCurrency() === comparator.getCurrency();
3796
+ },
3797
+
3798
+ /**
3799
+ * Checks whether the amount represented by this object equals to the other.
3800
+ *
3801
+ * @param {Dinero} comparator - The Dinero object to compare to.
3802
+ *
3803
+ * @example
3804
+ * // returns true
3805
+ * Dinero({ amount: 1000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000 }))
3806
+ * @example
3807
+ * // returns false
3808
+ * Dinero({ amount: 2000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000, currency: 'EUR' }))
3809
+ * @example
3810
+ * // returns true
3811
+ * Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
3812
+ * @example
3813
+ * // returns false
3814
+ * Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
3815
+ *
3816
+ * @return {Boolean}
3817
+ */
3818
+ hasSameAmount: function hasSameAmount(comparator) {
3819
+ var comparators = Dinero.normalizePrecision([this, comparator]);
3820
+ return comparators[0].getAmount() === comparators[1].getAmount();
3821
+ },
3822
+
3823
+ /**
3824
+ * Returns this object formatted as a string.
3825
+ *
3826
+ * The format is a mask which defines how the output string will be formatted.
3827
+ * It defines whether to display a currency, in what format, how many fraction digits to display and whether to use grouping separators.
3828
+ * The output is formatted according to the applying locale.
3829
+ *
3830
+ * Object | Format | String
3831
+ * :--------------------------- | :---------------- | :---
3832
+ * `Dinero({ amount: 500050 })` | `'$0,0.00'` | $5,000.50
3833
+ * `Dinero({ amount: 500050 })` | `'$0,0'` | $5,001
3834
+ * `Dinero({ amount: 500050 })` | `'$0'` | $5001
3835
+ * `Dinero({ amount: 500050 })` | `'$0.0'` | $5000.5
3836
+ * `Dinero({ amount: 500050 })` | `'USD0,0.0'` | USD5,000.5
3837
+ * `Dinero({ amount: 500050 })` | `'0,0.0 dollar'` | 5,000.5 dollars
3838
+ *
3839
+ * Don't try to substitute the `$` sign or the `USD` code with your target currency, nor adapt the format string to the exact format you want.
3840
+ * The format is a mask which defines a pattern and returns a valid, localized currency string.
3841
+ * If you want to display the object in a custom way, either use {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~toUnit toUnit} or {@link module:Dinero~toRoundedUnit toRoundedUnit} and manipulate the output string as you wish.
3842
+ *
3843
+ * {@link module:Dinero~toFormat toFormat} wraps around `Number.prototype.toLocaleString`. For that reason, **format will vary depending on how it's implemented in the end user's environment**.
3844
+ *
3845
+ * You can also use `toLocaleString` directly:
3846
+ * `Dinero().toRoundedUnit(digits, roundingMode).toLocaleString(locale, options)`.
3847
+ *
3848
+ * By default, amounts are rounded using the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
3849
+ * You can also specify a different `roundingMode` to better fit your needs.
3850
+ *
3851
+ * @param {String} [format='$0,0.00'] - The format mask to format to.
3852
+ * @param {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3853
+ *
3854
+ * @example
3855
+ * // returns $2,000
3856
+ * Dinero({ amount: 200000 }).toFormat('$0,0')
3857
+ * @example
3858
+ * // returns €50.5
3859
+ * Dinero({ amount: 5050, currency: 'EUR' }).toFormat('$0,0.0')
3860
+ * @example
3861
+ * // returns 100 euros
3862
+ * Dinero({ amount: 10000, currency: 'EUR' }).setLocale('fr-FR').toFormat('0,0 dollar')
3863
+ * @example
3864
+ * // returns 2000
3865
+ * Dinero({ amount: 200000, currency: 'EUR' }).toFormat()
3866
+ * @example
3867
+ * // returns $10
3868
+ * Dinero({ amount: 1050 }).toFormat('$0', 'HALF_EVEN')
3869
+ *
3870
+ * @return {String}
3871
+ */
3872
+ toFormat: function toFormat() {
3873
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalFormat;
3874
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3875
+ var formatter = Format(format);
3876
+ return this.toRoundedUnit(formatter.getMinimumFractionDigits(), roundingMode).toLocaleString(this.getLocale(), {
3877
+ currencyDisplay: formatter.getCurrencyDisplay(),
3878
+ useGrouping: formatter.getUseGrouping(),
3879
+ minimumFractionDigits: formatter.getMinimumFractionDigits(),
3880
+ style: formatter.getStyle(),
3881
+ currency: this.getCurrency()
3882
+ });
3883
+ },
3884
+
3885
+ /**
3886
+ * Returns the amount represented by this object in units.
3887
+ *
3888
+ * @example
3889
+ * // returns 10.5
3890
+ * Dinero({ amount: 1050 }).toUnit()
3891
+ * @example
3892
+ * // returns 10.545
3893
+ * Dinero({ amount: 10545, precision: 3 }).toUnit()
3894
+ *
3895
+ * @return {Number}
3896
+ */
3897
+ toUnit: function toUnit() {
3898
+ return calculator$1.divide(this.getAmount(), Math.pow(10, precision));
3899
+ },
3900
+
3901
+ /**
3902
+ * Returns the amount represented by this object in rounded units.
3903
+ *
3904
+ * By default, the method uses the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
3905
+ * You can also specify a different `roundingMode` to better fit your needs.
3906
+ *
3907
+ * @example
3908
+ * // returns 10.6
3909
+ * Dinero({ amount: 1055 }).toRoundedUnit(1)
3910
+ * @example
3911
+ * // returns 10
3912
+ * Dinero({ amount: 1050 }).toRoundedUnit(0, 'HALF_EVEN')
3913
+ *
3914
+ * @param {Number} digits - The number of fraction digits to round to.
3915
+ * @param {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3916
+ *
3917
+ * @return {Number}
3918
+ */
3919
+ toRoundedUnit: function toRoundedUnit(digits) {
3920
+ var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3921
+ var factor = Math.pow(10, digits);
3922
+ return calculator$1.divide(calculator$1.round(calculator$1.multiply(this.toUnit(), factor), roundingMode), factor);
3923
+ },
3924
+
3925
+ /**
3926
+ * Returns the object's data as an object literal.
3927
+ *
3928
+ * @example
3929
+ * // returns { amount: 500, currency: 'EUR', precision: 2 }
3930
+ * Dinero({ amount: 500, currency: 'EUR', precision: 2 }).toObject()
3931
+ *
3932
+ * @return {Object}
3933
+ */
3934
+ toObject: function toObject() {
3935
+ return {
3936
+ amount: amount,
3937
+ currency: currency,
3938
+ precision: precision
3939
+ };
3940
+ },
3941
+
3942
+ /**
3943
+ * Returns the object's data as an object literal.
3944
+ *
3945
+ * Alias of {@link module:Dinero~toObject toObject}.
3946
+ * It is defined so that calling `JSON.stringify` on a Dinero object will automatically extract the relevant data.
3947
+ *
3948
+ * @example
3949
+ * // returns '{"amount":500,"currency":"EUR","precision":2}'
3950
+ * JSON.stringify(Dinero({ amount: 500, currency: 'EUR', precision: 2 }))
3951
+ *
3952
+ * @return {Object}
3953
+ */
3954
+ toJSON: function toJSON() {
3955
+ return this.toObject();
3956
+ }
3957
+ };
3958
+ };
3959
+
3960
+ var Dinero$1 = Object.assign(Dinero, Defaults, Globals, Static);
3961
+
3962
+ return Dinero$1;
3963
+
3964
+ });