@blackglory/structures 0.11.1 → 0.11.2

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.
@@ -671,146 +671,8 @@ function truncateArrayRight(arr, num) {
671
671
  arr.splice(0, startIndex);
672
672
  }
673
673
 
674
- class Emitter {
675
- constructor() {
676
- this.map = new Map();
677
- }
678
- get [Symbol.toStringTag]() {
679
- return this.constructor.name;
680
- }
681
- on(event, listener) {
682
- if (!this.map.has(event)) {
683
- this.map.set(event, new Set());
684
- }
685
- const set = this.map.get(event);
686
- set.add(handler);
687
- return () => {
688
- if (!this.map.has(event))
689
- return;
690
- const handlers = this.map.get(event);
691
- handlers.delete(handler);
692
- if (handlers.size === 0) {
693
- this.map.delete(event);
694
- }
695
- };
696
- function handler(...args) {
697
- listener(...args);
698
- }
699
- }
700
- once(event, listener) {
701
- const removeListener = this.on(event, (...args) => {
702
- listener(...args);
703
- removeListener();
704
- });
705
- return removeListener;
706
- }
707
- emit(event, ...args) {
708
- if (!this.map.has(event))
709
- return;
710
- this.map.get(event).forEach(cb => cb(...args));
711
- }
712
- }
713
-
714
- class HashMap {
715
- constructor(hash) {
716
- this.hash = hash;
717
- this.map = new Map();
718
- }
719
- get [Symbol.toStringTag]() {
720
- return this.constructor.name;
721
- }
722
- get size() {
723
- return this.map.size;
724
- }
725
- set(key, value) {
726
- this.map.set(this.hash(key), value);
727
- return this;
728
- }
729
- has(key) {
730
- return this.map.has(this.hash(key));
731
- }
732
- get(key) {
733
- return this.map.get(this.hash(key));
734
- }
735
- delete(key) {
736
- return this.map.delete(this.hash(key));
737
- }
738
- clear() {
739
- this.map.clear();
740
- }
741
- }
742
-
743
- class HashSet {
744
- constructor(hash) {
745
- this.hash = hash;
746
- this.map = new Map();
747
- }
748
- get [Symbol.toStringTag]() {
749
- return this.constructor.name;
750
- }
751
- get size() {
752
- return this.map.size;
753
- }
754
- [Symbol.iterator]() {
755
- return this.map.values();
756
- }
757
- add(value) {
758
- this.map.set(this.hash(value), value);
759
- return this;
760
- }
761
- delete(value) {
762
- return this.map.delete(this.hash(value));
763
- }
764
- has(value) {
765
- return this.map.has(this.hash(value));
766
- }
767
- clear() {
768
- this.map.clear();
769
- }
770
- values() {
771
- return this.map.values();
772
- }
773
- }
774
-
775
- class Queue {
776
- constructor() {
777
- this.items = [];
778
- }
779
- get [Symbol.toStringTag]() {
780
- return this.constructor.name;
781
- }
782
- get size() {
783
- return this.items.length;
784
- }
785
- empty() {
786
- this.items.length = 0;
787
- }
788
- enqueue(...items) {
789
- this.items.push(...items);
790
- }
791
- dequeue() {
792
- return this.items.shift();
793
- }
794
- remove(item) {
795
- let index;
796
- while ((index = this.items.indexOf(item)) >= 0) {
797
- this.items.splice(index, 1);
798
- }
799
- }
800
- }
801
-
802
674
  var es2018$6 = {};
803
675
 
804
- var customError = {};
805
-
806
- var es2018$5 = {};
807
-
808
- var middleware = {};
809
-
810
- var chunkAsync = {};
811
-
812
- var es2018$4 = {};
813
-
814
676
  var go$1 = {};
815
677
 
816
678
  go$1.go = void 0;
@@ -838,11 +700,11 @@ goMicrotask$1.goMicrotask = goMicrotask;
838
700
 
839
701
  var goMacrotask$1 = {};
840
702
 
841
- var es2018$3 = {};
703
+ var es2018$5 = {};
842
704
 
843
705
  var exponentialBackoff = {};
844
706
 
845
- var es2018$2 = {};
707
+ var es2018$4 = {};
846
708
 
847
709
  var random$1 = {};
848
710
 
@@ -886,10 +748,10 @@ randomIntInclusive$1.randomIntInclusive = randomIntInclusive;
886
748
  __exportStar(randomInt$1, exports);
887
749
  __exportStar(randomIntInclusive$1, exports);
888
750
 
889
- } (es2018$2));
751
+ } (es2018$4));
890
752
 
891
753
  exponentialBackoff.calculateExponentialBackoffTimeout = void 0;
892
- const extra_rand_1 = es2018$2;
754
+ const extra_rand_1 = es2018$4;
893
755
  function calculateExponentialBackoffTimeout({ baseTimeout, retries, maxTimeout = Infinity, factor = 2, jitter = true }) {
894
756
  const timeout = Math.min(factor ** retries * baseTimeout, maxTimeout);
895
757
  if (jitter) {
@@ -1004,10 +866,10 @@ setDynamicTimeoutLoop$1.setDynamicTimeoutLoop = setDynamicTimeoutLoop;
1004
866
  __exportStar(setTimeoutLoop$1, exports);
1005
867
  __exportStar(setDynamicTimeoutLoop$1, exports);
1006
868
 
1007
- } (es2018$3));
869
+ } (es2018$5));
1008
870
 
1009
871
  goMacrotask$1.goMacrotask = void 0;
1010
- const extra_timers_1 = es2018$3;
872
+ const extra_timers_1 = es2018$5;
1011
873
  function goMacrotask(fn) {
1012
874
  return new Promise((resolve, reject) => {
1013
875
  (0, extra_timers_1.setImmediate)(async () => {
@@ -1040,7 +902,151 @@ goMacrotask$1.goMacrotask = goMacrotask;
1040
902
  __exportStar(goMicrotask$1, exports);
1041
903
  __exportStar(goMacrotask$1, exports);
1042
904
 
1043
- } (es2018$4));
905
+ } (es2018$6));
906
+
907
+ class Emitter {
908
+ constructor() {
909
+ this.map = new Map();
910
+ }
911
+ get [Symbol.toStringTag]() {
912
+ return this.constructor.name;
913
+ }
914
+ on(event, listener) {
915
+ const set = es2018$6.go(() => {
916
+ const set = this.map.get(event);
917
+ if (set) {
918
+ return set;
919
+ }
920
+ else {
921
+ const set = new Set();
922
+ this.map.set(event, set);
923
+ return set;
924
+ }
925
+ });
926
+ set.add(handler);
927
+ return () => {
928
+ const handlers = this.map.get(event);
929
+ if (handlers) {
930
+ const deleted = handlers.delete(handler);
931
+ if (deleted && handlers.size === 0) {
932
+ this.map.delete(event);
933
+ }
934
+ }
935
+ };
936
+ function handler(...args) {
937
+ listener(...args);
938
+ }
939
+ }
940
+ once(event, listener) {
941
+ const removeListener = this.on(event, (...args) => {
942
+ listener(...args);
943
+ removeListener();
944
+ });
945
+ return removeListener;
946
+ }
947
+ emit(event, ...args) {
948
+ var _a;
949
+ (_a = this.map.get(event)) === null || _a === void 0 ? void 0 : _a.forEach(cb => cb(...args));
950
+ }
951
+ }
952
+
953
+ class HashMap {
954
+ constructor(hash) {
955
+ this.hash = hash;
956
+ this.map = new Map();
957
+ }
958
+ get [Symbol.toStringTag]() {
959
+ return this.constructor.name;
960
+ }
961
+ get size() {
962
+ return this.map.size;
963
+ }
964
+ set(key, value) {
965
+ this.map.set(this.hash(key), value);
966
+ return this;
967
+ }
968
+ has(key) {
969
+ return this.map.has(this.hash(key));
970
+ }
971
+ get(key) {
972
+ return this.map.get(this.hash(key));
973
+ }
974
+ delete(key) {
975
+ return this.map.delete(this.hash(key));
976
+ }
977
+ clear() {
978
+ this.map.clear();
979
+ }
980
+ }
981
+
982
+ class HashSet {
983
+ constructor(hash) {
984
+ this.hash = hash;
985
+ this.map = new Map();
986
+ }
987
+ get [Symbol.toStringTag]() {
988
+ return this.constructor.name;
989
+ }
990
+ get size() {
991
+ return this.map.size;
992
+ }
993
+ [Symbol.iterator]() {
994
+ return this.map.values();
995
+ }
996
+ add(value) {
997
+ this.map.set(this.hash(value), value);
998
+ return this;
999
+ }
1000
+ delete(value) {
1001
+ return this.map.delete(this.hash(value));
1002
+ }
1003
+ has(value) {
1004
+ return this.map.has(this.hash(value));
1005
+ }
1006
+ clear() {
1007
+ this.map.clear();
1008
+ }
1009
+ values() {
1010
+ return this.map.values();
1011
+ }
1012
+ }
1013
+
1014
+ class Queue {
1015
+ constructor() {
1016
+ this.items = [];
1017
+ }
1018
+ get [Symbol.toStringTag]() {
1019
+ return this.constructor.name;
1020
+ }
1021
+ get size() {
1022
+ return this.items.length;
1023
+ }
1024
+ empty() {
1025
+ this.items.length = 0;
1026
+ }
1027
+ enqueue(...items) {
1028
+ this.items.push(...items);
1029
+ }
1030
+ dequeue() {
1031
+ return this.items.shift();
1032
+ }
1033
+ remove(item) {
1034
+ let index;
1035
+ while ((index = this.items.indexOf(item)) >= 0) {
1036
+ this.items.splice(index, 1);
1037
+ }
1038
+ }
1039
+ }
1040
+
1041
+ var es2018$3 = {};
1042
+
1043
+ var customError = {};
1044
+
1045
+ var es2018$2 = {};
1046
+
1047
+ var middleware = {};
1048
+
1049
+ var chunkAsync = {};
1044
1050
 
1045
1051
  var hasRequiredChunkAsync;
1046
1052
 
@@ -1048,7 +1054,7 @@ function requireChunkAsync () {
1048
1054
  if (hasRequiredChunkAsync) return chunkAsync;
1049
1055
  hasRequiredChunkAsync = 1;
1050
1056
  chunkAsync.chunkAsync = void 0;
1051
- const go_1 = es2018$4;
1057
+ const go_1 = es2018$6;
1052
1058
  const errors_1 = requireEs2018();
1053
1059
  function chunkAsync$1(iterable, size) {
1054
1060
  (0, errors_1.assert)(Number.isInteger(size), 'The parameter size must be an integer');
@@ -1513,7 +1519,7 @@ function requireChunk () {
1513
1519
  if (hasRequiredChunk) return chunk;
1514
1520
  hasRequiredChunk = 1;
1515
1521
  chunk.chunk = void 0;
1516
- const go_1 = es2018$4;
1522
+ const go_1 = es2018$6;
1517
1523
  const errors_1 = requireEs2018();
1518
1524
  function chunk$1(iterable, size) {
1519
1525
  (0, errors_1.assert)(Number.isInteger(size), 'The parameter size must be an integer');
@@ -1540,7 +1546,7 @@ var concatAsync$1 = {};
1540
1546
 
1541
1547
  concatAsync$1.concatAsync = void 0;
1542
1548
  const types_1$i = es2018$1;
1543
- const go_1$1 = es2018$4;
1549
+ const go_1$1 = es2018$6;
1544
1550
  function concatAsync(iterable, ...otherIterables) {
1545
1551
  return (0, go_1$1.go)(async function* () {
1546
1552
  for (const iter of [iterable, ...otherIterables]) {
@@ -1562,7 +1568,7 @@ concatAsync$1.concatAsync = concatAsync;
1562
1568
  var concat$1 = {};
1563
1569
 
1564
1570
  concat$1.concat = void 0;
1565
- const go_1 = es2018$4;
1571
+ const go_1 = es2018$6;
1566
1572
  function concat(iterable, ...otherIterables) {
1567
1573
  return (0, go_1.go)(function* () {
1568
1574
  for (const iter of [iterable, ...otherIterables]) {
@@ -1596,7 +1602,7 @@ function requireDropAsync () {
1596
1602
  if (hasRequiredDropAsync) return dropAsync;
1597
1603
  hasRequiredDropAsync = 1;
1598
1604
  dropAsync.dropAsync = void 0;
1599
- const go_1 = es2018$4;
1605
+ const go_1 = es2018$6;
1600
1606
  const utils_1 = utils;
1601
1607
  const errors_1 = requireEs2018();
1602
1608
  function dropAsync$1(iterable, count) {
@@ -1639,7 +1645,7 @@ function requireDropRightAsync () {
1639
1645
  if (hasRequiredDropRightAsync) return dropRightAsync;
1640
1646
  hasRequiredDropRightAsync = 1;
1641
1647
  dropRightAsync.dropRightAsync = void 0;
1642
- const go_1 = es2018$4;
1648
+ const go_1 = es2018$6;
1643
1649
  const utils_1 = utils;
1644
1650
  const errors_1 = requireEs2018();
1645
1651
  function dropRightAsync$1(iterable, count) {
@@ -1675,7 +1681,7 @@ function requireDropRight () {
1675
1681
  if (hasRequiredDropRight) return dropRight;
1676
1682
  hasRequiredDropRight = 1;
1677
1683
  dropRight.dropRight = void 0;
1678
- const go_1 = es2018$4;
1684
+ const go_1 = es2018$6;
1679
1685
  const utils_1 = utils;
1680
1686
  const errors_1 = requireEs2018();
1681
1687
  function dropRight$1(iterable, count) {
@@ -1783,7 +1789,7 @@ function requireDrop () {
1783
1789
  if (hasRequiredDrop) return drop;
1784
1790
  hasRequiredDrop = 1;
1785
1791
  drop.drop = void 0;
1786
- const go_1 = es2018$4;
1792
+ const go_1 = es2018$6;
1787
1793
  const utils_1 = utils;
1788
1794
  const errors_1 = requireEs2018();
1789
1795
  function drop$1(iterable, count) {
@@ -2046,7 +2052,7 @@ function requireRepeatAsync () {
2046
2052
  if (hasRequiredRepeatAsync) return repeatAsync;
2047
2053
  hasRequiredRepeatAsync = 1;
2048
2054
  repeatAsync.repeatAsync = void 0;
2049
- const go_1 = es2018$4;
2055
+ const go_1 = es2018$6;
2050
2056
  const errors_1 = requireEs2018();
2051
2057
  function repeatAsync$1(iterable, times) {
2052
2058
  (0, errors_1.assert)(times === Infinity || Number.isInteger(times), 'The parameter times must be an integer');
@@ -2089,7 +2095,7 @@ function requireRepeat () {
2089
2095
  if (hasRequiredRepeat) return repeat;
2090
2096
  hasRequiredRepeat = 1;
2091
2097
  repeat.repeat = void 0;
2092
- const go_1 = es2018$4;
2098
+ const go_1 = es2018$6;
2093
2099
  const errors_1 = requireEs2018();
2094
2100
  function repeat$1(iterable, times) {
2095
2101
  (0, errors_1.assert)(times === Infinity || Number.isInteger(times), 'The parameter times must be an integer');
@@ -2132,7 +2138,7 @@ function requireSliceAsync () {
2132
2138
  if (hasRequiredSliceAsync) return sliceAsync;
2133
2139
  hasRequiredSliceAsync = 1;
2134
2140
  sliceAsync.sliceAsync = void 0;
2135
- const go_1 = es2018$4;
2141
+ const go_1 = es2018$6;
2136
2142
  const errors_1 = requireEs2018();
2137
2143
  function sliceAsync$1(iterable, start, end = Infinity) {
2138
2144
  (0, errors_1.assert)(Number.isInteger(start), 'The parameter start must be an integer');
@@ -2163,7 +2169,7 @@ function requireSlice () {
2163
2169
  if (hasRequiredSlice) return slice;
2164
2170
  hasRequiredSlice = 1;
2165
2171
  slice.slice = void 0;
2166
- const go_1 = es2018$4;
2172
+ const go_1 = es2018$6;
2167
2173
  const errors_1 = requireEs2018();
2168
2174
  function slice$1(iterable, start, end = Infinity) {
2169
2175
  (0, errors_1.assert)(Number.isInteger(start), 'The parameter start must be an integer');
@@ -2294,7 +2300,7 @@ function requireTakeAsync () {
2294
2300
  if (hasRequiredTakeAsync) return takeAsync;
2295
2301
  hasRequiredTakeAsync = 1;
2296
2302
  takeAsync.takeAsync = void 0;
2297
- const go_1 = es2018$4;
2303
+ const go_1 = es2018$6;
2298
2304
  const errors_1 = requireEs2018();
2299
2305
  function takeAsync$1(iterable, count) {
2300
2306
  (0, errors_1.assert)(Number.isInteger(count), 'The parameter count must be an integer');
@@ -2323,7 +2329,7 @@ function requireTakeRightAsync () {
2323
2329
  if (hasRequiredTakeRightAsync) return takeRightAsync;
2324
2330
  hasRequiredTakeRightAsync = 1;
2325
2331
  takeRightAsync.takeRightAsync = void 0;
2326
- const go_1 = es2018$4;
2332
+ const go_1 = es2018$6;
2327
2333
  const errors_1 = requireEs2018();
2328
2334
  function takeRightAsync$1(iterable, count) {
2329
2335
  (0, errors_1.assert)(Number.isInteger(count), 'The parameter count must be an integer');
@@ -2361,7 +2367,7 @@ function requireTakeRight () {
2361
2367
  if (hasRequiredTakeRight) return takeRight;
2362
2368
  hasRequiredTakeRight = 1;
2363
2369
  takeRight.takeRight = void 0;
2364
- const go_1 = es2018$4;
2370
+ const go_1 = es2018$6;
2365
2371
  const errors_1 = requireEs2018();
2366
2372
  function takeRight$1(iterable, count) {
2367
2373
  (0, errors_1.assert)(Number.isInteger(count), 'The parameter count must be an integer');
@@ -2445,7 +2451,7 @@ function requireTake () {
2445
2451
  if (hasRequiredTake) return take;
2446
2452
  hasRequiredTake = 1;
2447
2453
  take.take = void 0;
2448
- const go_1 = es2018$4;
2454
+ const go_1 = es2018$6;
2449
2455
  const errors_1 = requireEs2018();
2450
2456
  function take$1(iterable, count) {
2451
2457
  (0, errors_1.assert)(Number.isInteger(count), 'The parameter count must be an integer');
@@ -3385,7 +3391,7 @@ groupByAsync$1.groupByAsync = groupByAsync;
3385
3391
  var hasRequiredEs2018$1;
3386
3392
 
3387
3393
  function requireEs2018$1 () {
3388
- if (hasRequiredEs2018$1) return es2018$5;
3394
+ if (hasRequiredEs2018$1) return es2018$2;
3389
3395
  hasRequiredEs2018$1 = 1;
3390
3396
  (function (exports) {
3391
3397
  var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -3404,8 +3410,8 @@ function requireEs2018$1 () {
3404
3410
  };__exportStar(requireMiddleware(), exports);
3405
3411
  __exportStar(output, exports);
3406
3412
 
3407
- } (es2018$5));
3408
- return es2018$5;
3413
+ } (es2018$2));
3414
+ return es2018$2;
3409
3415
  }
3410
3416
 
3411
3417
  var getErrorNames$1 = {};
@@ -3609,7 +3615,7 @@ assert.assert = void 0;
3609
3615
  var hasRequiredEs2018;
3610
3616
 
3611
3617
  function requireEs2018 () {
3612
- if (hasRequiredEs2018) return es2018$6;
3618
+ if (hasRequiredEs2018) return es2018$3;
3613
3619
  hasRequiredEs2018 = 1;
3614
3620
  (function (exports) {
3615
3621
  var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -3634,8 +3640,8 @@ function requireEs2018 () {
3634
3640
  __exportStar(getErrorNames$1, exports);
3635
3641
  __exportStar(traverseErrorPrototypeChain$1, exports);
3636
3642
 
3637
- } (es2018$6));
3638
- return es2018$6;
3643
+ } (es2018$3));
3644
+ return es2018$3;
3639
3645
  }
3640
3646
 
3641
3647
  var es2018Exports$1 = requireEs2018();
@@ -3784,7 +3790,7 @@ class ExpirableMap {
3784
3790
  if (this.itemMetadataSortedByExpirationTime.length > 0) {
3785
3791
  const item = this.itemMetadataSortedByExpirationTime[0];
3786
3792
  if (Number.isFinite(item.expirationTime)) {
3787
- const cancel = es2018$3.setSchedule(item.expirationTime, () => {
3793
+ const cancel = es2018$5.setSchedule(item.expirationTime, () => {
3788
3794
  this.clearExpiredItems(Date.now());
3789
3795
  this.rescheduleClearTimeout();
3790
3796
  });
@@ -3912,7 +3918,7 @@ class TLRUMap {
3912
3918
  if (this.itemMetadataSortedByExpirationTime.length > 0) {
3913
3919
  const item = this.itemMetadataSortedByExpirationTime[0];
3914
3920
  if (Number.isFinite(item.expirationTime)) {
3915
- const cancel = es2018$3.setSchedule(item.expirationTime, () => {
3921
+ const cancel = es2018$5.setSchedule(item.expirationTime, () => {
3916
3922
  this.clearExpiredItems(Date.now());
3917
3923
  this.rescheduleClearTimeout();
3918
3924
  });