@likec4/core 1.24.1 → 1.25.0

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.
@@ -1,9 +1,1052 @@
1
- import { d as t, a0 as n, o as commonAncestor, s as compareFqnHierarchically } from '../shared/core.CHsHWcLq.mjs';
2
- export { D as DefaultMap, e as DefaultWeakMap, f as LinkedList, g as MultiMap, q as Queue, S as Stack, k as ancestorsFqn, h as commonHead, r as compareByFqnHierarchically, j as compareNatural, M as difference, N as equalsSet, B as getOrCreate, a as hasAtLeast, u as hierarchyDistance, v as hierarchyLevel, F as ifilter, i as ifind, G as iflat, H as imap, O as intersection, w as isAncestor, x as isDescendantOf, I as isIterable, C as isNonEmptyArray, c as isSameHierarchy, E as isString, J as isome, K as iunique, n as nameFromFqn, T as objectHash, p as parentFqn, y as sortByFqnHierarchically, z as sortNaturalByFqn, A as sortParentsFirst, R as stringHash, P as symmetricDifference, L as toArray, t as toSet, Q as union } from '../shared/core.CHsHWcLq.mjs';
1
+ import { T as getDefaultExportFromCjs, V as requireIterator, U as requireForeach, d as t, Y as n, h as commonAncestor, k as compareFqnHierarchically } from '../shared/core.DQMSDiu8.mjs';
2
+ export { D as DefaultMap, S as Stack, g as ancestorsFqn, e as commonHead, j as compareByFqnHierarchically, f as compareNatural, I as difference, J as equalsSet, x as getOrCreate, a as hasAtLeast, o as hierarchyDistance, q as hierarchyLevel, A as ifilter, i as ifind, B as iflat, C as imap, K as intersection, r as isAncestor, s as isDescendantOf, E as isIterable, y as isNonEmptyArray, c as isSameHierarchy, z as isString, F as isome, G as iunique, n as nameFromFqn, O as objectHash, p as parentFqn, u as sortByFqnHierarchically, v as sortNaturalByFqn, w as sortParentsFirst, N as stringHash, L as symmetricDifference, H as toArray, t as toSet, M as union } from '../shared/core.DQMSDiu8.mjs';
3
3
  import { i as invariant } from '../shared/core.Btj1m6H6.mjs';
4
4
 
5
5
  function o(r,n){let e=Math.ceil(r),t=Math.floor(n);if(t<e)throw new RangeError(`randomInteger: The range [${r.toString()},${n.toString()}] contains no integer`);return Math.floor(Math.random()*(t-e+1)+e)}
6
6
 
7
+ /**
8
+ * Mnemonist DefaultWeakMap
9
+ * =========================
10
+ *
11
+ * JavaScript implementation of a default weak map that will return a constructed
12
+ * value any time one tries to access an non-existing key. It is similar to
13
+ * DefaultMap but uses ES6 WeakMap that only holds weak reference to keys.
14
+ */
15
+
16
+ var defaultWeakMap$1;
17
+ var hasRequiredDefaultWeakMap;
18
+
19
+ function requireDefaultWeakMap () {
20
+ if (hasRequiredDefaultWeakMap) return defaultWeakMap$1;
21
+ hasRequiredDefaultWeakMap = 1;
22
+ /**
23
+ * DefaultWeakMap.
24
+ *
25
+ * @constructor
26
+ */
27
+ function DefaultWeakMap(factory) {
28
+ if (typeof factory !== 'function')
29
+ throw new Error('mnemonist/DefaultWeakMap.constructor: expecting a function.');
30
+
31
+ this.items = new WeakMap();
32
+ this.factory = factory;
33
+ }
34
+
35
+ /**
36
+ * Method used to clear the structure.
37
+ *
38
+ * @return {undefined}
39
+ */
40
+ DefaultWeakMap.prototype.clear = function() {
41
+
42
+ // Properties
43
+ this.items = new WeakMap();
44
+ };
45
+
46
+ /**
47
+ * Method used to get the value set for given key. If the key does not exist,
48
+ * the value will be created using the provided factory.
49
+ *
50
+ * @param {any} key - Target key.
51
+ * @return {any}
52
+ */
53
+ DefaultWeakMap.prototype.get = function(key) {
54
+ var value = this.items.get(key);
55
+
56
+ if (typeof value === 'undefined') {
57
+ value = this.factory(key);
58
+ this.items.set(key, value);
59
+ }
60
+
61
+ return value;
62
+ };
63
+
64
+ /**
65
+ * Method used to get the value set for given key. If the key does not exist,
66
+ * a value won't be created.
67
+ *
68
+ * @param {any} key - Target key.
69
+ * @return {any}
70
+ */
71
+ DefaultWeakMap.prototype.peek = function(key) {
72
+ return this.items.get(key);
73
+ };
74
+
75
+ /**
76
+ * Method used to set a value for given key.
77
+ *
78
+ * @param {any} key - Target key.
79
+ * @param {any} value - Value.
80
+ * @return {DefaultMap}
81
+ */
82
+ DefaultWeakMap.prototype.set = function(key, value) {
83
+ this.items.set(key, value);
84
+ return this;
85
+ };
86
+
87
+ /**
88
+ * Method used to test the existence of a key in the map.
89
+ *
90
+ * @param {any} key - Target key.
91
+ * @return {boolean}
92
+ */
93
+ DefaultWeakMap.prototype.has = function(key) {
94
+ return this.items.has(key);
95
+ };
96
+
97
+ /**
98
+ * Method used to delete target key.
99
+ *
100
+ * @param {any} key - Target key.
101
+ * @return {boolean}
102
+ */
103
+ DefaultWeakMap.prototype.delete = function(key) {
104
+ return this.items.delete(key);
105
+ };
106
+
107
+ /**
108
+ * Convenience known methods.
109
+ */
110
+ DefaultWeakMap.prototype.inspect = function() {
111
+ return this.items;
112
+ };
113
+
114
+ if (typeof Symbol !== 'undefined')
115
+ DefaultWeakMap.prototype[Symbol.for('nodejs.util.inspect.custom')] = DefaultWeakMap.prototype.inspect;
116
+
117
+ /**
118
+ * Exporting.
119
+ */
120
+ defaultWeakMap$1 = DefaultWeakMap;
121
+ return defaultWeakMap$1;
122
+ }
123
+
124
+ var defaultWeakMapExports = /*@__PURE__*/ requireDefaultWeakMap();
125
+ const defaultWeakMap = /*@__PURE__*/getDefaultExportFromCjs(defaultWeakMapExports);
126
+
127
+ /**
128
+ * Mnemonist Linked List
129
+ * ======================
130
+ *
131
+ * Singly linked list implementation. Uses raw JavaScript objects as nodes
132
+ * as benchmarks proved it was the fastest thing to do.
133
+ */
134
+
135
+ var linkedList$1;
136
+ var hasRequiredLinkedList;
137
+
138
+ function requireLinkedList () {
139
+ if (hasRequiredLinkedList) return linkedList$1;
140
+ hasRequiredLinkedList = 1;
141
+ var Iterator = requireIterator(),
142
+ forEach = requireForeach();
143
+
144
+ /**
145
+ * Linked List.
146
+ *
147
+ * @constructor
148
+ */
149
+ function LinkedList() {
150
+ this.clear();
151
+ }
152
+
153
+ /**
154
+ * Method used to clear the list.
155
+ *
156
+ * @return {undefined}
157
+ */
158
+ LinkedList.prototype.clear = function() {
159
+
160
+ // Properties
161
+ this.head = null;
162
+ this.tail = null;
163
+ this.size = 0;
164
+ };
165
+
166
+ /**
167
+ * Method used to get the first item of the list.
168
+ *
169
+ * @return {any}
170
+ */
171
+ LinkedList.prototype.first = function() {
172
+ return this.head ? this.head.item : undefined;
173
+ };
174
+ LinkedList.prototype.peek = LinkedList.prototype.first;
175
+
176
+ /**
177
+ * Method used to get the last item of the list.
178
+ *
179
+ * @return {any}
180
+ */
181
+ LinkedList.prototype.last = function() {
182
+ return this.tail ? this.tail.item : undefined;
183
+ };
184
+
185
+ /**
186
+ * Method used to add an item at the end of the list.
187
+ *
188
+ * @param {any} item - The item to add.
189
+ * @return {number}
190
+ */
191
+ LinkedList.prototype.push = function(item) {
192
+ var node = {item: item, next: null};
193
+
194
+ if (!this.head) {
195
+ this.head = node;
196
+ this.tail = node;
197
+ }
198
+ else {
199
+ this.tail.next = node;
200
+ this.tail = node;
201
+ }
202
+
203
+ this.size++;
204
+
205
+ return this.size;
206
+ };
207
+
208
+ /**
209
+ * Method used to add an item at the beginning of the list.
210
+ *
211
+ * @param {any} item - The item to add.
212
+ * @return {number}
213
+ */
214
+ LinkedList.prototype.unshift = function(item) {
215
+ var node = {item: item, next: null};
216
+
217
+ if (!this.head) {
218
+ this.head = node;
219
+ this.tail = node;
220
+ }
221
+ else {
222
+ if (!this.head.next)
223
+ this.tail = this.head;
224
+ node.next = this.head;
225
+ this.head = node;
226
+ }
227
+
228
+ this.size++;
229
+
230
+ return this.size;
231
+ };
232
+
233
+ /**
234
+ * Method used to retrieve & remove the first item of the list.
235
+ *
236
+ * @return {any}
237
+ */
238
+ LinkedList.prototype.shift = function() {
239
+ if (!this.size)
240
+ return undefined;
241
+
242
+ var node = this.head;
243
+
244
+ this.head = node.next;
245
+ this.size--;
246
+
247
+ return node.item;
248
+ };
249
+
250
+ /**
251
+ * Method used to iterate over the list.
252
+ *
253
+ * @param {function} callback - Function to call for each item.
254
+ * @param {object} scope - Optional scope.
255
+ * @return {undefined}
256
+ */
257
+ LinkedList.prototype.forEach = function(callback, scope) {
258
+ if (!this.size)
259
+ return;
260
+
261
+ scope = arguments.length > 1 ? scope : this;
262
+
263
+ var n = this.head,
264
+ i = 0;
265
+
266
+ while (n) {
267
+ callback.call(scope, n.item, i, this);
268
+ n = n.next;
269
+ i++;
270
+ }
271
+ };
272
+
273
+ /**
274
+ * Method used to convert the list into an array.
275
+ *
276
+ * @return {array}
277
+ */
278
+ LinkedList.prototype.toArray = function() {
279
+ if (!this.size)
280
+ return [];
281
+
282
+ var array = new Array(this.size);
283
+
284
+ for (var i = 0, l = this.size, n = this.head; i < l; i++) {
285
+ array[i] = n.item;
286
+ n = n.next;
287
+ }
288
+
289
+ return array;
290
+ };
291
+
292
+ /**
293
+ * Method used to create an iterator over a list's values.
294
+ *
295
+ * @return {Iterator}
296
+ */
297
+ LinkedList.prototype.values = function() {
298
+ var n = this.head;
299
+
300
+ return new Iterator(function() {
301
+ if (!n)
302
+ return {
303
+ done: true
304
+ };
305
+
306
+ var value = n.item;
307
+ n = n.next;
308
+
309
+ return {
310
+ value: value,
311
+ done: false
312
+ };
313
+ });
314
+ };
315
+
316
+ /**
317
+ * Method used to create an iterator over a list's entries.
318
+ *
319
+ * @return {Iterator}
320
+ */
321
+ LinkedList.prototype.entries = function() {
322
+ var n = this.head,
323
+ i = 0;
324
+
325
+ return new Iterator(function() {
326
+ if (!n)
327
+ return {
328
+ done: true
329
+ };
330
+
331
+ var value = n.item;
332
+ n = n.next;
333
+ i++;
334
+
335
+ return {
336
+ value: [i - 1, value],
337
+ done: false
338
+ };
339
+ });
340
+ };
341
+
342
+ /**
343
+ * Attaching the #.values method to Symbol.iterator if possible.
344
+ */
345
+ if (typeof Symbol !== 'undefined')
346
+ LinkedList.prototype[Symbol.iterator] = LinkedList.prototype.values;
347
+
348
+ /**
349
+ * Convenience known methods.
350
+ */
351
+ LinkedList.prototype.toString = function() {
352
+ return this.toArray().join(',');
353
+ };
354
+
355
+ LinkedList.prototype.toJSON = function() {
356
+ return this.toArray();
357
+ };
358
+
359
+ LinkedList.prototype.inspect = function() {
360
+ var array = this.toArray();
361
+
362
+ // Trick so that node displays the name of the constructor
363
+ Object.defineProperty(array, 'constructor', {
364
+ value: LinkedList,
365
+ enumerable: false
366
+ });
367
+
368
+ return array;
369
+ };
370
+
371
+ if (typeof Symbol !== 'undefined')
372
+ LinkedList.prototype[Symbol.for('nodejs.util.inspect.custom')] = LinkedList.prototype.inspect;
373
+
374
+ /**
375
+ * Static @.from function taking an arbitrary iterable & converting it into
376
+ * a list.
377
+ *
378
+ * @param {Iterable} iterable - Target iterable.
379
+ * @return {LinkedList}
380
+ */
381
+ LinkedList.from = function(iterable) {
382
+ var list = new LinkedList();
383
+
384
+ forEach(iterable, function(value) {
385
+ list.push(value);
386
+ });
387
+
388
+ return list;
389
+ };
390
+
391
+ /**
392
+ * Exporting.
393
+ */
394
+ linkedList$1 = LinkedList;
395
+ return linkedList$1;
396
+ }
397
+
398
+ var linkedListExports = /*@__PURE__*/ requireLinkedList();
399
+ const linkedList = /*@__PURE__*/getDefaultExportFromCjs(linkedListExports);
400
+
401
+ /**
402
+ * Mnemonist MultiMap
403
+ * ===================
404
+ *
405
+ * Implementation of a MultiMap with custom container.
406
+ */
407
+
408
+ var multiMap$1;
409
+ var hasRequiredMultiMap;
410
+
411
+ function requireMultiMap () {
412
+ if (hasRequiredMultiMap) return multiMap$1;
413
+ hasRequiredMultiMap = 1;
414
+ var Iterator = requireIterator(),
415
+ forEach = requireForeach();
416
+
417
+ /**
418
+ * MultiMap.
419
+ *
420
+ * @constructor
421
+ */
422
+ function MultiMap(Container) {
423
+
424
+ this.Container = Container || Array;
425
+ this.items = new Map();
426
+ this.clear();
427
+
428
+ Object.defineProperty(this.items, 'constructor', {
429
+ value: MultiMap,
430
+ enumerable: false
431
+ });
432
+ }
433
+
434
+ /**
435
+ * Method used to clear the structure.
436
+ *
437
+ * @return {undefined}
438
+ */
439
+ MultiMap.prototype.clear = function() {
440
+
441
+ // Properties
442
+ this.size = 0;
443
+ this.dimension = 0;
444
+ this.items.clear();
445
+ };
446
+
447
+ /**
448
+ * Method used to set a value.
449
+ *
450
+ * @param {any} key - Key.
451
+ * @param {any} value - Value to add.
452
+ * @return {MultiMap}
453
+ */
454
+ MultiMap.prototype.set = function(key, value) {
455
+ var container = this.items.get(key),
456
+ sizeBefore;
457
+
458
+ if (!container) {
459
+ this.dimension++;
460
+ container = new this.Container();
461
+ this.items.set(key, container);
462
+ }
463
+
464
+ if (this.Container === Set) {
465
+ sizeBefore = container.size;
466
+ container.add(value);
467
+
468
+ if (sizeBefore < container.size)
469
+ this.size++;
470
+ }
471
+ else {
472
+ container.push(value);
473
+ this.size++;
474
+ }
475
+
476
+ return this;
477
+ };
478
+
479
+ /**
480
+ * Method used to delete the given key.
481
+ *
482
+ * @param {any} key - Key to delete.
483
+ * @return {boolean}
484
+ */
485
+ MultiMap.prototype.delete = function(key) {
486
+ var container = this.items.get(key);
487
+
488
+ if (!container)
489
+ return false;
490
+
491
+ this.size -= (this.Container === Set ? container.size : container.length);
492
+ this.dimension--;
493
+ this.items.delete(key);
494
+
495
+ return true;
496
+ };
497
+
498
+ /**
499
+ * Method used to delete the remove an item in the container stored at the
500
+ * given key.
501
+ *
502
+ * @param {any} key - Key to delete.
503
+ * @return {boolean}
504
+ */
505
+ MultiMap.prototype.remove = function(key, value) {
506
+ var container = this.items.get(key),
507
+ wasDeleted,
508
+ index;
509
+
510
+ if (!container)
511
+ return false;
512
+
513
+ if (this.Container === Set) {
514
+ wasDeleted = container.delete(value);
515
+
516
+ if (wasDeleted)
517
+ this.size--;
518
+
519
+ if (container.size === 0) {
520
+ this.items.delete(key);
521
+ this.dimension--;
522
+ }
523
+
524
+ return wasDeleted;
525
+ }
526
+ else {
527
+ index = container.indexOf(value);
528
+
529
+ if (index === -1)
530
+ return false;
531
+
532
+ this.size--;
533
+
534
+ if (container.length === 1) {
535
+ this.items.delete(key);
536
+ this.dimension--;
537
+
538
+ return true;
539
+ }
540
+
541
+ container.splice(index, 1);
542
+
543
+ return true;
544
+ }
545
+ };
546
+
547
+ /**
548
+ * Method used to return whether the given keys exists in the map.
549
+ *
550
+ * @param {any} key - Key to check.
551
+ * @return {boolean}
552
+ */
553
+ MultiMap.prototype.has = function(key) {
554
+ return this.items.has(key);
555
+ };
556
+
557
+ /**
558
+ * Method used to return the container stored at the given key or `undefined`.
559
+ *
560
+ * @param {any} key - Key to get.
561
+ * @return {boolean}
562
+ */
563
+ MultiMap.prototype.get = function(key) {
564
+ return this.items.get(key);
565
+ };
566
+
567
+ /**
568
+ * Method used to return the multiplicity of the given key, meaning the number
569
+ * of times it is set, or, more trivially, the size of the attached container.
570
+ *
571
+ * @param {any} key - Key to check.
572
+ * @return {number}
573
+ */
574
+ MultiMap.prototype.multiplicity = function(key) {
575
+ var container = this.items.get(key);
576
+
577
+ if (typeof container === 'undefined')
578
+ return 0;
579
+
580
+ return this.Container === Set ? container.size : container.length;
581
+ };
582
+ MultiMap.prototype.count = MultiMap.prototype.multiplicity;
583
+
584
+ /**
585
+ * Method used to iterate over each of the key/value pairs.
586
+ *
587
+ * @param {function} callback - Function to call for each item.
588
+ * @param {object} scope - Optional scope.
589
+ * @return {undefined}
590
+ */
591
+ MultiMap.prototype.forEach = function(callback, scope) {
592
+ scope = arguments.length > 1 ? scope : this;
593
+
594
+ // Inner iteration function is created here to avoid creating it in the loop
595
+ var key;
596
+ function inner(value) {
597
+ callback.call(scope, value, key);
598
+ }
599
+
600
+ this.items.forEach(function(container, k) {
601
+ key = k;
602
+ container.forEach(inner);
603
+ });
604
+ };
605
+
606
+ /**
607
+ * Method used to iterate over each of the associations.
608
+ *
609
+ * @param {function} callback - Function to call for each item.
610
+ * @param {object} scope - Optional scope.
611
+ * @return {undefined}
612
+ */
613
+ MultiMap.prototype.forEachAssociation = function(callback, scope) {
614
+ scope = arguments.length > 1 ? scope : this;
615
+
616
+ this.items.forEach(callback, scope);
617
+ };
618
+
619
+ /**
620
+ * Method returning an iterator over the map's keys.
621
+ *
622
+ * @return {Iterator}
623
+ */
624
+ MultiMap.prototype.keys = function() {
625
+ return this.items.keys();
626
+ };
627
+
628
+ /**
629
+ * Method returning an iterator over the map's keys.
630
+ *
631
+ * @return {Iterator}
632
+ */
633
+ MultiMap.prototype.values = function() {
634
+ var iterator = this.items.values(),
635
+ inContainer = false,
636
+ countainer,
637
+ step,
638
+ i,
639
+ l;
640
+
641
+ if (this.Container === Set)
642
+ return new Iterator(function next() {
643
+ if (!inContainer) {
644
+ step = iterator.next();
645
+
646
+ if (step.done)
647
+ return {done: true};
648
+
649
+ inContainer = true;
650
+ countainer = step.value.values();
651
+ }
652
+
653
+ step = countainer.next();
654
+
655
+ if (step.done) {
656
+ inContainer = false;
657
+ return next();
658
+ }
659
+
660
+ return {
661
+ done: false,
662
+ value: step.value
663
+ };
664
+ });
665
+
666
+ return new Iterator(function next() {
667
+ if (!inContainer) {
668
+ step = iterator.next();
669
+
670
+ if (step.done)
671
+ return {done: true};
672
+
673
+ inContainer = true;
674
+ countainer = step.value;
675
+ i = 0;
676
+ l = countainer.length;
677
+ }
678
+
679
+ if (i >= l) {
680
+ inContainer = false;
681
+ return next();
682
+ }
683
+
684
+ return {
685
+ done: false,
686
+ value: countainer[i++]
687
+ };
688
+ });
689
+ };
690
+
691
+ /**
692
+ * Method returning an iterator over the map's entries.
693
+ *
694
+ * @return {Iterator}
695
+ */
696
+ MultiMap.prototype.entries = function() {
697
+ var iterator = this.items.entries(),
698
+ inContainer = false,
699
+ countainer,
700
+ step,
701
+ key,
702
+ i,
703
+ l;
704
+
705
+ if (this.Container === Set)
706
+ return new Iterator(function next() {
707
+ if (!inContainer) {
708
+ step = iterator.next();
709
+
710
+ if (step.done)
711
+ return {done: true};
712
+
713
+ inContainer = true;
714
+ key = step.value[0];
715
+ countainer = step.value[1].values();
716
+ }
717
+
718
+ step = countainer.next();
719
+
720
+ if (step.done) {
721
+ inContainer = false;
722
+ return next();
723
+ }
724
+
725
+ return {
726
+ done: false,
727
+ value: [key, step.value]
728
+ };
729
+ });
730
+
731
+ return new Iterator(function next() {
732
+ if (!inContainer) {
733
+ step = iterator.next();
734
+
735
+ if (step.done)
736
+ return {done: true};
737
+
738
+ inContainer = true;
739
+ key = step.value[0];
740
+ countainer = step.value[1];
741
+ i = 0;
742
+ l = countainer.length;
743
+ }
744
+
745
+ if (i >= l) {
746
+ inContainer = false;
747
+ return next();
748
+ }
749
+
750
+ return {
751
+ done: false,
752
+ value: [key, countainer[i++]]
753
+ };
754
+ });
755
+ };
756
+
757
+ /**
758
+ * Method returning an iterator over the map's containers.
759
+ *
760
+ * @return {Iterator}
761
+ */
762
+ MultiMap.prototype.containers = function() {
763
+ return this.items.values();
764
+ };
765
+
766
+ /**
767
+ * Method returning an iterator over the map's associations.
768
+ *
769
+ * @return {Iterator}
770
+ */
771
+ MultiMap.prototype.associations = function() {
772
+ return this.items.entries();
773
+ };
774
+
775
+ /**
776
+ * Attaching the #.entries method to Symbol.iterator if possible.
777
+ */
778
+ if (typeof Symbol !== 'undefined')
779
+ MultiMap.prototype[Symbol.iterator] = MultiMap.prototype.entries;
780
+
781
+ /**
782
+ * Convenience known methods.
783
+ */
784
+ MultiMap.prototype.inspect = function() {
785
+ return this.items;
786
+ };
787
+
788
+ if (typeof Symbol !== 'undefined')
789
+ MultiMap.prototype[Symbol.for('nodejs.util.inspect.custom')] = MultiMap.prototype.inspect;
790
+ MultiMap.prototype.toJSON = function() {
791
+ return this.items;
792
+ };
793
+
794
+ /**
795
+ * Static @.from function taking an arbitrary iterable & converting it into
796
+ * a structure.
797
+ *
798
+ * @param {Iterable} iterable - Target iterable.
799
+ * @param {Class} Container - Container.
800
+ * @return {MultiMap}
801
+ */
802
+ MultiMap.from = function(iterable, Container) {
803
+ var map = new MultiMap(Container);
804
+
805
+ forEach(iterable, function(value, key) {
806
+ map.set(key, value);
807
+ });
808
+
809
+ return map;
810
+ };
811
+
812
+ /**
813
+ * Exporting.
814
+ */
815
+ multiMap$1 = MultiMap;
816
+ return multiMap$1;
817
+ }
818
+
819
+ var multiMapExports = /*@__PURE__*/ requireMultiMap();
820
+ const multiMap = /*@__PURE__*/getDefaultExportFromCjs(multiMapExports);
821
+
822
+ /**
823
+ * Mnemonist Queue
824
+ * ================
825
+ *
826
+ * Queue implementation based on the ideas of Queue.js that seems to beat
827
+ * a LinkedList one in performance.
828
+ */
829
+
830
+ var queue$1;
831
+ var hasRequiredQueue;
832
+
833
+ function requireQueue () {
834
+ if (hasRequiredQueue) return queue$1;
835
+ hasRequiredQueue = 1;
836
+ var Iterator = requireIterator(),
837
+ forEach = requireForeach();
838
+
839
+ /**
840
+ * Queue
841
+ *
842
+ * @constructor
843
+ */
844
+ function Queue() {
845
+ this.clear();
846
+ }
847
+
848
+ /**
849
+ * Method used to clear the queue.
850
+ *
851
+ * @return {undefined}
852
+ */
853
+ Queue.prototype.clear = function() {
854
+
855
+ // Properties
856
+ this.items = [];
857
+ this.offset = 0;
858
+ this.size = 0;
859
+ };
860
+
861
+ /**
862
+ * Method used to add an item to the queue.
863
+ *
864
+ * @param {any} item - Item to enqueue.
865
+ * @return {number}
866
+ */
867
+ Queue.prototype.enqueue = function(item) {
868
+
869
+ this.items.push(item);
870
+ return ++this.size;
871
+ };
872
+
873
+ /**
874
+ * Method used to retrieve & remove the first item of the queue.
875
+ *
876
+ * @return {any}
877
+ */
878
+ Queue.prototype.dequeue = function() {
879
+ if (!this.size)
880
+ return;
881
+
882
+ var item = this.items[this.offset];
883
+
884
+ if (++this.offset * 2 >= this.items.length) {
885
+ this.items = this.items.slice(this.offset);
886
+ this.offset = 0;
887
+ }
888
+
889
+ this.size--;
890
+
891
+ return item;
892
+ };
893
+
894
+ /**
895
+ * Method used to retrieve the first item of the queue.
896
+ *
897
+ * @return {any}
898
+ */
899
+ Queue.prototype.peek = function() {
900
+ if (!this.size)
901
+ return;
902
+
903
+ return this.items[this.offset];
904
+ };
905
+
906
+ /**
907
+ * Method used to iterate over the queue.
908
+ *
909
+ * @param {function} callback - Function to call for each item.
910
+ * @param {object} scope - Optional scope.
911
+ * @return {undefined}
912
+ */
913
+ Queue.prototype.forEach = function(callback, scope) {
914
+ scope = arguments.length > 1 ? scope : this;
915
+
916
+ for (var i = this.offset, j = 0, l = this.items.length; i < l; i++, j++)
917
+ callback.call(scope, this.items[i], j, this);
918
+ };
919
+
920
+ /*
921
+ * Method used to convert the queue to a JavaScript array.
922
+ *
923
+ * @return {array}
924
+ */
925
+ Queue.prototype.toArray = function() {
926
+ return this.items.slice(this.offset);
927
+ };
928
+
929
+ /**
930
+ * Method used to create an iterator over a queue's values.
931
+ *
932
+ * @return {Iterator}
933
+ */
934
+ Queue.prototype.values = function() {
935
+ var items = this.items,
936
+ i = this.offset;
937
+
938
+ return new Iterator(function() {
939
+ if (i >= items.length)
940
+ return {
941
+ done: true
942
+ };
943
+
944
+ var value = items[i];
945
+ i++;
946
+
947
+ return {
948
+ value: value,
949
+ done: false
950
+ };
951
+ });
952
+ };
953
+
954
+ /**
955
+ * Method used to create an iterator over a queue's entries.
956
+ *
957
+ * @return {Iterator}
958
+ */
959
+ Queue.prototype.entries = function() {
960
+ var items = this.items,
961
+ i = this.offset,
962
+ j = 0;
963
+
964
+ return new Iterator(function() {
965
+ if (i >= items.length)
966
+ return {
967
+ done: true
968
+ };
969
+
970
+ var value = items[i];
971
+ i++;
972
+
973
+ return {
974
+ value: [j++, value],
975
+ done: false
976
+ };
977
+ });
978
+ };
979
+
980
+ /**
981
+ * Attaching the #.values method to Symbol.iterator if possible.
982
+ */
983
+ if (typeof Symbol !== 'undefined')
984
+ Queue.prototype[Symbol.iterator] = Queue.prototype.values;
985
+
986
+ /**
987
+ * Convenience known methods.
988
+ */
989
+ Queue.prototype.toString = function() {
990
+ return this.toArray().join(',');
991
+ };
992
+
993
+ Queue.prototype.toJSON = function() {
994
+ return this.toArray();
995
+ };
996
+
997
+ Queue.prototype.inspect = function() {
998
+ var array = this.toArray();
999
+
1000
+ // Trick so that node displays the name of the constructor
1001
+ Object.defineProperty(array, 'constructor', {
1002
+ value: Queue,
1003
+ enumerable: false
1004
+ });
1005
+
1006
+ return array;
1007
+ };
1008
+
1009
+ if (typeof Symbol !== 'undefined')
1010
+ Queue.prototype[Symbol.for('nodejs.util.inspect.custom')] = Queue.prototype.inspect;
1011
+
1012
+ /**
1013
+ * Static @.from function taking an arbitrary iterable & converting it into
1014
+ * a queue.
1015
+ *
1016
+ * @param {Iterable} iterable - Target iterable.
1017
+ * @return {Queue}
1018
+ */
1019
+ Queue.from = function(iterable) {
1020
+ var queue = new Queue();
1021
+
1022
+ forEach(iterable, function(value) {
1023
+ queue.enqueue(value);
1024
+ });
1025
+
1026
+ return queue;
1027
+ };
1028
+
1029
+ /**
1030
+ * Static @.of function taking an arbitrary number of arguments & converting it
1031
+ * into a queue.
1032
+ *
1033
+ * @param {...any} args
1034
+ * @return {Queue}
1035
+ */
1036
+ Queue.of = function() {
1037
+ return Queue.from(arguments);
1038
+ };
1039
+
1040
+ /**
1041
+ * Exporting.
1042
+ */
1043
+ queue$1 = Queue;
1044
+ return queue$1;
1045
+ }
1046
+
1047
+ var queueExports = /*@__PURE__*/ requireQueue();
1048
+ const queue = /*@__PURE__*/getDefaultExportFromCjs(queueExports);
1049
+
7
1050
  function ireduce(arg1, arg2, arg3) {
8
1051
  const reducer = n(arg3) ? arg2 : arg1;
9
1052
  const initialValue = arg3 ?? arg2;
@@ -53,4 +1096,4 @@ const compareRelations = (a, b) => {
53
1096
  return compareFqnHierarchically(a.target, b.target);
54
1097
  };
55
1098
 
56
- export { commonAncestor, compareFqnHierarchically, compareRelations, delay, ireduce };
1099
+ export { defaultWeakMap as DefaultWeakMap, linkedList as LinkedList, multiMap as MultiMap, queue as Queue, commonAncestor, compareFqnHierarchically, compareRelations, delay, ireduce };