@blackglory/structures 0.2.6 → 0.2.7

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.
@@ -4,15 +4,6 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Structures = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- function convertConsToArray([value, next]) {
8
- if (next === null)
9
- return [value];
10
- return [value, ...convertConsToArray(next)];
11
- }
12
- function convertArrayToCons([value, ...next]) {
13
- return [value, next.length ? convertArrayToCons(next) : null];
14
- }
15
-
16
7
  /*! *****************************************************************************
17
8
  Copyright (c) Microsoft Corporation.
18
9
 
@@ -41,6 +32,30 @@
41
32
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
42
33
  }
43
34
 
35
+ var _Box_value;
36
+ class Box {
37
+ constructor(value) {
38
+ _Box_value.set(this, void 0);
39
+ __classPrivateFieldSet(this, _Box_value, value, "f");
40
+ }
41
+ set(value) {
42
+ __classPrivateFieldSet(this, _Box_value, value, "f");
43
+ }
44
+ get() {
45
+ return __classPrivateFieldGet(this, _Box_value, "f");
46
+ }
47
+ }
48
+ _Box_value = new WeakMap();
49
+
50
+ function convertConsToArray([value, next]) {
51
+ if (next === null)
52
+ return [value];
53
+ return [value, ...convertConsToArray(next)];
54
+ }
55
+ function convertArrayToCons([value, ...next]) {
56
+ return [value, next.length ? convertArrayToCons(next) : null];
57
+ }
58
+
44
59
  var _Emitter_map;
45
60
  class Emitter {
46
61
  constructor() {
@@ -169,7 +184,7 @@
169
184
 
170
185
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
171
186
 
172
- var es2018$4 = {};
187
+ var es2018$5 = {};
173
188
 
174
189
  var customError = {};
175
190
 
@@ -247,15 +262,15 @@
247
262
  __exportStar(refute$1, exports);
248
263
  __exportStar(assert$1, exports);
249
264
 
250
- }(es2018$4));
265
+ }(es2018$5));
251
266
 
252
- var es2018$3 = {};
267
+ var es2018$4 = {};
253
268
 
254
269
  var middleware = {};
255
270
 
256
271
  var chunkAsync$1 = {};
257
272
 
258
- var es2018$2 = {};
273
+ var es2018$3 = {};
259
274
 
260
275
  var go$1 = {};
261
276
 
@@ -277,11 +292,11 @@
277
292
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
278
293
  };__exportStar(go$1, exports);
279
294
 
280
- }(es2018$2));
295
+ }(es2018$3));
281
296
 
282
297
  chunkAsync$1.chunkAsync = void 0;
283
- const go_1$f = es2018$2;
284
- const errors_1$f = es2018$4;
298
+ const go_1$f = es2018$3;
299
+ const errors_1$f = es2018$5;
285
300
  function chunkAsync(iterable, size) {
286
301
  (0, errors_1$f.assert)(Number.isInteger(size), 'The parameter size must be an integer');
287
302
  (0, errors_1$f.assert)(size > 0, 'The parameter size must be greater than 0');
@@ -302,7 +317,7 @@
302
317
 
303
318
  var chunkByAsync$1 = {};
304
319
 
305
- var es2018$1 = {};
320
+ var es2018$2 = {};
306
321
 
307
322
  var array = {};
308
323
 
@@ -651,10 +666,10 @@
651
666
  __exportStar(_undefined, exports);
652
667
  __exportStar(url, exports);
653
668
 
654
- }(es2018$1));
669
+ }(es2018$2));
655
670
 
656
671
  chunkByAsync$1.chunkByAsync = void 0;
657
- const types_1$h = es2018$1;
672
+ const types_1$h = es2018$2;
658
673
  function chunkByAsync(iterable, predicate) {
659
674
  if ((0, types_1$h.isAsyncIterable)(iterable)) {
660
675
  return chunkByAsyncIterable(iterable);
@@ -715,8 +730,8 @@
715
730
  var chunk$1 = {};
716
731
 
717
732
  chunk$1.chunk = void 0;
718
- const go_1$e = es2018$2;
719
- const errors_1$e = es2018$4;
733
+ const go_1$e = es2018$3;
734
+ const errors_1$e = es2018$5;
720
735
  function chunk(iterable, size) {
721
736
  (0, errors_1$e.assert)(Number.isInteger(size), 'The parameter size must be an integer');
722
737
  (0, errors_1$e.assert)(size > 0, 'The parameter size must be greater than 0');
@@ -738,8 +753,8 @@
738
753
  var concatAsync$1 = {};
739
754
 
740
755
  concatAsync$1.concatAsync = void 0;
741
- const types_1$g = es2018$1;
742
- const go_1$d = es2018$2;
756
+ const types_1$g = es2018$2;
757
+ const go_1$d = es2018$3;
743
758
  function concatAsync(iterable, ...otherIterables) {
744
759
  return (0, go_1$d.go)(async function* () {
745
760
  for (const iter of [iterable, ...otherIterables]) {
@@ -761,7 +776,7 @@
761
776
  var concat$1 = {};
762
777
 
763
778
  concat$1.concat = void 0;
764
- const go_1$c = es2018$2;
779
+ const go_1$c = es2018$3;
765
780
  function concat(iterable, ...otherIterables) {
766
781
  return (0, go_1$c.go)(function* () {
767
782
  for (const iter of [iterable, ...otherIterables]) {
@@ -790,9 +805,9 @@
790
805
  utils.copyIterable = copyIterable;
791
806
 
792
807
  dropAsync$1.dropAsync = void 0;
793
- const go_1$b = es2018$2;
808
+ const go_1$b = es2018$3;
794
809
  const utils_1$3 = utils;
795
- const errors_1$d = es2018$4;
810
+ const errors_1$d = es2018$5;
796
811
  function dropAsync(iterable, count) {
797
812
  (0, errors_1$d.assert)(Number.isInteger(count), 'The parameter count must be an integer');
798
813
  (0, errors_1$d.assert)(count >= 0, 'The parameter count must be greater than or equal to 0');
@@ -825,9 +840,9 @@
825
840
  var dropRightAsync$1 = {};
826
841
 
827
842
  dropRightAsync$1.dropRightAsync = void 0;
828
- const go_1$a = es2018$2;
843
+ const go_1$a = es2018$3;
829
844
  const utils_1$2 = utils;
830
- const errors_1$c = es2018$4;
845
+ const errors_1$c = es2018$5;
831
846
  function dropRightAsync(iterable, count) {
832
847
  (0, errors_1$c.assert)(Number.isInteger(count), 'The parameter count must be an integer');
833
848
  (0, errors_1$c.assert)(count >= 0, 'The parameter count must be greater than or equal to 0');
@@ -853,9 +868,9 @@
853
868
  var dropRight$1 = {};
854
869
 
855
870
  dropRight$1.dropRight = void 0;
856
- const go_1$9 = es2018$2;
871
+ const go_1$9 = es2018$3;
857
872
  const utils_1$1 = utils;
858
- const errors_1$b = es2018$4;
873
+ const errors_1$b = es2018$5;
859
874
  function dropRight(iterable, count) {
860
875
  (0, errors_1$b.assert)(Number.isInteger(count), 'The parameter count must be an integer');
861
876
  (0, errors_1$b.assert)(count >= 0, 'The parameter count must be greater than or equal to 0');
@@ -871,7 +886,7 @@
871
886
  var dropUntilAsync$1 = {};
872
887
 
873
888
  dropUntilAsync$1.dropUntilAsync = void 0;
874
- const types_1$f = es2018$1;
889
+ const types_1$f = es2018$2;
875
890
  function dropUntilAsync(iterable, predicate) {
876
891
  if ((0, types_1$f.isAsyncIterable)(iterable)) {
877
892
  return dropUntilAsyncIterable(iterable);
@@ -953,9 +968,9 @@
953
968
  var drop$1 = {};
954
969
 
955
970
  drop$1.drop = void 0;
956
- const go_1$8 = es2018$2;
971
+ const go_1$8 = es2018$3;
957
972
  const utils_1 = utils;
958
- const errors_1$a = es2018$4;
973
+ const errors_1$a = es2018$5;
959
974
  function drop(iterable, count) {
960
975
  (0, errors_1$a.assert)(Number.isInteger(count), 'The parameter count must be an integer');
961
976
  (0, errors_1$a.assert)(count >= 0, 'The parameter count must be greater than or equal to 0');
@@ -988,7 +1003,7 @@
988
1003
  var filterAsync$1 = {};
989
1004
 
990
1005
  filterAsync$1.filterAsync = void 0;
991
- const types_1$e = es2018$1;
1006
+ const types_1$e = es2018$2;
992
1007
  function filterAsync(iterable, predicate) {
993
1008
  if ((0, types_1$e.isAsyncIterable)(iterable)) {
994
1009
  return filterAsyncIterable(iterable);
@@ -1035,7 +1050,7 @@
1035
1050
  var flattenByAsync$1 = {};
1036
1051
 
1037
1052
  flattenByAsync$1.flattenByAsync = void 0;
1038
- const types_1$d = es2018$1;
1053
+ const types_1$d = es2018$2;
1039
1054
  function flattenByAsync(iterable, predicate) {
1040
1055
  if ((0, types_1$d.isAsyncIterable)(iterable)) {
1041
1056
  return flattenByAsyncIterable(iterable);
@@ -1075,7 +1090,7 @@
1075
1090
 
1076
1091
  flattenDeepAsync$1.flattenDeepAsync = void 0;
1077
1092
  const flatten_by_async_1 = flattenByAsync$1;
1078
- const errors_1$9 = es2018$4;
1093
+ const errors_1$9 = es2018$5;
1079
1094
  function flattenDeepAsync(iterable, depth = Infinity) {
1080
1095
  (0, errors_1$9.assert)(depth === Infinity || Number.isInteger(depth), 'The parameter depth must be an integer');
1081
1096
  (0, errors_1$9.assert)(depth >= 0, 'The parameter depth must be greater than or equal to 0');
@@ -1093,7 +1108,7 @@
1093
1108
  var flattenBy$1 = {};
1094
1109
 
1095
1110
  flattenBy$1.flattenBy = void 0;
1096
- const types_1$c = es2018$1;
1111
+ const types_1$c = es2018$2;
1097
1112
  function flattenBy(iterable, predicate) {
1098
1113
  return flatten(iterable, 1);
1099
1114
  function* flatten(iterable, level) {
@@ -1116,7 +1131,7 @@
1116
1131
 
1117
1132
  flattenDeep$1.flattenDeep = void 0;
1118
1133
  const flatten_by_1 = flattenBy$1;
1119
- const errors_1$8 = es2018$4;
1134
+ const errors_1$8 = es2018$5;
1120
1135
  function flattenDeep(iterable, depth = Infinity) {
1121
1136
  (0, errors_1$8.assert)(depth === Infinity || Number.isInteger(depth), 'The parameter depth must be an integer');
1122
1137
  (0, errors_1$8.assert)(depth >= 0, 'The parameter depth must be greater than or equal to 0');
@@ -1136,7 +1151,7 @@
1136
1151
  var mapAsync$1 = {};
1137
1152
 
1138
1153
  mapAsync$1.mapAsync = void 0;
1139
- const types_1$b = es2018$1;
1154
+ const types_1$b = es2018$2;
1140
1155
  function mapAsync(iterable, fn) {
1141
1156
  if ((0, types_1$b.isAsyncIterable)(iterable)) {
1142
1157
  return mapAsyncIterable(iterable);
@@ -1176,8 +1191,8 @@
1176
1191
  var repeatAsync$1 = {};
1177
1192
 
1178
1193
  repeatAsync$1.repeatAsync = void 0;
1179
- const go_1$7 = es2018$2;
1180
- const errors_1$7 = es2018$4;
1194
+ const go_1$7 = es2018$3;
1195
+ const errors_1$7 = es2018$5;
1181
1196
  function repeatAsync(iterable, times) {
1182
1197
  (0, errors_1$7.assert)(times === Infinity || Number.isInteger(times), 'The parameter times must be an integer');
1183
1198
  (0, errors_1$7.assert)(times >= 0, 'The parameter times must be greater than or equal to 0');
@@ -1211,8 +1226,8 @@
1211
1226
  var repeat$1 = {};
1212
1227
 
1213
1228
  repeat$1.repeat = void 0;
1214
- const go_1$6 = es2018$2;
1215
- const errors_1$6 = es2018$4;
1229
+ const go_1$6 = es2018$3;
1230
+ const errors_1$6 = es2018$5;
1216
1231
  function repeat(iterable, times) {
1217
1232
  (0, errors_1$6.assert)(times === Infinity || Number.isInteger(times), 'The parameter times must be an integer');
1218
1233
  (0, errors_1$6.assert)(times >= 0, 'The parameter times must be greater than or equal to 0');
@@ -1246,8 +1261,8 @@
1246
1261
  var sliceAsync$1 = {};
1247
1262
 
1248
1263
  sliceAsync$1.sliceAsync = void 0;
1249
- const go_1$5 = es2018$2;
1250
- const errors_1$5 = es2018$4;
1264
+ const go_1$5 = es2018$3;
1265
+ const errors_1$5 = es2018$5;
1251
1266
  function sliceAsync(iterable, start, end = Infinity) {
1252
1267
  (0, errors_1$5.assert)(Number.isInteger(start), 'The parameter start must be an integer');
1253
1268
  (0, errors_1$5.assert)(start >= 0, 'The parameter start must be greater than or equal to 0');
@@ -1269,8 +1284,8 @@
1269
1284
  var slice$1 = {};
1270
1285
 
1271
1286
  slice$1.slice = void 0;
1272
- const go_1$4 = es2018$2;
1273
- const errors_1$4 = es2018$4;
1287
+ const go_1$4 = es2018$3;
1288
+ const errors_1$4 = es2018$5;
1274
1289
  function slice(iterable, start, end = Infinity) {
1275
1290
  (0, errors_1$4.assert)(Number.isInteger(start), 'The parameter start must be an integer');
1276
1291
  (0, errors_1$4.assert)(start >= 0, 'The parameter start must be greater than or equal to 0');
@@ -1310,7 +1325,7 @@
1310
1325
  var splitByAsync$1 = {};
1311
1326
 
1312
1327
  splitByAsync$1.splitByAsync = void 0;
1313
- const types_1$a = es2018$1;
1328
+ const types_1$a = es2018$2;
1314
1329
  function splitByAsync(iterable, predicate) {
1315
1330
  if ((0, types_1$a.isAsyncIterable)(iterable)) {
1316
1331
  return splitByAsyncIterable(iterable);
@@ -1392,8 +1407,8 @@
1392
1407
  var takeAsync$1 = {};
1393
1408
 
1394
1409
  takeAsync$1.takeAsync = void 0;
1395
- const go_1$3 = es2018$2;
1396
- const errors_1$3 = es2018$4;
1410
+ const go_1$3 = es2018$3;
1411
+ const errors_1$3 = es2018$5;
1397
1412
  function takeAsync(iterable, count) {
1398
1413
  (0, errors_1$3.assert)(Number.isInteger(count), 'The parameter count must be an integer');
1399
1414
  (0, errors_1$3.assert)(count >= 0, 'The parameter count must be greater than or equal to 0');
@@ -1413,8 +1428,8 @@
1413
1428
  var takeRightAsync$1 = {};
1414
1429
 
1415
1430
  takeRightAsync$1.takeRightAsync = void 0;
1416
- const go_1$2 = es2018$2;
1417
- const errors_1$2 = es2018$4;
1431
+ const go_1$2 = es2018$3;
1432
+ const errors_1$2 = es2018$5;
1418
1433
  function takeRightAsync(iterable, count) {
1419
1434
  (0, errors_1$2.assert)(Number.isInteger(count), 'The parameter count must be an integer');
1420
1435
  (0, errors_1$2.assert)(count >= 0, 'The parameter count must be greater than or equal to 0');
@@ -1443,8 +1458,8 @@
1443
1458
  var takeRight$1 = {};
1444
1459
 
1445
1460
  takeRight$1.takeRight = void 0;
1446
- const go_1$1 = es2018$2;
1447
- const errors_1$1 = es2018$4;
1461
+ const go_1$1 = es2018$3;
1462
+ const errors_1$1 = es2018$5;
1448
1463
  function takeRight(iterable, count) {
1449
1464
  (0, errors_1$1.assert)(Number.isInteger(count), 'The parameter count must be an integer');
1450
1465
  (0, errors_1$1.assert)(count >= 0, 'The parameter count must be greater than or equal to 0');
@@ -1473,7 +1488,7 @@
1473
1488
  var takeUntilAsync$1 = {};
1474
1489
 
1475
1490
  takeUntilAsync$1.takeUntilAsync = void 0;
1476
- const types_1$9 = es2018$1;
1491
+ const types_1$9 = es2018$2;
1477
1492
  function takeUntilAsync(iterable, predicate) {
1478
1493
  if ((0, types_1$9.isAsyncIterable)(iterable)) {
1479
1494
  return takeUntilAsyncIterable(iterable);
@@ -1519,8 +1534,8 @@
1519
1534
  var take$1 = {};
1520
1535
 
1521
1536
  take$1.take = void 0;
1522
- const go_1 = es2018$2;
1523
- const errors_1 = es2018$4;
1537
+ const go_1 = es2018$3;
1538
+ const errors_1 = es2018$5;
1524
1539
  function take(iterable, count) {
1525
1540
  (0, errors_1.assert)(Number.isInteger(count), 'The parameter count must be an integer');
1526
1541
  (0, errors_1.assert)(count >= 0, 'The parameter count must be greater than or equal to 0');
@@ -1540,7 +1555,7 @@
1540
1555
  var tapAsync$1 = {};
1541
1556
 
1542
1557
  tapAsync$1.tapAsync = void 0;
1543
- const types_1$8 = es2018$1;
1558
+ const types_1$8 = es2018$2;
1544
1559
  function tapAsync(iterable, fn) {
1545
1560
  if ((0, types_1$8.isAsyncIterable)(iterable)) {
1546
1561
  return tapAsyncIterable(iterable);
@@ -1623,7 +1638,7 @@
1623
1638
  var uniqByAsync$1 = {};
1624
1639
 
1625
1640
  uniqByAsync$1.uniqByAsync = void 0;
1626
- const types_1$7 = es2018$1;
1641
+ const types_1$7 = es2018$2;
1627
1642
  function uniqByAsync(iterable, fn) {
1628
1643
  if ((0, types_1$7.isAsyncIterable)(iterable)) {
1629
1644
  return uniqByAsyncIterable(iterable);
@@ -1692,7 +1707,7 @@
1692
1707
  var zipAsync$1 = {};
1693
1708
 
1694
1709
  zipAsync$1.zipAsync = void 0;
1695
- const types_1$6 = es2018$1;
1710
+ const types_1$6 = es2018$2;
1696
1711
  var Kind;
1697
1712
  (function (Kind) {
1698
1713
  Kind[Kind["Sync"] = 0] = "Sync";
@@ -1852,7 +1867,7 @@
1852
1867
  var eachAsync$1 = {};
1853
1868
 
1854
1869
  eachAsync$1.eachAsync = void 0;
1855
- const types_1$5 = es2018$1;
1870
+ const types_1$5 = es2018$2;
1856
1871
  function eachAsync(iterable, fn) {
1857
1872
  if ((0, types_1$5.isAsyncIterable)(iterable)) {
1858
1873
  return eachAsyncIterable(iterable);
@@ -1892,7 +1907,7 @@
1892
1907
  var everyAsync$1 = {};
1893
1908
 
1894
1909
  everyAsync$1.everyAsync = void 0;
1895
- const types_1$4 = es2018$1;
1910
+ const types_1$4 = es2018$2;
1896
1911
  function everyAsync(iterable, predicate) {
1897
1912
  if ((0, types_1$4.isAsyncIterable)(iterable)) {
1898
1913
  return everyAsyncIterable(iterable);
@@ -1938,7 +1953,7 @@
1938
1953
  var findAsync$1 = {};
1939
1954
 
1940
1955
  findAsync$1.findAsync = void 0;
1941
- const types_1$3 = es2018$1;
1956
+ const types_1$3 = es2018$2;
1942
1957
  function findAsync(iterable, predicate) {
1943
1958
  if ((0, types_1$3.isAsyncIterable)(iterable)) {
1944
1959
  return findAsyncIterable(iterable);
@@ -2062,7 +2077,7 @@
2062
2077
  var reduceAsync$1 = {};
2063
2078
 
2064
2079
  reduceAsync$1.reduceAsync = void 0;
2065
- const types_1$2 = es2018$1;
2080
+ const types_1$2 = es2018$2;
2066
2081
  function reduceAsync(iterable, fn, initialValue) {
2067
2082
  if ((0, types_1$2.isUndefined)(initialValue)) {
2068
2083
  return reduceAsyncWithoutInitialValue(iterable, fn);
@@ -2158,7 +2173,7 @@
2158
2173
  var reduce$1 = {};
2159
2174
 
2160
2175
  reduce$1.reduce = void 0;
2161
- const types_1$1 = es2018$1;
2176
+ const types_1$1 = es2018$2;
2162
2177
  function reduce(iterable, fn, initialValue) {
2163
2178
  if ((0, types_1$1.isUndefined)(initialValue)) {
2164
2179
  return reduceWithoutInitialValue(iterable, fn);
@@ -2205,7 +2220,7 @@
2205
2220
  var someAsync$1 = {};
2206
2221
 
2207
2222
  someAsync$1.someAsync = void 0;
2208
- const types_1 = es2018$1;
2223
+ const types_1 = es2018$2;
2209
2224
  function someAsync(iterable, predicate) {
2210
2225
  if ((0, types_1.isAsyncIterable)(iterable)) {
2211
2226
  return someAsyncIterable(iterable);
@@ -2389,15 +2404,15 @@
2389
2404
  };__exportStar(middleware, exports);
2390
2405
  __exportStar(output, exports);
2391
2406
 
2392
- }(es2018$3));
2407
+ }(es2018$4));
2393
2408
 
2394
2409
  var _LRUMap_limit, _LRUMap_map;
2395
2410
  class LRUMap {
2396
2411
  constructor(limit) {
2397
2412
  _LRUMap_limit.set(this, void 0);
2398
2413
  _LRUMap_map.set(this, new Map());
2399
- es2018$4.assert(Number.isInteger(limit), 'The parameter limit must be an integer');
2400
- es2018$4.assert(limit > 0, 'The parameter limit must be a positive value');
2414
+ es2018$5.assert(Number.isInteger(limit), 'The parameter limit must be an integer');
2415
+ es2018$5.assert(limit > 0, 'The parameter limit must be a positive value');
2401
2416
  __classPrivateFieldSet(this, _LRUMap_limit, limit, "f");
2402
2417
  }
2403
2418
  get [(_LRUMap_limit = new WeakMap(), _LRUMap_map = new WeakMap(), Symbol.toStringTag)]() {
@@ -2445,12 +2460,73 @@
2445
2460
  * Return the earliest key inserted in the Map
2446
2461
  */
2447
2462
  getColdestKey() {
2448
- return es2018$3.first(__classPrivateFieldGet(this, _LRUMap_map, "f").keys());
2463
+ return es2018$4.first(__classPrivateFieldGet(this, _LRUMap_map, "f").keys());
2449
2464
  }
2450
2465
  }
2451
2466
 
2467
+ var es2018$1 = {};
2468
+
2469
+ var exponentialBackoff = {};
2470
+
2452
2471
  var es2018 = {};
2453
2472
 
2473
+ var random$1 = {};
2474
+
2475
+ random$1.random = void 0;
2476
+ function random(min, max) {
2477
+ return Math.random() * (max - min) + min;
2478
+ }
2479
+ random$1.random = random;
2480
+
2481
+ var randomInt$1 = {};
2482
+
2483
+ randomInt$1.randomInt = void 0;
2484
+ function randomInt(min, max) {
2485
+ min = Math.ceil(min);
2486
+ max = Math.floor(max);
2487
+ return Math.floor(Math.random() * (max - min)) + min;
2488
+ }
2489
+ randomInt$1.randomInt = randomInt;
2490
+
2491
+ var randomIntInclusive$1 = {};
2492
+
2493
+ randomIntInclusive$1.randomIntInclusive = void 0;
2494
+ function randomIntInclusive(min, max) {
2495
+ min = Math.ceil(min);
2496
+ max = Math.floor(max);
2497
+ return Math.floor(Math.random() * (max - min + 1)) + min;
2498
+ }
2499
+ randomIntInclusive$1.randomIntInclusive = randomIntInclusive;
2500
+
2501
+ (function (exports) {
2502
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2503
+ if (k2 === undefined) k2 = k;
2504
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2505
+ }) : (function(o, m, k, k2) {
2506
+ if (k2 === undefined) k2 = k;
2507
+ o[k2] = m[k];
2508
+ }));
2509
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
2510
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2511
+ };__exportStar(random$1, exports);
2512
+ __exportStar(randomInt$1, exports);
2513
+ __exportStar(randomIntInclusive$1, exports);
2514
+
2515
+ }(es2018));
2516
+
2517
+ exponentialBackoff.calculateExponentialBackoffTimeout = void 0;
2518
+ const extra_rand_1 = es2018;
2519
+ function calculateExponentialBackoffTimeout({ baseTimeout, retries, maxTimeout = Infinity, factor = 2, jitter = true }) {
2520
+ const timeout = Math.min(factor ** retries * baseTimeout, maxTimeout);
2521
+ if (jitter) {
2522
+ return (0, extra_rand_1.randomIntInclusive)(0, timeout);
2523
+ }
2524
+ else {
2525
+ return timeout;
2526
+ }
2527
+ }
2528
+ exponentialBackoff.calculateExponentialBackoffTimeout = calculateExponentialBackoffTimeout;
2529
+
2454
2530
  var setTimeout$1 = {};
2455
2531
 
2456
2532
  setTimeout$1.setTimeout = void 0;
@@ -2507,8 +2583,9 @@
2507
2583
  };
2508
2584
  async function loop() {
2509
2585
  await cb();
2510
- if (!isCancelled)
2586
+ if (!isCancelled) {
2511
2587
  cancel = (0, set_timeout_1$1.setTimeout)(timeout, loop);
2588
+ }
2512
2589
  }
2513
2590
  }
2514
2591
  setTimeoutLoop$1.setTimeoutLoop = setTimeoutLoop;
@@ -2528,8 +2605,9 @@
2528
2605
  const start = Date.now();
2529
2606
  await cb();
2530
2607
  const elapsed = Date.now() - start;
2531
- if (!isCancelled)
2608
+ if (!isCancelled) {
2532
2609
  cancel = (0, set_timeout_1.setTimeout)(Math.max(timeout - elapsed, 0), loop);
2610
+ }
2533
2611
  }
2534
2612
  }
2535
2613
  setDynamicTimeoutLoop$1.setDynamicTimeoutLoop = setDynamicTimeoutLoop;
@@ -2544,14 +2622,15 @@
2544
2622
  }));
2545
2623
  var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
2546
2624
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2547
- };__exportStar(setTimeout$1, exports);
2625
+ };__exportStar(exponentialBackoff, exports);
2626
+ __exportStar(setTimeout$1, exports);
2548
2627
  __exportStar(setSchedule$1, exports);
2549
2628
  __exportStar(setInterval$1, exports);
2550
2629
  __exportStar(setImmediate$1, exports);
2551
2630
  __exportStar(setTimeoutLoop$1, exports);
2552
2631
  __exportStar(setDynamicTimeoutLoop$1, exports);
2553
2632
 
2554
- }(es2018));
2633
+ }(es2018$1));
2555
2634
 
2556
2635
  var _ExpirableMap_map, _ExpirableMap_cancelClearTimeout;
2557
2636
  class ExpirableMap {
@@ -2641,7 +2720,7 @@
2641
2720
  if (this.itemMetadataSortedByExpirationTime.length > 0) {
2642
2721
  const item = this.itemMetadataSortedByExpirationTime[0];
2643
2722
  if (Number.isFinite(item.expirationTime)) {
2644
- const cancel = es2018.setSchedule(item.expirationTime, () => {
2723
+ const cancel = es2018$1.setSchedule(item.expirationTime, () => {
2645
2724
  this.clearExpiredItems(Date.now());
2646
2725
  this.rescheduleClearTimeout();
2647
2726
  });
@@ -2667,8 +2746,8 @@
2667
2746
  * 按过期时间升序排列所有项目的元数据
2668
2747
  */
2669
2748
  this.itemMetadataSortedByExpirationTime = [];
2670
- es2018$4.assert(Number.isInteger(limit), 'The parameter limit must be an integer');
2671
- es2018$4.assert(limit > 0, 'The parameter limit must be a positive value');
2749
+ es2018$5.assert(Number.isInteger(limit), 'The parameter limit must be an integer');
2750
+ es2018$5.assert(limit > 0, 'The parameter limit must be a positive value');
2672
2751
  __classPrivateFieldSet(this, _TLRUMap_limit, limit, "f");
2673
2752
  }
2674
2753
  get [(_TLRUMap_limit = new WeakMap(), _TLRUMap_map = new WeakMap(), _TLRUMap_cancelClearTimeout = new WeakMap(), Symbol.toStringTag)]() {
@@ -2772,7 +2851,7 @@
2772
2851
  if (this.itemMetadataSortedByExpirationTime.length > 0) {
2773
2852
  const item = this.itemMetadataSortedByExpirationTime[0];
2774
2853
  if (Number.isFinite(item.expirationTime)) {
2775
- const cancel = es2018.setSchedule(item.expirationTime, () => {
2854
+ const cancel = es2018$1.setSchedule(item.expirationTime, () => {
2776
2855
  this.clearExpiredItems(Date.now());
2777
2856
  this.rescheduleClearTimeout();
2778
2857
  });
@@ -2787,7 +2866,7 @@
2787
2866
  * Return the earliest key inserted in the Map
2788
2867
  */
2789
2868
  getColdestKey() {
2790
- return es2018$3.first(__classPrivateFieldGet(this, _TLRUMap_map, "f").keys());
2869
+ return es2018$4.first(__classPrivateFieldGet(this, _TLRUMap_map, "f").keys());
2791
2870
  }
2792
2871
  }
2793
2872
 
@@ -2855,7 +2934,7 @@
2855
2934
  delete node.value;
2856
2935
  // 如果节点没有后缀, 则代表这是末端节点, 往前删除其前缀
2857
2936
  if (node.children.size === 0) {
2858
- for (const [part, parentNode] of es2018$3.toArray(es2018$3.zip(key, parentNodes)).reverse()) {
2937
+ for (const [part, parentNode] of es2018$4.toArray(es2018$4.zip(key, parentNodes)).reverse()) {
2859
2938
  parentNode.children.delete(part);
2860
2939
  if (parentNode.children.size !== 0)
2861
2940
  break;
@@ -2865,6 +2944,7 @@
2865
2944
  }
2866
2945
  }
2867
2946
 
2947
+ exports.Box = Box;
2868
2948
  exports.Emitter = Emitter;
2869
2949
  exports.ExpirableMap = ExpirableMap;
2870
2950
  exports.HashMap = HashMap;