@likec4/core 1.47.0 → 1.48.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.
- package/LICENSE +1 -1
- package/dist/_chunks/Builder.view-element.mjs +3284 -0
- package/dist/_chunks/LikeC4Model.d.mts +1287 -0
- package/dist/_chunks/LikeC4Styles.mjs +691 -0
- package/dist/_chunks/RichText.d.mts +84 -0
- package/dist/_chunks/RichText.mjs +148 -0
- package/dist/_chunks/_aux.d.mts +289 -0
- package/dist/_chunks/_aux.mjs +18 -0
- package/dist/_chunks/_types.d.mts +781 -0
- package/dist/_chunks/_types2.d.mts +38 -0
- package/dist/_chunks/assignTagColors.mjs +24 -0
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +379 -0
- package/dist/_chunks/connection.mjs +0 -0
- package/dist/_chunks/const.d.mts +43 -0
- package/dist/_chunks/const.mjs +33 -0
- package/dist/_chunks/expression-model.d.mts +192 -0
- package/dist/_chunks/expression-model.mjs +103 -0
- package/dist/_chunks/expression.d.mts +347 -0
- package/dist/_chunks/expression.mjs +107 -0
- package/dist/_chunks/find.d.mts +82 -0
- package/dist/_chunks/find.mjs +646 -0
- package/dist/_chunks/find2.d.mts +78 -0
- package/dist/_chunks/find2.mjs +287 -0
- package/dist/_chunks/fqnRef.d.mts +58 -0
- package/dist/_chunks/fqnRef.mjs +41 -0
- package/dist/_chunks/geometry.mjs +335 -0
- package/dist/_chunks/index.d.mts +169 -0
- package/dist/_chunks/index2.d.mts +937 -0
- package/dist/_chunks/index3.d.mts +146 -0
- package/dist/_chunks/index4.d.mts +62 -0
- package/dist/_chunks/index5.d.mts +42 -0
- package/dist/_chunks/index6.d.mts +43 -0
- package/dist/{shared/core.OtRNdMxy.d.mts → _chunks/index7.d.mts} +113 -197
- package/dist/_chunks/index8.d.mts +144 -0
- package/dist/_chunks/invariant.mjs +18 -0
- package/dist/_chunks/iterable.mjs +146 -0
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +3416 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +213 -0
- package/dist/_chunks/libs/bail.mjs +14 -0
- package/dist/_chunks/libs/ccount.mjs +25 -0
- package/dist/_chunks/libs/character-entities-html4.mjs +263 -0
- package/dist/_chunks/libs/character-entities-legacy.mjs +117 -0
- package/dist/_chunks/libs/character-entities.mjs +2136 -0
- package/dist/_chunks/libs/comma-separated-tokens.mjs +18 -0
- package/dist/_chunks/libs/decode-named-character-reference.mjs +21 -0
- package/dist/_chunks/libs/defu.mjs +42 -0
- package/dist/_chunks/libs/devlop.mjs +5 -0
- package/dist/_chunks/libs/escape-string-regexp.mjs +8 -0
- package/dist/_chunks/libs/extend.mjs +77 -0
- package/dist/_chunks/libs/graphology-dag.mjs +703 -0
- package/dist/_chunks/libs/graphology-types.d.mts +601 -0
- package/dist/_chunks/libs/graphology.d.mts +6 -0
- package/dist/_chunks/libs/graphology.mjs +4565 -0
- package/dist/_chunks/libs/hast-util-sanitize.mjs +863 -0
- package/dist/_chunks/libs/hast-util-to-html.mjs +2696 -0
- package/dist/_chunks/libs/is-plain-obj.mjs +9 -0
- package/dist/_chunks/libs/longest-streak.mjs +30 -0
- package/dist/_chunks/libs/markdown-table.mjs +290 -0
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +653 -0
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +8522 -0
- package/dist/_chunks/libs/mdast-util-gfm.mjs +2393 -0
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +1803 -0
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +2243 -0
- package/dist/_chunks/libs/mnemonist.d.mts +254 -0
- package/dist/_chunks/libs/mnemonist.mjs +1978 -0
- package/dist/_chunks/libs/natural-compare-lite.mjs +42 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +29 -0
- package/dist/_chunks/libs/rehype-stringify.mjs +34 -0
- package/dist/_chunks/libs/remark-gfm.mjs +36 -0
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +100 -0
- package/dist/_chunks/libs/remark-parse.mjs +39 -0
- package/dist/_chunks/libs/remark-rehype.mjs +171 -0
- package/dist/_chunks/libs/remeda.mjs +702 -0
- package/dist/_chunks/libs/trough.mjs +158 -0
- package/dist/_chunks/libs/unified.mjs +2212 -0
- package/dist/_chunks/mnemonist.d.mts +1 -0
- package/dist/_chunks/mnemonist.mjs +0 -0
- package/dist/_chunks/model.mjs +1898 -0
- package/dist/_chunks/model2.mjs +0 -0
- package/dist/_chunks/relationships-view.mjs +132 -0
- package/dist/_chunks/rolldown-runtime.mjs +42 -0
- package/dist/{shared/core.C_3y3eqV.d.mts → _chunks/scalar.d.mts} +13 -43
- package/dist/_chunks/scalar.mjs +84 -0
- package/dist/_chunks/utils.mjs +483 -0
- package/dist/builder/index.d.mts +11 -775
- package/dist/builder/index.mjs +631 -1022
- package/dist/compute-view/index.d.mts +85 -56
- package/dist/compute-view/index.mjs +247 -214
- package/dist/compute-view/relationships-view/index.d.mts +16 -51
- package/dist/compute-view/relationships-view/index.mjs +6 -184
- package/dist/geometry/index.d.mts +2 -109
- package/dist/geometry/index.mjs +2 -327
- package/dist/index.d.mts +18 -20
- package/dist/index.mjs +27 -18
- package/dist/model/connection/deployment/index.d.mts +12 -15
- package/dist/model/connection/deployment/index.mjs +9 -2
- package/dist/model/connection/index.d.mts +14 -75
- package/dist/model/connection/index.mjs +10 -3
- package/dist/model/connection/model/index.d.mts +12 -15
- package/dist/model/connection/model/index.mjs +8 -2
- package/dist/model/index.d.mts +15 -57
- package/dist/model/index.mjs +11 -4
- package/dist/styles/index.d.mts +9 -117
- package/dist/styles/index.mjs +26 -59
- package/dist/types/RichText.d.mts +3 -0
- package/dist/types/RichText.mjs +7 -0
- package/dist/types/_aux.d.mts +3 -4
- package/dist/types/_aux.mjs +2 -7
- package/dist/types/expression-model.d.mts +6 -190
- package/dist/types/expression-model.mjs +6 -108
- package/dist/types/expression.d.mts +5 -6
- package/dist/types/expression.mjs +6 -112
- package/dist/types/fqnRef.d.mts +4 -60
- package/dist/types/fqnRef.mjs +6 -44
- package/dist/types/index.d.mts +9 -47
- package/dist/types/index.mjs +14 -16
- package/dist/types/scalar.d.mts +2 -2
- package/dist/types/scalar.mjs +7 -4
- package/dist/utils/graphology/index.d.mts +2 -1864
- package/dist/utils/graphology/index.mjs +3 -1
- package/dist/utils/index.d.mts +11 -124
- package/dist/utils/index.mjs +16 -43
- package/dist/utils/iterable/index.d.mts +9 -132
- package/dist/utils/iterable/index.mjs +2 -61
- package/dist/utils/mnemonist.d.mts +2 -0
- package/dist/utils/mnemonist.mjs +12 -0
- package/package.json +17 -22
- package/compute-view/relationships/package.json +0 -4
- package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
- package/dist/shared/core.78IWAHAE.mjs +0 -332
- package/dist/shared/core.B85MJLTf.mjs +0 -5
- package/dist/shared/core.BFd1lU9R.mjs +0 -29
- package/dist/shared/core.BKlholso.mjs +0 -3
- package/dist/shared/core.BNN-3vPH.mjs +0 -1255
- package/dist/shared/core.BPGOjone.d.mts +0 -46
- package/dist/shared/core.BP_QHEXs.mjs +0 -785
- package/dist/shared/core.BbE4y-yl.mjs +0 -177
- package/dist/shared/core.Bdy3hhTc.mjs +0 -28382
- package/dist/shared/core.BfCKSW-g.d.mts +0 -1266
- package/dist/shared/core.BhNcrwzK.mjs +0 -7
- package/dist/shared/core.BkVA6gjl.mjs +0 -5
- package/dist/shared/core.BoYfZOBm.mjs +0 -3
- package/dist/shared/core.BsSXS-_R.mjs +0 -7
- package/dist/shared/core.C3JowhaZ.mjs +0 -32
- package/dist/shared/core.C4x8aaWa.mjs +0 -27
- package/dist/shared/core.CAgYpDtM.d.mts +0 -98
- package/dist/shared/core.CHf8VEa3.mjs +0 -1206
- package/dist/shared/core.CLSZtnFh.mjs +0 -69
- package/dist/shared/core.CbT8JVYL.mjs +0 -5
- package/dist/shared/core.CdNCAwq7.mjs +0 -176
- package/dist/shared/core.CmGY9blO.mjs +0 -6717
- package/dist/shared/core.CmPXpJ8l.mjs +0 -21
- package/dist/shared/core.Coi_LOUZ.mjs +0 -7
- package/dist/shared/core.CqAJJpK_.mjs +0 -3
- package/dist/shared/core.CywrQs86.d.mts +0 -31
- package/dist/shared/core.D00YbOhQ.d.mts +0 -300
- package/dist/shared/core.D0WZutNd.mjs +0 -94
- package/dist/shared/core.D4npX2q8.mjs +0 -18
- package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
- package/dist/shared/core.DC5IAaDT.d.mts +0 -334
- package/dist/shared/core.DE9qzhn8.d.mts +0 -83
- package/dist/shared/core.DGcIbsj4.mjs +0 -3946
- package/dist/shared/core.DH7TXqXf.mjs +0 -136
- package/dist/shared/core.DKhRkHRN.d.mts +0 -41
- package/dist/shared/core.DRJma0Ol.mjs +0 -22
- package/dist/shared/core.DU5SRqNF.mjs +0 -2209
- package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
- package/dist/shared/core.DbfO90vF.mjs +0 -434
- package/dist/shared/core.DcS-0zys.mjs +0 -10
- package/dist/shared/core.Dh119QSP.mjs +0 -4995
- package/dist/shared/core.DjcWextK.mjs +0 -1371
- package/dist/shared/core.Dojz4bvg.d.mts +0 -504
- package/dist/shared/core.FZ305VYd.mjs +0 -21
- package/dist/shared/core.RfnaEmgA.mjs +0 -7
- package/dist/shared/core.btEq3i3f.mjs +0 -300
- package/dist/shared/core.oSV6SRfk.mjs +0 -13
- package/dist/shared/core.om36dXXW.mjs +0 -41
- package/dist/shared/core.osFs8tU7.d.mts +0 -466
- package/dist/shared/core.q10OP9oJ.mjs +0 -5
- package/dist/shared/core.tpvDGvdC.d.mts +0 -87
- package/dist/shared/core.uFk_o9X6.mjs +0 -13
|
@@ -0,0 +1,1978 @@
|
|
|
1
|
+
import { r as __toESM, t as __commonJSMin } from "../rolldown-runtime.mjs";
|
|
2
|
+
import { a as require_iterator, i as require_typed_arrays, o as require_foreach, r as require_iterables } from "./graphology-dag.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/bi-map.js
|
|
5
|
+
var require_bi_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
|
+
/**
|
|
7
|
+
* Mnemonist BiMap
|
|
8
|
+
* ================
|
|
9
|
+
*
|
|
10
|
+
* JavaScript implementation of a BiMap.
|
|
11
|
+
*/
|
|
12
|
+
var forEach = require_foreach();
|
|
13
|
+
/**
|
|
14
|
+
* Inverse Map.
|
|
15
|
+
*
|
|
16
|
+
* @constructor
|
|
17
|
+
*/
|
|
18
|
+
function InverseMap(original) {
|
|
19
|
+
this.size = 0;
|
|
20
|
+
this.items = /* @__PURE__ */ new Map();
|
|
21
|
+
this.inverse = original;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* BiMap.
|
|
25
|
+
*
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
function BiMap() {
|
|
29
|
+
this.size = 0;
|
|
30
|
+
this.items = /* @__PURE__ */ new Map();
|
|
31
|
+
this.inverse = new InverseMap(this);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Method used to clear the map.
|
|
35
|
+
*
|
|
36
|
+
* @return {undefined}
|
|
37
|
+
*/
|
|
38
|
+
function clear() {
|
|
39
|
+
this.size = 0;
|
|
40
|
+
this.items.clear();
|
|
41
|
+
this.inverse.items.clear();
|
|
42
|
+
}
|
|
43
|
+
BiMap.prototype.clear = clear;
|
|
44
|
+
InverseMap.prototype.clear = clear;
|
|
45
|
+
/**
|
|
46
|
+
* Method used to set a relation.
|
|
47
|
+
*
|
|
48
|
+
* @param {any} key - Key.
|
|
49
|
+
* @param {any} value - Value.
|
|
50
|
+
* @return {BiMap|InverseMap}
|
|
51
|
+
*/
|
|
52
|
+
function set(key, value) {
|
|
53
|
+
if (this.items.has(key)) {
|
|
54
|
+
var currentValue = this.items.get(key);
|
|
55
|
+
if (currentValue === value) return this;
|
|
56
|
+
else this.inverse.items.delete(currentValue);
|
|
57
|
+
}
|
|
58
|
+
if (this.inverse.items.has(value)) {
|
|
59
|
+
var currentKey = this.inverse.items.get(value);
|
|
60
|
+
if (currentKey === key) return this;
|
|
61
|
+
else this.items.delete(currentKey);
|
|
62
|
+
}
|
|
63
|
+
this.items.set(key, value);
|
|
64
|
+
this.inverse.items.set(value, key);
|
|
65
|
+
this.size = this.items.size;
|
|
66
|
+
this.inverse.size = this.inverse.items.size;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
BiMap.prototype.set = set;
|
|
70
|
+
InverseMap.prototype.set = set;
|
|
71
|
+
/**
|
|
72
|
+
* Method used to delete a relation.
|
|
73
|
+
*
|
|
74
|
+
* @param {any} key - Key.
|
|
75
|
+
* @return {boolean}
|
|
76
|
+
*/
|
|
77
|
+
function del(key) {
|
|
78
|
+
if (this.items.has(key)) {
|
|
79
|
+
var currentValue = this.items.get(key);
|
|
80
|
+
this.items.delete(key);
|
|
81
|
+
this.inverse.items.delete(currentValue);
|
|
82
|
+
this.size = this.items.size;
|
|
83
|
+
this.inverse.size = this.inverse.items.size;
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
BiMap.prototype.delete = del;
|
|
89
|
+
InverseMap.prototype.delete = del;
|
|
90
|
+
[
|
|
91
|
+
"has",
|
|
92
|
+
"get",
|
|
93
|
+
"forEach",
|
|
94
|
+
"keys",
|
|
95
|
+
"values",
|
|
96
|
+
"entries"
|
|
97
|
+
].forEach(function(name) {
|
|
98
|
+
BiMap.prototype[name] = InverseMap.prototype[name] = function() {
|
|
99
|
+
return Map.prototype[name].apply(this.items, arguments);
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* Attaching the #.values method to Symbol.iterator if possible.
|
|
104
|
+
*/
|
|
105
|
+
if (typeof Symbol !== "undefined") {
|
|
106
|
+
BiMap.prototype[Symbol.iterator] = BiMap.prototype.entries;
|
|
107
|
+
InverseMap.prototype[Symbol.iterator] = InverseMap.prototype.entries;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Convenience known methods.
|
|
111
|
+
*/
|
|
112
|
+
BiMap.prototype.inspect = function() {
|
|
113
|
+
var dummy = {
|
|
114
|
+
left: this.items,
|
|
115
|
+
right: this.inverse.items
|
|
116
|
+
};
|
|
117
|
+
Object.defineProperty(dummy, "constructor", {
|
|
118
|
+
value: BiMap,
|
|
119
|
+
enumerable: false
|
|
120
|
+
});
|
|
121
|
+
return dummy;
|
|
122
|
+
};
|
|
123
|
+
if (typeof Symbol !== "undefined") BiMap.prototype[Symbol.for("nodejs.util.inspect.custom")] = BiMap.prototype.inspect;
|
|
124
|
+
InverseMap.prototype.inspect = function() {
|
|
125
|
+
var dummy = {
|
|
126
|
+
left: this.inverse.items,
|
|
127
|
+
right: this.items
|
|
128
|
+
};
|
|
129
|
+
Object.defineProperty(dummy, "constructor", {
|
|
130
|
+
value: InverseMap,
|
|
131
|
+
enumerable: false
|
|
132
|
+
});
|
|
133
|
+
return dummy;
|
|
134
|
+
};
|
|
135
|
+
if (typeof Symbol !== "undefined") InverseMap.prototype[Symbol.for("nodejs.util.inspect.custom")] = InverseMap.prototype.inspect;
|
|
136
|
+
/**
|
|
137
|
+
* Static @.from function taking an arbitrary iterable & converting it into
|
|
138
|
+
* a bimap.
|
|
139
|
+
*
|
|
140
|
+
* @param {Iterable} iterable - Target iterable.
|
|
141
|
+
* @return {BiMap}
|
|
142
|
+
*/
|
|
143
|
+
BiMap.from = function(iterable) {
|
|
144
|
+
var bimap = new BiMap();
|
|
145
|
+
forEach(iterable, function(value, key) {
|
|
146
|
+
bimap.set(key, value);
|
|
147
|
+
});
|
|
148
|
+
return bimap;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Exporting.
|
|
152
|
+
*/
|
|
153
|
+
module.exports = BiMap;
|
|
154
|
+
}));
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/default-map.js
|
|
158
|
+
var require_default_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
159
|
+
/**
|
|
160
|
+
* Mnemonist DefaultMap
|
|
161
|
+
* =====================
|
|
162
|
+
*
|
|
163
|
+
* JavaScript implementation of a default map that will return a constructed
|
|
164
|
+
* value any time one tries to access an inexisting key. It's quite similar
|
|
165
|
+
* to python's defaultdict.
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* DefaultMap.
|
|
169
|
+
*
|
|
170
|
+
* @constructor
|
|
171
|
+
*/
|
|
172
|
+
function DefaultMap(factory) {
|
|
173
|
+
if (typeof factory !== "function") throw new Error("mnemonist/DefaultMap.constructor: expecting a function.");
|
|
174
|
+
this.items = /* @__PURE__ */ new Map();
|
|
175
|
+
this.factory = factory;
|
|
176
|
+
this.size = 0;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Method used to clear the structure.
|
|
180
|
+
*
|
|
181
|
+
* @return {undefined}
|
|
182
|
+
*/
|
|
183
|
+
DefaultMap.prototype.clear = function() {
|
|
184
|
+
this.items.clear();
|
|
185
|
+
this.size = 0;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Method used to get the value set for given key. If the key does not exist,
|
|
189
|
+
* the value will be created using the provided factory.
|
|
190
|
+
*
|
|
191
|
+
* @param {any} key - Target key.
|
|
192
|
+
* @return {any}
|
|
193
|
+
*/
|
|
194
|
+
DefaultMap.prototype.get = function(key) {
|
|
195
|
+
var value = this.items.get(key);
|
|
196
|
+
if (typeof value === "undefined") {
|
|
197
|
+
value = this.factory(key, this.size);
|
|
198
|
+
this.items.set(key, value);
|
|
199
|
+
this.size++;
|
|
200
|
+
}
|
|
201
|
+
return value;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Method used to get the value set for given key. If the key does not exist,
|
|
205
|
+
* a value won't be created.
|
|
206
|
+
*
|
|
207
|
+
* @param {any} key - Target key.
|
|
208
|
+
* @return {any}
|
|
209
|
+
*/
|
|
210
|
+
DefaultMap.prototype.peek = function(key) {
|
|
211
|
+
return this.items.get(key);
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Method used to set a value for given key.
|
|
215
|
+
*
|
|
216
|
+
* @param {any} key - Target key.
|
|
217
|
+
* @param {any} value - Value.
|
|
218
|
+
* @return {DefaultMap}
|
|
219
|
+
*/
|
|
220
|
+
DefaultMap.prototype.set = function(key, value) {
|
|
221
|
+
this.items.set(key, value);
|
|
222
|
+
this.size = this.items.size;
|
|
223
|
+
return this;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Method used to test the existence of a key in the map.
|
|
227
|
+
*
|
|
228
|
+
* @param {any} key - Target key.
|
|
229
|
+
* @return {boolean}
|
|
230
|
+
*/
|
|
231
|
+
DefaultMap.prototype.has = function(key) {
|
|
232
|
+
return this.items.has(key);
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Method used to delete target key.
|
|
236
|
+
*
|
|
237
|
+
* @param {any} key - Target key.
|
|
238
|
+
* @return {boolean}
|
|
239
|
+
*/
|
|
240
|
+
DefaultMap.prototype.delete = function(key) {
|
|
241
|
+
var deleted = this.items.delete(key);
|
|
242
|
+
this.size = this.items.size;
|
|
243
|
+
return deleted;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Method used to iterate over each of the key/value pairs.
|
|
247
|
+
*
|
|
248
|
+
* @param {function} callback - Function to call for each item.
|
|
249
|
+
* @param {object} scope - Optional scope.
|
|
250
|
+
* @return {undefined}
|
|
251
|
+
*/
|
|
252
|
+
DefaultMap.prototype.forEach = function(callback, scope) {
|
|
253
|
+
scope = arguments.length > 1 ? scope : this;
|
|
254
|
+
this.items.forEach(callback, scope);
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Iterators.
|
|
258
|
+
*/
|
|
259
|
+
DefaultMap.prototype.entries = function() {
|
|
260
|
+
return this.items.entries();
|
|
261
|
+
};
|
|
262
|
+
DefaultMap.prototype.keys = function() {
|
|
263
|
+
return this.items.keys();
|
|
264
|
+
};
|
|
265
|
+
DefaultMap.prototype.values = function() {
|
|
266
|
+
return this.items.values();
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Attaching the #.entries method to Symbol.iterator if possible.
|
|
270
|
+
*/
|
|
271
|
+
if (typeof Symbol !== "undefined") DefaultMap.prototype[Symbol.iterator] = DefaultMap.prototype.entries;
|
|
272
|
+
/**
|
|
273
|
+
* Convenience known methods.
|
|
274
|
+
*/
|
|
275
|
+
DefaultMap.prototype.inspect = function() {
|
|
276
|
+
return this.items;
|
|
277
|
+
};
|
|
278
|
+
if (typeof Symbol !== "undefined") DefaultMap.prototype[Symbol.for("nodejs.util.inspect.custom")] = DefaultMap.prototype.inspect;
|
|
279
|
+
/**
|
|
280
|
+
* Typical factories.
|
|
281
|
+
*/
|
|
282
|
+
DefaultMap.autoIncrement = function() {
|
|
283
|
+
var i = 0;
|
|
284
|
+
return function() {
|
|
285
|
+
return i++;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Exporting.
|
|
290
|
+
*/
|
|
291
|
+
module.exports = DefaultMap;
|
|
292
|
+
}));
|
|
293
|
+
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/default-weak-map.js
|
|
296
|
+
var require_default_weak_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
297
|
+
/**
|
|
298
|
+
* Mnemonist DefaultWeakMap
|
|
299
|
+
* =========================
|
|
300
|
+
*
|
|
301
|
+
* JavaScript implementation of a default weak map that will return a constructed
|
|
302
|
+
* value any time one tries to access an non-existing key. It is similar to
|
|
303
|
+
* DefaultMap but uses ES6 WeakMap that only holds weak reference to keys.
|
|
304
|
+
*/
|
|
305
|
+
/**
|
|
306
|
+
* DefaultWeakMap.
|
|
307
|
+
*
|
|
308
|
+
* @constructor
|
|
309
|
+
*/
|
|
310
|
+
function DefaultWeakMap(factory) {
|
|
311
|
+
if (typeof factory !== "function") throw new Error("mnemonist/DefaultWeakMap.constructor: expecting a function.");
|
|
312
|
+
this.items = /* @__PURE__ */ new WeakMap();
|
|
313
|
+
this.factory = factory;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Method used to clear the structure.
|
|
317
|
+
*
|
|
318
|
+
* @return {undefined}
|
|
319
|
+
*/
|
|
320
|
+
DefaultWeakMap.prototype.clear = function() {
|
|
321
|
+
this.items = /* @__PURE__ */ new WeakMap();
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Method used to get the value set for given key. If the key does not exist,
|
|
325
|
+
* the value will be created using the provided factory.
|
|
326
|
+
*
|
|
327
|
+
* @param {any} key - Target key.
|
|
328
|
+
* @return {any}
|
|
329
|
+
*/
|
|
330
|
+
DefaultWeakMap.prototype.get = function(key) {
|
|
331
|
+
var value = this.items.get(key);
|
|
332
|
+
if (typeof value === "undefined") {
|
|
333
|
+
value = this.factory(key);
|
|
334
|
+
this.items.set(key, value);
|
|
335
|
+
}
|
|
336
|
+
return value;
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Method used to get the value set for given key. If the key does not exist,
|
|
340
|
+
* a value won't be created.
|
|
341
|
+
*
|
|
342
|
+
* @param {any} key - Target key.
|
|
343
|
+
* @return {any}
|
|
344
|
+
*/
|
|
345
|
+
DefaultWeakMap.prototype.peek = function(key) {
|
|
346
|
+
return this.items.get(key);
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Method used to set a value for given key.
|
|
350
|
+
*
|
|
351
|
+
* @param {any} key - Target key.
|
|
352
|
+
* @param {any} value - Value.
|
|
353
|
+
* @return {DefaultMap}
|
|
354
|
+
*/
|
|
355
|
+
DefaultWeakMap.prototype.set = function(key, value) {
|
|
356
|
+
this.items.set(key, value);
|
|
357
|
+
return this;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Method used to test the existence of a key in the map.
|
|
361
|
+
*
|
|
362
|
+
* @param {any} key - Target key.
|
|
363
|
+
* @return {boolean}
|
|
364
|
+
*/
|
|
365
|
+
DefaultWeakMap.prototype.has = function(key) {
|
|
366
|
+
return this.items.has(key);
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Method used to delete target key.
|
|
370
|
+
*
|
|
371
|
+
* @param {any} key - Target key.
|
|
372
|
+
* @return {boolean}
|
|
373
|
+
*/
|
|
374
|
+
DefaultWeakMap.prototype.delete = function(key) {
|
|
375
|
+
return this.items.delete(key);
|
|
376
|
+
};
|
|
377
|
+
/**
|
|
378
|
+
* Convenience known methods.
|
|
379
|
+
*/
|
|
380
|
+
DefaultWeakMap.prototype.inspect = function() {
|
|
381
|
+
return this.items;
|
|
382
|
+
};
|
|
383
|
+
if (typeof Symbol !== "undefined") DefaultWeakMap.prototype[Symbol.for("nodejs.util.inspect.custom")] = DefaultWeakMap.prototype.inspect;
|
|
384
|
+
/**
|
|
385
|
+
* Exporting.
|
|
386
|
+
*/
|
|
387
|
+
module.exports = DefaultWeakMap;
|
|
388
|
+
}));
|
|
389
|
+
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/linked-list.js
|
|
392
|
+
var require_linked_list = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
393
|
+
/**
|
|
394
|
+
* Mnemonist Linked List
|
|
395
|
+
* ======================
|
|
396
|
+
*
|
|
397
|
+
* Singly linked list implementation. Uses raw JavaScript objects as nodes
|
|
398
|
+
* as benchmarks proved it was the fastest thing to do.
|
|
399
|
+
*/
|
|
400
|
+
var Iterator = require_iterator(), forEach = require_foreach();
|
|
401
|
+
/**
|
|
402
|
+
* Linked List.
|
|
403
|
+
*
|
|
404
|
+
* @constructor
|
|
405
|
+
*/
|
|
406
|
+
function LinkedList() {
|
|
407
|
+
this.clear();
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Method used to clear the list.
|
|
411
|
+
*
|
|
412
|
+
* @return {undefined}
|
|
413
|
+
*/
|
|
414
|
+
LinkedList.prototype.clear = function() {
|
|
415
|
+
this.head = null;
|
|
416
|
+
this.tail = null;
|
|
417
|
+
this.size = 0;
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* Method used to get the first item of the list.
|
|
421
|
+
*
|
|
422
|
+
* @return {any}
|
|
423
|
+
*/
|
|
424
|
+
LinkedList.prototype.first = function() {
|
|
425
|
+
return this.head ? this.head.item : void 0;
|
|
426
|
+
};
|
|
427
|
+
LinkedList.prototype.peek = LinkedList.prototype.first;
|
|
428
|
+
/**
|
|
429
|
+
* Method used to get the last item of the list.
|
|
430
|
+
*
|
|
431
|
+
* @return {any}
|
|
432
|
+
*/
|
|
433
|
+
LinkedList.prototype.last = function() {
|
|
434
|
+
return this.tail ? this.tail.item : void 0;
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* Method used to add an item at the end of the list.
|
|
438
|
+
*
|
|
439
|
+
* @param {any} item - The item to add.
|
|
440
|
+
* @return {number}
|
|
441
|
+
*/
|
|
442
|
+
LinkedList.prototype.push = function(item) {
|
|
443
|
+
var node = {
|
|
444
|
+
item,
|
|
445
|
+
next: null
|
|
446
|
+
};
|
|
447
|
+
if (!this.head) {
|
|
448
|
+
this.head = node;
|
|
449
|
+
this.tail = node;
|
|
450
|
+
} else {
|
|
451
|
+
this.tail.next = node;
|
|
452
|
+
this.tail = node;
|
|
453
|
+
}
|
|
454
|
+
this.size++;
|
|
455
|
+
return this.size;
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Method used to add an item at the beginning of the list.
|
|
459
|
+
*
|
|
460
|
+
* @param {any} item - The item to add.
|
|
461
|
+
* @return {number}
|
|
462
|
+
*/
|
|
463
|
+
LinkedList.prototype.unshift = function(item) {
|
|
464
|
+
var node = {
|
|
465
|
+
item,
|
|
466
|
+
next: null
|
|
467
|
+
};
|
|
468
|
+
if (!this.head) {
|
|
469
|
+
this.head = node;
|
|
470
|
+
this.tail = node;
|
|
471
|
+
} else {
|
|
472
|
+
if (!this.head.next) this.tail = this.head;
|
|
473
|
+
node.next = this.head;
|
|
474
|
+
this.head = node;
|
|
475
|
+
}
|
|
476
|
+
this.size++;
|
|
477
|
+
return this.size;
|
|
478
|
+
};
|
|
479
|
+
/**
|
|
480
|
+
* Method used to retrieve & remove the first item of the list.
|
|
481
|
+
*
|
|
482
|
+
* @return {any}
|
|
483
|
+
*/
|
|
484
|
+
LinkedList.prototype.shift = function() {
|
|
485
|
+
if (!this.size) return void 0;
|
|
486
|
+
var node = this.head;
|
|
487
|
+
this.head = node.next;
|
|
488
|
+
this.size--;
|
|
489
|
+
return node.item;
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Method used to iterate over the list.
|
|
493
|
+
*
|
|
494
|
+
* @param {function} callback - Function to call for each item.
|
|
495
|
+
* @param {object} scope - Optional scope.
|
|
496
|
+
* @return {undefined}
|
|
497
|
+
*/
|
|
498
|
+
LinkedList.prototype.forEach = function(callback, scope) {
|
|
499
|
+
if (!this.size) return;
|
|
500
|
+
scope = arguments.length > 1 ? scope : this;
|
|
501
|
+
var n = this.head, i = 0;
|
|
502
|
+
while (n) {
|
|
503
|
+
callback.call(scope, n.item, i, this);
|
|
504
|
+
n = n.next;
|
|
505
|
+
i++;
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Method used to convert the list into an array.
|
|
510
|
+
*
|
|
511
|
+
* @return {array}
|
|
512
|
+
*/
|
|
513
|
+
LinkedList.prototype.toArray = function() {
|
|
514
|
+
if (!this.size) return [];
|
|
515
|
+
var array = new Array(this.size);
|
|
516
|
+
for (var i = 0, l = this.size, n = this.head; i < l; i++) {
|
|
517
|
+
array[i] = n.item;
|
|
518
|
+
n = n.next;
|
|
519
|
+
}
|
|
520
|
+
return array;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Method used to create an iterator over a list's values.
|
|
524
|
+
*
|
|
525
|
+
* @return {Iterator}
|
|
526
|
+
*/
|
|
527
|
+
LinkedList.prototype.values = function() {
|
|
528
|
+
var n = this.head;
|
|
529
|
+
return new Iterator(function() {
|
|
530
|
+
if (!n) return { done: true };
|
|
531
|
+
var value = n.item;
|
|
532
|
+
n = n.next;
|
|
533
|
+
return {
|
|
534
|
+
value,
|
|
535
|
+
done: false
|
|
536
|
+
};
|
|
537
|
+
});
|
|
538
|
+
};
|
|
539
|
+
/**
|
|
540
|
+
* Method used to create an iterator over a list's entries.
|
|
541
|
+
*
|
|
542
|
+
* @return {Iterator}
|
|
543
|
+
*/
|
|
544
|
+
LinkedList.prototype.entries = function() {
|
|
545
|
+
var n = this.head, i = 0;
|
|
546
|
+
return new Iterator(function() {
|
|
547
|
+
if (!n) return { done: true };
|
|
548
|
+
var value = n.item;
|
|
549
|
+
n = n.next;
|
|
550
|
+
i++;
|
|
551
|
+
return {
|
|
552
|
+
value: [i - 1, value],
|
|
553
|
+
done: false
|
|
554
|
+
};
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* Attaching the #.values method to Symbol.iterator if possible.
|
|
559
|
+
*/
|
|
560
|
+
if (typeof Symbol !== "undefined") LinkedList.prototype[Symbol.iterator] = LinkedList.prototype.values;
|
|
561
|
+
/**
|
|
562
|
+
* Convenience known methods.
|
|
563
|
+
*/
|
|
564
|
+
LinkedList.prototype.toString = function() {
|
|
565
|
+
return this.toArray().join(",");
|
|
566
|
+
};
|
|
567
|
+
LinkedList.prototype.toJSON = function() {
|
|
568
|
+
return this.toArray();
|
|
569
|
+
};
|
|
570
|
+
LinkedList.prototype.inspect = function() {
|
|
571
|
+
var array = this.toArray();
|
|
572
|
+
Object.defineProperty(array, "constructor", {
|
|
573
|
+
value: LinkedList,
|
|
574
|
+
enumerable: false
|
|
575
|
+
});
|
|
576
|
+
return array;
|
|
577
|
+
};
|
|
578
|
+
if (typeof Symbol !== "undefined") LinkedList.prototype[Symbol.for("nodejs.util.inspect.custom")] = LinkedList.prototype.inspect;
|
|
579
|
+
/**
|
|
580
|
+
* Static @.from function taking an arbitrary iterable & converting it into
|
|
581
|
+
* a list.
|
|
582
|
+
*
|
|
583
|
+
* @param {Iterable} iterable - Target iterable.
|
|
584
|
+
* @return {LinkedList}
|
|
585
|
+
*/
|
|
586
|
+
LinkedList.from = function(iterable) {
|
|
587
|
+
var list = new LinkedList();
|
|
588
|
+
forEach(iterable, function(value) {
|
|
589
|
+
list.push(value);
|
|
590
|
+
});
|
|
591
|
+
return list;
|
|
592
|
+
};
|
|
593
|
+
/**
|
|
594
|
+
* Exporting.
|
|
595
|
+
*/
|
|
596
|
+
module.exports = LinkedList;
|
|
597
|
+
}));
|
|
598
|
+
|
|
599
|
+
//#endregion
|
|
600
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/multi-map.js
|
|
601
|
+
var require_multi_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
602
|
+
/**
|
|
603
|
+
* Mnemonist MultiMap
|
|
604
|
+
* ===================
|
|
605
|
+
*
|
|
606
|
+
* Implementation of a MultiMap with custom container.
|
|
607
|
+
*/
|
|
608
|
+
var Iterator = require_iterator(), forEach = require_foreach();
|
|
609
|
+
/**
|
|
610
|
+
* MultiMap.
|
|
611
|
+
*
|
|
612
|
+
* @constructor
|
|
613
|
+
*/
|
|
614
|
+
function MultiMap(Container) {
|
|
615
|
+
this.Container = Container || Array;
|
|
616
|
+
this.items = /* @__PURE__ */ new Map();
|
|
617
|
+
this.clear();
|
|
618
|
+
Object.defineProperty(this.items, "constructor", {
|
|
619
|
+
value: MultiMap,
|
|
620
|
+
enumerable: false
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Method used to clear the structure.
|
|
625
|
+
*
|
|
626
|
+
* @return {undefined}
|
|
627
|
+
*/
|
|
628
|
+
MultiMap.prototype.clear = function() {
|
|
629
|
+
this.size = 0;
|
|
630
|
+
this.dimension = 0;
|
|
631
|
+
this.items.clear();
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* Method used to set a value.
|
|
635
|
+
*
|
|
636
|
+
* @param {any} key - Key.
|
|
637
|
+
* @param {any} value - Value to add.
|
|
638
|
+
* @return {MultiMap}
|
|
639
|
+
*/
|
|
640
|
+
MultiMap.prototype.set = function(key, value) {
|
|
641
|
+
var container = this.items.get(key), sizeBefore;
|
|
642
|
+
if (!container) {
|
|
643
|
+
this.dimension++;
|
|
644
|
+
container = new this.Container();
|
|
645
|
+
this.items.set(key, container);
|
|
646
|
+
}
|
|
647
|
+
if (this.Container === Set) {
|
|
648
|
+
sizeBefore = container.size;
|
|
649
|
+
container.add(value);
|
|
650
|
+
if (sizeBefore < container.size) this.size++;
|
|
651
|
+
} else {
|
|
652
|
+
container.push(value);
|
|
653
|
+
this.size++;
|
|
654
|
+
}
|
|
655
|
+
return this;
|
|
656
|
+
};
|
|
657
|
+
/**
|
|
658
|
+
* Method used to delete the given key.
|
|
659
|
+
*
|
|
660
|
+
* @param {any} key - Key to delete.
|
|
661
|
+
* @return {boolean}
|
|
662
|
+
*/
|
|
663
|
+
MultiMap.prototype.delete = function(key) {
|
|
664
|
+
var container = this.items.get(key);
|
|
665
|
+
if (!container) return false;
|
|
666
|
+
this.size -= this.Container === Set ? container.size : container.length;
|
|
667
|
+
this.dimension--;
|
|
668
|
+
this.items.delete(key);
|
|
669
|
+
return true;
|
|
670
|
+
};
|
|
671
|
+
/**
|
|
672
|
+
* Method used to delete the remove an item in the container stored at the
|
|
673
|
+
* given key.
|
|
674
|
+
*
|
|
675
|
+
* @param {any} key - Key to delete.
|
|
676
|
+
* @return {boolean}
|
|
677
|
+
*/
|
|
678
|
+
MultiMap.prototype.remove = function(key, value) {
|
|
679
|
+
var container = this.items.get(key), wasDeleted, index;
|
|
680
|
+
if (!container) return false;
|
|
681
|
+
if (this.Container === Set) {
|
|
682
|
+
wasDeleted = container.delete(value);
|
|
683
|
+
if (wasDeleted) this.size--;
|
|
684
|
+
if (container.size === 0) {
|
|
685
|
+
this.items.delete(key);
|
|
686
|
+
this.dimension--;
|
|
687
|
+
}
|
|
688
|
+
return wasDeleted;
|
|
689
|
+
} else {
|
|
690
|
+
index = container.indexOf(value);
|
|
691
|
+
if (index === -1) return false;
|
|
692
|
+
this.size--;
|
|
693
|
+
if (container.length === 1) {
|
|
694
|
+
this.items.delete(key);
|
|
695
|
+
this.dimension--;
|
|
696
|
+
return true;
|
|
697
|
+
}
|
|
698
|
+
container.splice(index, 1);
|
|
699
|
+
return true;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* Method used to return whether the given keys exists in the map.
|
|
704
|
+
*
|
|
705
|
+
* @param {any} key - Key to check.
|
|
706
|
+
* @return {boolean}
|
|
707
|
+
*/
|
|
708
|
+
MultiMap.prototype.has = function(key) {
|
|
709
|
+
return this.items.has(key);
|
|
710
|
+
};
|
|
711
|
+
/**
|
|
712
|
+
* Method used to return the container stored at the given key or `undefined`.
|
|
713
|
+
*
|
|
714
|
+
* @param {any} key - Key to get.
|
|
715
|
+
* @return {boolean}
|
|
716
|
+
*/
|
|
717
|
+
MultiMap.prototype.get = function(key) {
|
|
718
|
+
return this.items.get(key);
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Method used to return the multiplicity of the given key, meaning the number
|
|
722
|
+
* of times it is set, or, more trivially, the size of the attached container.
|
|
723
|
+
*
|
|
724
|
+
* @param {any} key - Key to check.
|
|
725
|
+
* @return {number}
|
|
726
|
+
*/
|
|
727
|
+
MultiMap.prototype.multiplicity = function(key) {
|
|
728
|
+
var container = this.items.get(key);
|
|
729
|
+
if (typeof container === "undefined") return 0;
|
|
730
|
+
return this.Container === Set ? container.size : container.length;
|
|
731
|
+
};
|
|
732
|
+
MultiMap.prototype.count = MultiMap.prototype.multiplicity;
|
|
733
|
+
/**
|
|
734
|
+
* Method used to iterate over each of the key/value pairs.
|
|
735
|
+
*
|
|
736
|
+
* @param {function} callback - Function to call for each item.
|
|
737
|
+
* @param {object} scope - Optional scope.
|
|
738
|
+
* @return {undefined}
|
|
739
|
+
*/
|
|
740
|
+
MultiMap.prototype.forEach = function(callback, scope) {
|
|
741
|
+
scope = arguments.length > 1 ? scope : this;
|
|
742
|
+
var key;
|
|
743
|
+
function inner(value) {
|
|
744
|
+
callback.call(scope, value, key);
|
|
745
|
+
}
|
|
746
|
+
this.items.forEach(function(container, k) {
|
|
747
|
+
key = k;
|
|
748
|
+
container.forEach(inner);
|
|
749
|
+
});
|
|
750
|
+
};
|
|
751
|
+
/**
|
|
752
|
+
* Method used to iterate over each of the associations.
|
|
753
|
+
*
|
|
754
|
+
* @param {function} callback - Function to call for each item.
|
|
755
|
+
* @param {object} scope - Optional scope.
|
|
756
|
+
* @return {undefined}
|
|
757
|
+
*/
|
|
758
|
+
MultiMap.prototype.forEachAssociation = function(callback, scope) {
|
|
759
|
+
scope = arguments.length > 1 ? scope : this;
|
|
760
|
+
this.items.forEach(callback, scope);
|
|
761
|
+
};
|
|
762
|
+
/**
|
|
763
|
+
* Method returning an iterator over the map's keys.
|
|
764
|
+
*
|
|
765
|
+
* @return {Iterator}
|
|
766
|
+
*/
|
|
767
|
+
MultiMap.prototype.keys = function() {
|
|
768
|
+
return this.items.keys();
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* Method returning an iterator over the map's keys.
|
|
772
|
+
*
|
|
773
|
+
* @return {Iterator}
|
|
774
|
+
*/
|
|
775
|
+
MultiMap.prototype.values = function() {
|
|
776
|
+
var iterator = this.items.values(), inContainer = false, countainer, step, i, l;
|
|
777
|
+
if (this.Container === Set) return new Iterator(function next() {
|
|
778
|
+
if (!inContainer) {
|
|
779
|
+
step = iterator.next();
|
|
780
|
+
if (step.done) return { done: true };
|
|
781
|
+
inContainer = true;
|
|
782
|
+
countainer = step.value.values();
|
|
783
|
+
}
|
|
784
|
+
step = countainer.next();
|
|
785
|
+
if (step.done) {
|
|
786
|
+
inContainer = false;
|
|
787
|
+
return next();
|
|
788
|
+
}
|
|
789
|
+
return {
|
|
790
|
+
done: false,
|
|
791
|
+
value: step.value
|
|
792
|
+
};
|
|
793
|
+
});
|
|
794
|
+
return new Iterator(function next() {
|
|
795
|
+
if (!inContainer) {
|
|
796
|
+
step = iterator.next();
|
|
797
|
+
if (step.done) return { done: true };
|
|
798
|
+
inContainer = true;
|
|
799
|
+
countainer = step.value;
|
|
800
|
+
i = 0;
|
|
801
|
+
l = countainer.length;
|
|
802
|
+
}
|
|
803
|
+
if (i >= l) {
|
|
804
|
+
inContainer = false;
|
|
805
|
+
return next();
|
|
806
|
+
}
|
|
807
|
+
return {
|
|
808
|
+
done: false,
|
|
809
|
+
value: countainer[i++]
|
|
810
|
+
};
|
|
811
|
+
});
|
|
812
|
+
};
|
|
813
|
+
/**
|
|
814
|
+
* Method returning an iterator over the map's entries.
|
|
815
|
+
*
|
|
816
|
+
* @return {Iterator}
|
|
817
|
+
*/
|
|
818
|
+
MultiMap.prototype.entries = function() {
|
|
819
|
+
var iterator = this.items.entries(), inContainer = false, countainer, step, key, i, l;
|
|
820
|
+
if (this.Container === Set) return new Iterator(function next() {
|
|
821
|
+
if (!inContainer) {
|
|
822
|
+
step = iterator.next();
|
|
823
|
+
if (step.done) return { done: true };
|
|
824
|
+
inContainer = true;
|
|
825
|
+
key = step.value[0];
|
|
826
|
+
countainer = step.value[1].values();
|
|
827
|
+
}
|
|
828
|
+
step = countainer.next();
|
|
829
|
+
if (step.done) {
|
|
830
|
+
inContainer = false;
|
|
831
|
+
return next();
|
|
832
|
+
}
|
|
833
|
+
return {
|
|
834
|
+
done: false,
|
|
835
|
+
value: [key, step.value]
|
|
836
|
+
};
|
|
837
|
+
});
|
|
838
|
+
return new Iterator(function next() {
|
|
839
|
+
if (!inContainer) {
|
|
840
|
+
step = iterator.next();
|
|
841
|
+
if (step.done) return { done: true };
|
|
842
|
+
inContainer = true;
|
|
843
|
+
key = step.value[0];
|
|
844
|
+
countainer = step.value[1];
|
|
845
|
+
i = 0;
|
|
846
|
+
l = countainer.length;
|
|
847
|
+
}
|
|
848
|
+
if (i >= l) {
|
|
849
|
+
inContainer = false;
|
|
850
|
+
return next();
|
|
851
|
+
}
|
|
852
|
+
return {
|
|
853
|
+
done: false,
|
|
854
|
+
value: [key, countainer[i++]]
|
|
855
|
+
};
|
|
856
|
+
});
|
|
857
|
+
};
|
|
858
|
+
/**
|
|
859
|
+
* Method returning an iterator over the map's containers.
|
|
860
|
+
*
|
|
861
|
+
* @return {Iterator}
|
|
862
|
+
*/
|
|
863
|
+
MultiMap.prototype.containers = function() {
|
|
864
|
+
return this.items.values();
|
|
865
|
+
};
|
|
866
|
+
/**
|
|
867
|
+
* Method returning an iterator over the map's associations.
|
|
868
|
+
*
|
|
869
|
+
* @return {Iterator}
|
|
870
|
+
*/
|
|
871
|
+
MultiMap.prototype.associations = function() {
|
|
872
|
+
return this.items.entries();
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* Attaching the #.entries method to Symbol.iterator if possible.
|
|
876
|
+
*/
|
|
877
|
+
if (typeof Symbol !== "undefined") MultiMap.prototype[Symbol.iterator] = MultiMap.prototype.entries;
|
|
878
|
+
/**
|
|
879
|
+
* Convenience known methods.
|
|
880
|
+
*/
|
|
881
|
+
MultiMap.prototype.inspect = function() {
|
|
882
|
+
return this.items;
|
|
883
|
+
};
|
|
884
|
+
if (typeof Symbol !== "undefined") MultiMap.prototype[Symbol.for("nodejs.util.inspect.custom")] = MultiMap.prototype.inspect;
|
|
885
|
+
MultiMap.prototype.toJSON = function() {
|
|
886
|
+
return this.items;
|
|
887
|
+
};
|
|
888
|
+
/**
|
|
889
|
+
* Static @.from function taking an arbitrary iterable & converting it into
|
|
890
|
+
* a structure.
|
|
891
|
+
*
|
|
892
|
+
* @param {Iterable} iterable - Target iterable.
|
|
893
|
+
* @param {Class} Container - Container.
|
|
894
|
+
* @return {MultiMap}
|
|
895
|
+
*/
|
|
896
|
+
MultiMap.from = function(iterable, Container) {
|
|
897
|
+
var map = new MultiMap(Container);
|
|
898
|
+
forEach(iterable, function(value, key) {
|
|
899
|
+
map.set(key, value);
|
|
900
|
+
});
|
|
901
|
+
return map;
|
|
902
|
+
};
|
|
903
|
+
/**
|
|
904
|
+
* Exporting.
|
|
905
|
+
*/
|
|
906
|
+
module.exports = MultiMap;
|
|
907
|
+
}));
|
|
908
|
+
|
|
909
|
+
//#endregion
|
|
910
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/queue.js
|
|
911
|
+
var require_queue = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
912
|
+
/**
|
|
913
|
+
* Mnemonist Queue
|
|
914
|
+
* ================
|
|
915
|
+
*
|
|
916
|
+
* Queue implementation based on the ideas of Queue.js that seems to beat
|
|
917
|
+
* a LinkedList one in performance.
|
|
918
|
+
*/
|
|
919
|
+
var Iterator = require_iterator(), forEach = require_foreach();
|
|
920
|
+
/**
|
|
921
|
+
* Queue
|
|
922
|
+
*
|
|
923
|
+
* @constructor
|
|
924
|
+
*/
|
|
925
|
+
function Queue() {
|
|
926
|
+
this.clear();
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Method used to clear the queue.
|
|
930
|
+
*
|
|
931
|
+
* @return {undefined}
|
|
932
|
+
*/
|
|
933
|
+
Queue.prototype.clear = function() {
|
|
934
|
+
this.items = [];
|
|
935
|
+
this.offset = 0;
|
|
936
|
+
this.size = 0;
|
|
937
|
+
};
|
|
938
|
+
/**
|
|
939
|
+
* Method used to add an item to the queue.
|
|
940
|
+
*
|
|
941
|
+
* @param {any} item - Item to enqueue.
|
|
942
|
+
* @return {number}
|
|
943
|
+
*/
|
|
944
|
+
Queue.prototype.enqueue = function(item) {
|
|
945
|
+
this.items.push(item);
|
|
946
|
+
return ++this.size;
|
|
947
|
+
};
|
|
948
|
+
/**
|
|
949
|
+
* Method used to retrieve & remove the first item of the queue.
|
|
950
|
+
*
|
|
951
|
+
* @return {any}
|
|
952
|
+
*/
|
|
953
|
+
Queue.prototype.dequeue = function() {
|
|
954
|
+
if (!this.size) return;
|
|
955
|
+
var item = this.items[this.offset];
|
|
956
|
+
if (++this.offset * 2 >= this.items.length) {
|
|
957
|
+
this.items = this.items.slice(this.offset);
|
|
958
|
+
this.offset = 0;
|
|
959
|
+
}
|
|
960
|
+
this.size--;
|
|
961
|
+
return item;
|
|
962
|
+
};
|
|
963
|
+
/**
|
|
964
|
+
* Method used to retrieve the first item of the queue.
|
|
965
|
+
*
|
|
966
|
+
* @return {any}
|
|
967
|
+
*/
|
|
968
|
+
Queue.prototype.peek = function() {
|
|
969
|
+
if (!this.size) return;
|
|
970
|
+
return this.items[this.offset];
|
|
971
|
+
};
|
|
972
|
+
/**
|
|
973
|
+
* Method used to iterate over the queue.
|
|
974
|
+
*
|
|
975
|
+
* @param {function} callback - Function to call for each item.
|
|
976
|
+
* @param {object} scope - Optional scope.
|
|
977
|
+
* @return {undefined}
|
|
978
|
+
*/
|
|
979
|
+
Queue.prototype.forEach = function(callback, scope) {
|
|
980
|
+
scope = arguments.length > 1 ? scope : this;
|
|
981
|
+
for (var i = this.offset, j = 0, l = this.items.length; i < l; i++, j++) callback.call(scope, this.items[i], j, this);
|
|
982
|
+
};
|
|
983
|
+
Queue.prototype.toArray = function() {
|
|
984
|
+
return this.items.slice(this.offset);
|
|
985
|
+
};
|
|
986
|
+
/**
|
|
987
|
+
* Method used to create an iterator over a queue's values.
|
|
988
|
+
*
|
|
989
|
+
* @return {Iterator}
|
|
990
|
+
*/
|
|
991
|
+
Queue.prototype.values = function() {
|
|
992
|
+
var items = this.items, i = this.offset;
|
|
993
|
+
return new Iterator(function() {
|
|
994
|
+
if (i >= items.length) return { done: true };
|
|
995
|
+
var value = items[i];
|
|
996
|
+
i++;
|
|
997
|
+
return {
|
|
998
|
+
value,
|
|
999
|
+
done: false
|
|
1000
|
+
};
|
|
1001
|
+
});
|
|
1002
|
+
};
|
|
1003
|
+
/**
|
|
1004
|
+
* Method used to create an iterator over a queue's entries.
|
|
1005
|
+
*
|
|
1006
|
+
* @return {Iterator}
|
|
1007
|
+
*/
|
|
1008
|
+
Queue.prototype.entries = function() {
|
|
1009
|
+
var items = this.items, i = this.offset, j = 0;
|
|
1010
|
+
return new Iterator(function() {
|
|
1011
|
+
if (i >= items.length) return { done: true };
|
|
1012
|
+
var value = items[i];
|
|
1013
|
+
i++;
|
|
1014
|
+
return {
|
|
1015
|
+
value: [j++, value],
|
|
1016
|
+
done: false
|
|
1017
|
+
};
|
|
1018
|
+
});
|
|
1019
|
+
};
|
|
1020
|
+
/**
|
|
1021
|
+
* Attaching the #.values method to Symbol.iterator if possible.
|
|
1022
|
+
*/
|
|
1023
|
+
if (typeof Symbol !== "undefined") Queue.prototype[Symbol.iterator] = Queue.prototype.values;
|
|
1024
|
+
/**
|
|
1025
|
+
* Convenience known methods.
|
|
1026
|
+
*/
|
|
1027
|
+
Queue.prototype.toString = function() {
|
|
1028
|
+
return this.toArray().join(",");
|
|
1029
|
+
};
|
|
1030
|
+
Queue.prototype.toJSON = function() {
|
|
1031
|
+
return this.toArray();
|
|
1032
|
+
};
|
|
1033
|
+
Queue.prototype.inspect = function() {
|
|
1034
|
+
var array = this.toArray();
|
|
1035
|
+
Object.defineProperty(array, "constructor", {
|
|
1036
|
+
value: Queue,
|
|
1037
|
+
enumerable: false
|
|
1038
|
+
});
|
|
1039
|
+
return array;
|
|
1040
|
+
};
|
|
1041
|
+
if (typeof Symbol !== "undefined") Queue.prototype[Symbol.for("nodejs.util.inspect.custom")] = Queue.prototype.inspect;
|
|
1042
|
+
/**
|
|
1043
|
+
* Static @.from function taking an arbitrary iterable & converting it into
|
|
1044
|
+
* a queue.
|
|
1045
|
+
*
|
|
1046
|
+
* @param {Iterable} iterable - Target iterable.
|
|
1047
|
+
* @return {Queue}
|
|
1048
|
+
*/
|
|
1049
|
+
Queue.from = function(iterable) {
|
|
1050
|
+
var queue = new Queue();
|
|
1051
|
+
forEach(iterable, function(value) {
|
|
1052
|
+
queue.enqueue(value);
|
|
1053
|
+
});
|
|
1054
|
+
return queue;
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* Static @.of function taking an arbitrary number of arguments & converting it
|
|
1058
|
+
* into a queue.
|
|
1059
|
+
*
|
|
1060
|
+
* @param {...any} args
|
|
1061
|
+
* @return {Queue}
|
|
1062
|
+
*/
|
|
1063
|
+
Queue.of = function() {
|
|
1064
|
+
return Queue.from(arguments);
|
|
1065
|
+
};
|
|
1066
|
+
/**
|
|
1067
|
+
* Exporting.
|
|
1068
|
+
*/
|
|
1069
|
+
module.exports = Queue;
|
|
1070
|
+
}));
|
|
1071
|
+
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/lru-cache.js
|
|
1074
|
+
var require_lru_cache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1075
|
+
/**
|
|
1076
|
+
* Mnemonist LRUCache
|
|
1077
|
+
* ===================
|
|
1078
|
+
*
|
|
1079
|
+
* JavaScript implementation of the LRU Cache data structure. To save up
|
|
1080
|
+
* memory and allocations this implementation represents its underlying
|
|
1081
|
+
* doubly-linked list as static arrays and pointers. Thus, memory is allocated
|
|
1082
|
+
* only once at instantiation and JS objects are never created to serve as
|
|
1083
|
+
* pointers. This also means this implementation does not trigger too many
|
|
1084
|
+
* garbage collections.
|
|
1085
|
+
*
|
|
1086
|
+
* Note that to save up memory, a LRU Cache can be implemented using a singly
|
|
1087
|
+
* linked list by storing predecessors' pointers as hashmap values.
|
|
1088
|
+
* However, this means more hashmap lookups and would probably slow the whole
|
|
1089
|
+
* thing down. What's more, pointers are not the things taking most space in
|
|
1090
|
+
* memory.
|
|
1091
|
+
*/
|
|
1092
|
+
var Iterator = require_iterator(), forEach = require_foreach(), typed = require_typed_arrays(), iterables = require_iterables();
|
|
1093
|
+
/**
|
|
1094
|
+
* LRUCache.
|
|
1095
|
+
*
|
|
1096
|
+
* @constructor
|
|
1097
|
+
* @param {function} Keys - Array class for storing keys.
|
|
1098
|
+
* @param {function} Values - Array class for storing values.
|
|
1099
|
+
* @param {number} capacity - Desired capacity.
|
|
1100
|
+
*/
|
|
1101
|
+
function LRUCache(Keys, Values, capacity) {
|
|
1102
|
+
if (arguments.length < 2) {
|
|
1103
|
+
capacity = Keys;
|
|
1104
|
+
Keys = null;
|
|
1105
|
+
Values = null;
|
|
1106
|
+
}
|
|
1107
|
+
this.capacity = capacity;
|
|
1108
|
+
if (typeof this.capacity !== "number" || this.capacity <= 0) throw new Error("mnemonist/lru-cache: capacity should be positive number.");
|
|
1109
|
+
else if (!isFinite(this.capacity) || Math.floor(this.capacity) !== this.capacity) throw new Error("mnemonist/lru-cache: capacity should be a finite positive integer.");
|
|
1110
|
+
var PointerArray = typed.getPointerArray(capacity);
|
|
1111
|
+
this.forward = new PointerArray(capacity);
|
|
1112
|
+
this.backward = new PointerArray(capacity);
|
|
1113
|
+
this.K = typeof Keys === "function" ? new Keys(capacity) : new Array(capacity);
|
|
1114
|
+
this.V = typeof Values === "function" ? new Values(capacity) : new Array(capacity);
|
|
1115
|
+
this.size = 0;
|
|
1116
|
+
this.head = 0;
|
|
1117
|
+
this.tail = 0;
|
|
1118
|
+
this.items = {};
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Method used to clear the structure.
|
|
1122
|
+
*
|
|
1123
|
+
* @return {undefined}
|
|
1124
|
+
*/
|
|
1125
|
+
LRUCache.prototype.clear = function() {
|
|
1126
|
+
this.size = 0;
|
|
1127
|
+
this.head = 0;
|
|
1128
|
+
this.tail = 0;
|
|
1129
|
+
this.items = {};
|
|
1130
|
+
};
|
|
1131
|
+
/**
|
|
1132
|
+
* Method used to splay a value on top.
|
|
1133
|
+
*
|
|
1134
|
+
* @param {number} pointer - Pointer of the value to splay on top.
|
|
1135
|
+
* @return {LRUCache}
|
|
1136
|
+
*/
|
|
1137
|
+
LRUCache.prototype.splayOnTop = function(pointer) {
|
|
1138
|
+
var oldHead = this.head;
|
|
1139
|
+
if (this.head === pointer) return this;
|
|
1140
|
+
var previous = this.backward[pointer], next = this.forward[pointer];
|
|
1141
|
+
if (this.tail === pointer) this.tail = previous;
|
|
1142
|
+
else this.backward[next] = previous;
|
|
1143
|
+
this.forward[previous] = next;
|
|
1144
|
+
this.backward[oldHead] = pointer;
|
|
1145
|
+
this.head = pointer;
|
|
1146
|
+
this.forward[pointer] = oldHead;
|
|
1147
|
+
return this;
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* Method used to set the value for the given key in the cache.
|
|
1151
|
+
*
|
|
1152
|
+
* @param {any} key - Key.
|
|
1153
|
+
* @param {any} value - Value.
|
|
1154
|
+
* @return {undefined}
|
|
1155
|
+
*/
|
|
1156
|
+
LRUCache.prototype.set = function(key, value) {
|
|
1157
|
+
var pointer = this.items[key];
|
|
1158
|
+
if (typeof pointer !== "undefined") {
|
|
1159
|
+
this.splayOnTop(pointer);
|
|
1160
|
+
this.V[pointer] = value;
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
if (this.size < this.capacity) pointer = this.size++;
|
|
1164
|
+
else {
|
|
1165
|
+
pointer = this.tail;
|
|
1166
|
+
this.tail = this.backward[pointer];
|
|
1167
|
+
delete this.items[this.K[pointer]];
|
|
1168
|
+
}
|
|
1169
|
+
this.items[key] = pointer;
|
|
1170
|
+
this.K[pointer] = key;
|
|
1171
|
+
this.V[pointer] = value;
|
|
1172
|
+
this.forward[pointer] = this.head;
|
|
1173
|
+
this.backward[this.head] = pointer;
|
|
1174
|
+
this.head = pointer;
|
|
1175
|
+
};
|
|
1176
|
+
/**
|
|
1177
|
+
* Method used to set the value for the given key in the cache
|
|
1178
|
+
*
|
|
1179
|
+
* @param {any} key - Key.
|
|
1180
|
+
* @param {any} value - Value.
|
|
1181
|
+
* @return {{evicted: boolean, key: any, value: any}} An object containing the
|
|
1182
|
+
* key and value of an item that was overwritten or evicted in the set
|
|
1183
|
+
* operation, as well as a boolean indicating whether it was evicted due to
|
|
1184
|
+
* limited capacity. Return value is null if nothing was evicted or overwritten
|
|
1185
|
+
* during the set operation.
|
|
1186
|
+
*/
|
|
1187
|
+
LRUCache.prototype.setpop = function(key, value) {
|
|
1188
|
+
var oldValue = null;
|
|
1189
|
+
var oldKey = null;
|
|
1190
|
+
var pointer = this.items[key];
|
|
1191
|
+
if (typeof pointer !== "undefined") {
|
|
1192
|
+
this.splayOnTop(pointer);
|
|
1193
|
+
oldValue = this.V[pointer];
|
|
1194
|
+
this.V[pointer] = value;
|
|
1195
|
+
return {
|
|
1196
|
+
evicted: false,
|
|
1197
|
+
key,
|
|
1198
|
+
value: oldValue
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
if (this.size < this.capacity) pointer = this.size++;
|
|
1202
|
+
else {
|
|
1203
|
+
pointer = this.tail;
|
|
1204
|
+
this.tail = this.backward[pointer];
|
|
1205
|
+
oldValue = this.V[pointer];
|
|
1206
|
+
oldKey = this.K[pointer];
|
|
1207
|
+
delete this.items[oldKey];
|
|
1208
|
+
}
|
|
1209
|
+
this.items[key] = pointer;
|
|
1210
|
+
this.K[pointer] = key;
|
|
1211
|
+
this.V[pointer] = value;
|
|
1212
|
+
this.forward[pointer] = this.head;
|
|
1213
|
+
this.backward[this.head] = pointer;
|
|
1214
|
+
this.head = pointer;
|
|
1215
|
+
if (oldKey) return {
|
|
1216
|
+
evicted: true,
|
|
1217
|
+
key: oldKey,
|
|
1218
|
+
value: oldValue
|
|
1219
|
+
};
|
|
1220
|
+
else return null;
|
|
1221
|
+
};
|
|
1222
|
+
/**
|
|
1223
|
+
* Method used to check whether the key exists in the cache.
|
|
1224
|
+
*
|
|
1225
|
+
* @param {any} key - Key.
|
|
1226
|
+
* @return {boolean}
|
|
1227
|
+
*/
|
|
1228
|
+
LRUCache.prototype.has = function(key) {
|
|
1229
|
+
return key in this.items;
|
|
1230
|
+
};
|
|
1231
|
+
/**
|
|
1232
|
+
* Method used to get the value attached to the given key. Will move the
|
|
1233
|
+
* related key to the front of the underlying linked list.
|
|
1234
|
+
*
|
|
1235
|
+
* @param {any} key - Key.
|
|
1236
|
+
* @return {any}
|
|
1237
|
+
*/
|
|
1238
|
+
LRUCache.prototype.get = function(key) {
|
|
1239
|
+
var pointer = this.items[key];
|
|
1240
|
+
if (typeof pointer === "undefined") return;
|
|
1241
|
+
this.splayOnTop(pointer);
|
|
1242
|
+
return this.V[pointer];
|
|
1243
|
+
};
|
|
1244
|
+
/**
|
|
1245
|
+
* Method used to get the value attached to the given key. Does not modify
|
|
1246
|
+
* the ordering of the underlying linked list.
|
|
1247
|
+
*
|
|
1248
|
+
* @param {any} key - Key.
|
|
1249
|
+
* @return {any}
|
|
1250
|
+
*/
|
|
1251
|
+
LRUCache.prototype.peek = function(key) {
|
|
1252
|
+
var pointer = this.items[key];
|
|
1253
|
+
if (typeof pointer === "undefined") return;
|
|
1254
|
+
return this.V[pointer];
|
|
1255
|
+
};
|
|
1256
|
+
/**
|
|
1257
|
+
* Method used to iterate over the cache's entries using a callback.
|
|
1258
|
+
*
|
|
1259
|
+
* @param {function} callback - Function to call for each item.
|
|
1260
|
+
* @param {object} scope - Optional scope.
|
|
1261
|
+
* @return {undefined}
|
|
1262
|
+
*/
|
|
1263
|
+
LRUCache.prototype.forEach = function(callback, scope) {
|
|
1264
|
+
scope = arguments.length > 1 ? scope : this;
|
|
1265
|
+
var i = 0, l = this.size;
|
|
1266
|
+
var pointer = this.head, keys = this.K, values = this.V, forward = this.forward;
|
|
1267
|
+
while (i < l) {
|
|
1268
|
+
callback.call(scope, values[pointer], keys[pointer], this);
|
|
1269
|
+
pointer = forward[pointer];
|
|
1270
|
+
i++;
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
/**
|
|
1274
|
+
* Method used to create an iterator over the cache's keys from most
|
|
1275
|
+
* recently used to least recently used.
|
|
1276
|
+
*
|
|
1277
|
+
* @return {Iterator}
|
|
1278
|
+
*/
|
|
1279
|
+
LRUCache.prototype.keys = function() {
|
|
1280
|
+
var i = 0, l = this.size;
|
|
1281
|
+
var pointer = this.head, keys = this.K, forward = this.forward;
|
|
1282
|
+
return new Iterator(function() {
|
|
1283
|
+
if (i >= l) return { done: true };
|
|
1284
|
+
var key = keys[pointer];
|
|
1285
|
+
i++;
|
|
1286
|
+
if (i < l) pointer = forward[pointer];
|
|
1287
|
+
return {
|
|
1288
|
+
done: false,
|
|
1289
|
+
value: key
|
|
1290
|
+
};
|
|
1291
|
+
});
|
|
1292
|
+
};
|
|
1293
|
+
/**
|
|
1294
|
+
* Method used to create an iterator over the cache's values from most
|
|
1295
|
+
* recently used to least recently used.
|
|
1296
|
+
*
|
|
1297
|
+
* @return {Iterator}
|
|
1298
|
+
*/
|
|
1299
|
+
LRUCache.prototype.values = function() {
|
|
1300
|
+
var i = 0, l = this.size;
|
|
1301
|
+
var pointer = this.head, values = this.V, forward = this.forward;
|
|
1302
|
+
return new Iterator(function() {
|
|
1303
|
+
if (i >= l) return { done: true };
|
|
1304
|
+
var value = values[pointer];
|
|
1305
|
+
i++;
|
|
1306
|
+
if (i < l) pointer = forward[pointer];
|
|
1307
|
+
return {
|
|
1308
|
+
done: false,
|
|
1309
|
+
value
|
|
1310
|
+
};
|
|
1311
|
+
});
|
|
1312
|
+
};
|
|
1313
|
+
/**
|
|
1314
|
+
* Method used to create an iterator over the cache's entries from most
|
|
1315
|
+
* recently used to least recently used.
|
|
1316
|
+
*
|
|
1317
|
+
* @return {Iterator}
|
|
1318
|
+
*/
|
|
1319
|
+
LRUCache.prototype.entries = function() {
|
|
1320
|
+
var i = 0, l = this.size;
|
|
1321
|
+
var pointer = this.head, keys = this.K, values = this.V, forward = this.forward;
|
|
1322
|
+
return new Iterator(function() {
|
|
1323
|
+
if (i >= l) return { done: true };
|
|
1324
|
+
var key = keys[pointer], value = values[pointer];
|
|
1325
|
+
i++;
|
|
1326
|
+
if (i < l) pointer = forward[pointer];
|
|
1327
|
+
return {
|
|
1328
|
+
done: false,
|
|
1329
|
+
value: [key, value]
|
|
1330
|
+
};
|
|
1331
|
+
});
|
|
1332
|
+
};
|
|
1333
|
+
/**
|
|
1334
|
+
* Attaching the #.entries method to Symbol.iterator if possible.
|
|
1335
|
+
*/
|
|
1336
|
+
if (typeof Symbol !== "undefined") LRUCache.prototype[Symbol.iterator] = LRUCache.prototype.entries;
|
|
1337
|
+
/**
|
|
1338
|
+
* Convenience known methods.
|
|
1339
|
+
*/
|
|
1340
|
+
LRUCache.prototype.inspect = function() {
|
|
1341
|
+
var proxy = /* @__PURE__ */ new Map();
|
|
1342
|
+
var iterator = this.entries(), step;
|
|
1343
|
+
while (step = iterator.next(), !step.done) proxy.set(step.value[0], step.value[1]);
|
|
1344
|
+
Object.defineProperty(proxy, "constructor", {
|
|
1345
|
+
value: LRUCache,
|
|
1346
|
+
enumerable: false
|
|
1347
|
+
});
|
|
1348
|
+
return proxy;
|
|
1349
|
+
};
|
|
1350
|
+
if (typeof Symbol !== "undefined") LRUCache.prototype[Symbol.for("nodejs.util.inspect.custom")] = LRUCache.prototype.inspect;
|
|
1351
|
+
/**
|
|
1352
|
+
* Static @.from function taking an arbitrary iterable & converting it into
|
|
1353
|
+
* a structure.
|
|
1354
|
+
*
|
|
1355
|
+
* @param {Iterable} iterable - Target iterable.
|
|
1356
|
+
* @param {function} Keys - Array class for storing keys.
|
|
1357
|
+
* @param {function} Values - Array class for storing values.
|
|
1358
|
+
* @param {number} capacity - Cache's capacity.
|
|
1359
|
+
* @return {LRUCache}
|
|
1360
|
+
*/
|
|
1361
|
+
LRUCache.from = function(iterable, Keys, Values, capacity) {
|
|
1362
|
+
if (arguments.length < 2) {
|
|
1363
|
+
capacity = iterables.guessLength(iterable);
|
|
1364
|
+
if (typeof capacity !== "number") throw new Error("mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.");
|
|
1365
|
+
} else if (arguments.length === 2) {
|
|
1366
|
+
capacity = Keys;
|
|
1367
|
+
Keys = null;
|
|
1368
|
+
Values = null;
|
|
1369
|
+
}
|
|
1370
|
+
var cache = new LRUCache(Keys, Values, capacity);
|
|
1371
|
+
forEach(iterable, function(value, key) {
|
|
1372
|
+
cache.set(key, value);
|
|
1373
|
+
});
|
|
1374
|
+
return cache;
|
|
1375
|
+
};
|
|
1376
|
+
/**
|
|
1377
|
+
* Exporting.
|
|
1378
|
+
*/
|
|
1379
|
+
module.exports = LRUCache;
|
|
1380
|
+
}));
|
|
1381
|
+
|
|
1382
|
+
//#endregion
|
|
1383
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/lru-map.js
|
|
1384
|
+
var require_lru_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1385
|
+
/**
|
|
1386
|
+
* Mnemonist LRUMap
|
|
1387
|
+
* =================
|
|
1388
|
+
*
|
|
1389
|
+
* Variant of the LRUCache class that leverages an ES6 Map instead of an object.
|
|
1390
|
+
* It might be faster for some use case but it is still hard to understand
|
|
1391
|
+
* when a Map can outperform an object in v8.
|
|
1392
|
+
*/
|
|
1393
|
+
var LRUCache = require_lru_cache(), forEach = require_foreach(), typed = require_typed_arrays(), iterables = require_iterables();
|
|
1394
|
+
/**
|
|
1395
|
+
* LRUMap.
|
|
1396
|
+
*
|
|
1397
|
+
* @constructor
|
|
1398
|
+
* @param {function} Keys - Array class for storing keys.
|
|
1399
|
+
* @param {function} Values - Array class for storing values.
|
|
1400
|
+
* @param {number} capacity - Desired capacity.
|
|
1401
|
+
*/
|
|
1402
|
+
function LRUMap(Keys, Values, capacity) {
|
|
1403
|
+
if (arguments.length < 2) {
|
|
1404
|
+
capacity = Keys;
|
|
1405
|
+
Keys = null;
|
|
1406
|
+
Values = null;
|
|
1407
|
+
}
|
|
1408
|
+
this.capacity = capacity;
|
|
1409
|
+
if (typeof this.capacity !== "number" || this.capacity <= 0) throw new Error("mnemonist/lru-map: capacity should be positive number.");
|
|
1410
|
+
else if (!isFinite(this.capacity) || Math.floor(this.capacity) !== this.capacity) throw new Error("mnemonist/lru-map: capacity should be a finite positive integer.");
|
|
1411
|
+
var PointerArray = typed.getPointerArray(capacity);
|
|
1412
|
+
this.forward = new PointerArray(capacity);
|
|
1413
|
+
this.backward = new PointerArray(capacity);
|
|
1414
|
+
this.K = typeof Keys === "function" ? new Keys(capacity) : new Array(capacity);
|
|
1415
|
+
this.V = typeof Values === "function" ? new Values(capacity) : new Array(capacity);
|
|
1416
|
+
this.size = 0;
|
|
1417
|
+
this.head = 0;
|
|
1418
|
+
this.tail = 0;
|
|
1419
|
+
this.items = /* @__PURE__ */ new Map();
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Method used to clear the structure.
|
|
1423
|
+
*
|
|
1424
|
+
* @return {undefined}
|
|
1425
|
+
*/
|
|
1426
|
+
LRUMap.prototype.clear = function() {
|
|
1427
|
+
this.size = 0;
|
|
1428
|
+
this.head = 0;
|
|
1429
|
+
this.tail = 0;
|
|
1430
|
+
this.items.clear();
|
|
1431
|
+
};
|
|
1432
|
+
/**
|
|
1433
|
+
* Method used to set the value for the given key in the cache.
|
|
1434
|
+
*
|
|
1435
|
+
* @param {any} key - Key.
|
|
1436
|
+
* @param {any} value - Value.
|
|
1437
|
+
* @return {undefined}
|
|
1438
|
+
*/
|
|
1439
|
+
LRUMap.prototype.set = function(key, value) {
|
|
1440
|
+
var pointer = this.items.get(key);
|
|
1441
|
+
if (typeof pointer !== "undefined") {
|
|
1442
|
+
this.splayOnTop(pointer);
|
|
1443
|
+
this.V[pointer] = value;
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
if (this.size < this.capacity) pointer = this.size++;
|
|
1447
|
+
else {
|
|
1448
|
+
pointer = this.tail;
|
|
1449
|
+
this.tail = this.backward[pointer];
|
|
1450
|
+
this.items.delete(this.K[pointer]);
|
|
1451
|
+
}
|
|
1452
|
+
this.items.set(key, pointer);
|
|
1453
|
+
this.K[pointer] = key;
|
|
1454
|
+
this.V[pointer] = value;
|
|
1455
|
+
this.forward[pointer] = this.head;
|
|
1456
|
+
this.backward[this.head] = pointer;
|
|
1457
|
+
this.head = pointer;
|
|
1458
|
+
};
|
|
1459
|
+
/**
|
|
1460
|
+
* Method used to set the value for the given key in the cache.
|
|
1461
|
+
*
|
|
1462
|
+
* @param {any} key - Key.
|
|
1463
|
+
* @param {any} value - Value.
|
|
1464
|
+
* @return {{evicted: boolean, key: any, value: any}} An object containing the
|
|
1465
|
+
* key and value of an item that was overwritten or evicted in the set
|
|
1466
|
+
* operation, as well as a boolean indicating whether it was evicted due to
|
|
1467
|
+
* limited capacity. Return value is null if nothing was evicted or overwritten
|
|
1468
|
+
* during the set operation.
|
|
1469
|
+
*/
|
|
1470
|
+
LRUMap.prototype.setpop = function(key, value) {
|
|
1471
|
+
var oldValue = null;
|
|
1472
|
+
var oldKey = null;
|
|
1473
|
+
var pointer = this.items.get(key);
|
|
1474
|
+
if (typeof pointer !== "undefined") {
|
|
1475
|
+
this.splayOnTop(pointer);
|
|
1476
|
+
oldValue = this.V[pointer];
|
|
1477
|
+
this.V[pointer] = value;
|
|
1478
|
+
return {
|
|
1479
|
+
evicted: false,
|
|
1480
|
+
key,
|
|
1481
|
+
value: oldValue
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
if (this.size < this.capacity) pointer = this.size++;
|
|
1485
|
+
else {
|
|
1486
|
+
pointer = this.tail;
|
|
1487
|
+
this.tail = this.backward[pointer];
|
|
1488
|
+
oldValue = this.V[pointer];
|
|
1489
|
+
oldKey = this.K[pointer];
|
|
1490
|
+
this.items.delete(oldKey);
|
|
1491
|
+
}
|
|
1492
|
+
this.items.set(key, pointer);
|
|
1493
|
+
this.K[pointer] = key;
|
|
1494
|
+
this.V[pointer] = value;
|
|
1495
|
+
this.forward[pointer] = this.head;
|
|
1496
|
+
this.backward[this.head] = pointer;
|
|
1497
|
+
this.head = pointer;
|
|
1498
|
+
if (oldKey) return {
|
|
1499
|
+
evicted: true,
|
|
1500
|
+
key: oldKey,
|
|
1501
|
+
value: oldValue
|
|
1502
|
+
};
|
|
1503
|
+
else return null;
|
|
1504
|
+
};
|
|
1505
|
+
/**
|
|
1506
|
+
* Method used to check whether the key exists in the cache.
|
|
1507
|
+
*
|
|
1508
|
+
* @param {any} key - Key.
|
|
1509
|
+
* @return {boolean}
|
|
1510
|
+
*/
|
|
1511
|
+
LRUMap.prototype.has = function(key) {
|
|
1512
|
+
return this.items.has(key);
|
|
1513
|
+
};
|
|
1514
|
+
/**
|
|
1515
|
+
* Method used to get the value attached to the given key. Will move the
|
|
1516
|
+
* related key to the front of the underlying linked list.
|
|
1517
|
+
*
|
|
1518
|
+
* @param {any} key - Key.
|
|
1519
|
+
* @return {any}
|
|
1520
|
+
*/
|
|
1521
|
+
LRUMap.prototype.get = function(key) {
|
|
1522
|
+
var pointer = this.items.get(key);
|
|
1523
|
+
if (typeof pointer === "undefined") return;
|
|
1524
|
+
this.splayOnTop(pointer);
|
|
1525
|
+
return this.V[pointer];
|
|
1526
|
+
};
|
|
1527
|
+
/**
|
|
1528
|
+
* Method used to get the value attached to the given key. Does not modify
|
|
1529
|
+
* the ordering of the underlying linked list.
|
|
1530
|
+
*
|
|
1531
|
+
* @param {any} key - Key.
|
|
1532
|
+
* @return {any}
|
|
1533
|
+
*/
|
|
1534
|
+
LRUMap.prototype.peek = function(key) {
|
|
1535
|
+
var pointer = this.items.get(key);
|
|
1536
|
+
if (typeof pointer === "undefined") return;
|
|
1537
|
+
return this.V[pointer];
|
|
1538
|
+
};
|
|
1539
|
+
/**
|
|
1540
|
+
* Methods that can be reused as-is from LRUCache.
|
|
1541
|
+
*/
|
|
1542
|
+
LRUMap.prototype.splayOnTop = LRUCache.prototype.splayOnTop;
|
|
1543
|
+
LRUMap.prototype.forEach = LRUCache.prototype.forEach;
|
|
1544
|
+
LRUMap.prototype.keys = LRUCache.prototype.keys;
|
|
1545
|
+
LRUMap.prototype.values = LRUCache.prototype.values;
|
|
1546
|
+
LRUMap.prototype.entries = LRUCache.prototype.entries;
|
|
1547
|
+
/**
|
|
1548
|
+
* Attaching the #.entries method to Symbol.iterator if possible.
|
|
1549
|
+
*/
|
|
1550
|
+
if (typeof Symbol !== "undefined") LRUMap.prototype[Symbol.iterator] = LRUMap.prototype.entries;
|
|
1551
|
+
/**
|
|
1552
|
+
* Convenience known methods.
|
|
1553
|
+
*/
|
|
1554
|
+
LRUMap.prototype.inspect = LRUCache.prototype.inspect;
|
|
1555
|
+
/**
|
|
1556
|
+
* Static @.from function taking an arbitrary iterable & converting it into
|
|
1557
|
+
* a structure.
|
|
1558
|
+
*
|
|
1559
|
+
* @param {Iterable} iterable - Target iterable.
|
|
1560
|
+
* @param {function} Keys - Array class for storing keys.
|
|
1561
|
+
* @param {function} Values - Array class for storing values.
|
|
1562
|
+
* @param {number} capacity - Cache's capacity.
|
|
1563
|
+
* @return {LRUMap}
|
|
1564
|
+
*/
|
|
1565
|
+
LRUMap.from = function(iterable, Keys, Values, capacity) {
|
|
1566
|
+
if (arguments.length < 2) {
|
|
1567
|
+
capacity = iterables.guessLength(iterable);
|
|
1568
|
+
if (typeof capacity !== "number") throw new Error("mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.");
|
|
1569
|
+
} else if (arguments.length === 2) {
|
|
1570
|
+
capacity = Keys;
|
|
1571
|
+
Keys = null;
|
|
1572
|
+
Values = null;
|
|
1573
|
+
}
|
|
1574
|
+
var cache = new LRUMap(Keys, Values, capacity);
|
|
1575
|
+
forEach(iterable, function(value, key) {
|
|
1576
|
+
cache.set(key, value);
|
|
1577
|
+
});
|
|
1578
|
+
return cache;
|
|
1579
|
+
};
|
|
1580
|
+
/**
|
|
1581
|
+
* Exporting.
|
|
1582
|
+
*/
|
|
1583
|
+
module.exports = LRUMap;
|
|
1584
|
+
}));
|
|
1585
|
+
|
|
1586
|
+
//#endregion
|
|
1587
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/set.js
|
|
1588
|
+
var require_set = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1589
|
+
/**
|
|
1590
|
+
* Mnemonist Set
|
|
1591
|
+
* ==============
|
|
1592
|
+
*
|
|
1593
|
+
* Useful function related to sets such as union, intersection and so on...
|
|
1594
|
+
*/
|
|
1595
|
+
/**
|
|
1596
|
+
* Variadic function computing the intersection of multiple sets.
|
|
1597
|
+
*
|
|
1598
|
+
* @param {...Set} sets - Sets to intersect.
|
|
1599
|
+
* @return {Set} - The intesection.
|
|
1600
|
+
*/
|
|
1601
|
+
exports.intersection = function() {
|
|
1602
|
+
if (arguments.length < 2) throw new Error("mnemonist/Set.intersection: needs at least two arguments.");
|
|
1603
|
+
var I = /* @__PURE__ */ new Set();
|
|
1604
|
+
var smallestSize = Infinity, smallestSet = null;
|
|
1605
|
+
var s, i, l = arguments.length;
|
|
1606
|
+
for (i = 0; i < l; i++) {
|
|
1607
|
+
s = arguments[i];
|
|
1608
|
+
if (s.size === 0) return I;
|
|
1609
|
+
if (s.size < smallestSize) {
|
|
1610
|
+
smallestSize = s.size;
|
|
1611
|
+
smallestSet = s;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
var iterator = smallestSet.values(), step, item, add, set;
|
|
1615
|
+
while (step = iterator.next(), !step.done) {
|
|
1616
|
+
item = step.value;
|
|
1617
|
+
add = true;
|
|
1618
|
+
for (i = 0; i < l; i++) {
|
|
1619
|
+
set = arguments[i];
|
|
1620
|
+
if (set === smallestSet) continue;
|
|
1621
|
+
if (!set.has(item)) {
|
|
1622
|
+
add = false;
|
|
1623
|
+
break;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
if (add) I.add(item);
|
|
1627
|
+
}
|
|
1628
|
+
return I;
|
|
1629
|
+
};
|
|
1630
|
+
/**
|
|
1631
|
+
* Variadic function computing the union of multiple sets.
|
|
1632
|
+
*
|
|
1633
|
+
* @param {...Set} sets - Sets to unite.
|
|
1634
|
+
* @return {Set} - The union.
|
|
1635
|
+
*/
|
|
1636
|
+
exports.union = function() {
|
|
1637
|
+
if (arguments.length < 2) throw new Error("mnemonist/Set.union: needs at least two arguments.");
|
|
1638
|
+
var U = /* @__PURE__ */ new Set();
|
|
1639
|
+
var i, l = arguments.length;
|
|
1640
|
+
var iterator, step;
|
|
1641
|
+
for (i = 0; i < l; i++) {
|
|
1642
|
+
iterator = arguments[i].values();
|
|
1643
|
+
while (step = iterator.next(), !step.done) U.add(step.value);
|
|
1644
|
+
}
|
|
1645
|
+
return U;
|
|
1646
|
+
};
|
|
1647
|
+
/**
|
|
1648
|
+
* Function computing the difference between two sets.
|
|
1649
|
+
*
|
|
1650
|
+
* @param {Set} A - First set.
|
|
1651
|
+
* @param {Set} B - Second set.
|
|
1652
|
+
* @return {Set} - The difference.
|
|
1653
|
+
*/
|
|
1654
|
+
exports.difference = function(A, B) {
|
|
1655
|
+
if (!A.size) return /* @__PURE__ */ new Set();
|
|
1656
|
+
if (!B.size) return new Set(A);
|
|
1657
|
+
var D = /* @__PURE__ */ new Set();
|
|
1658
|
+
var iterator = A.values(), step;
|
|
1659
|
+
while (step = iterator.next(), !step.done) if (!B.has(step.value)) D.add(step.value);
|
|
1660
|
+
return D;
|
|
1661
|
+
};
|
|
1662
|
+
/**
|
|
1663
|
+
* Function computing the symmetric difference between two sets.
|
|
1664
|
+
*
|
|
1665
|
+
* @param {Set} A - First set.
|
|
1666
|
+
* @param {Set} B - Second set.
|
|
1667
|
+
* @return {Set} - The symmetric difference.
|
|
1668
|
+
*/
|
|
1669
|
+
exports.symmetricDifference = function(A, B) {
|
|
1670
|
+
var S = /* @__PURE__ */ new Set();
|
|
1671
|
+
var iterator = A.values(), step;
|
|
1672
|
+
while (step = iterator.next(), !step.done) if (!B.has(step.value)) S.add(step.value);
|
|
1673
|
+
iterator = B.values();
|
|
1674
|
+
while (step = iterator.next(), !step.done) if (!A.has(step.value)) S.add(step.value);
|
|
1675
|
+
return S;
|
|
1676
|
+
};
|
|
1677
|
+
/**
|
|
1678
|
+
* Function returning whether A is a subset of B.
|
|
1679
|
+
*
|
|
1680
|
+
* @param {Set} A - First set.
|
|
1681
|
+
* @param {Set} B - Second set.
|
|
1682
|
+
* @return {boolean}
|
|
1683
|
+
*/
|
|
1684
|
+
exports.isSubset = function(A, B) {
|
|
1685
|
+
var iterator = A.values(), step;
|
|
1686
|
+
if (A === B) return true;
|
|
1687
|
+
if (A.size > B.size) return false;
|
|
1688
|
+
while (step = iterator.next(), !step.done) if (!B.has(step.value)) return false;
|
|
1689
|
+
return true;
|
|
1690
|
+
};
|
|
1691
|
+
/**
|
|
1692
|
+
* Function returning whether A is a superset of B.
|
|
1693
|
+
*
|
|
1694
|
+
* @param {Set} A - First set.
|
|
1695
|
+
* @param {Set} B - Second set.
|
|
1696
|
+
* @return {boolean}
|
|
1697
|
+
*/
|
|
1698
|
+
exports.isSuperset = function(A, B) {
|
|
1699
|
+
return exports.isSubset(B, A);
|
|
1700
|
+
};
|
|
1701
|
+
/**
|
|
1702
|
+
* Function adding the items of set B to the set A.
|
|
1703
|
+
*
|
|
1704
|
+
* @param {Set} A - First set.
|
|
1705
|
+
* @param {Set} B - Second set.
|
|
1706
|
+
*/
|
|
1707
|
+
exports.add = function(A, B) {
|
|
1708
|
+
var iterator = B.values(), step;
|
|
1709
|
+
while (step = iterator.next(), !step.done) A.add(step.value);
|
|
1710
|
+
};
|
|
1711
|
+
/**
|
|
1712
|
+
* Function subtracting the items of set B from the set A.
|
|
1713
|
+
*
|
|
1714
|
+
* @param {Set} A - First set.
|
|
1715
|
+
* @param {Set} B - Second set.
|
|
1716
|
+
*/
|
|
1717
|
+
exports.subtract = function(A, B) {
|
|
1718
|
+
var iterator = B.values(), step;
|
|
1719
|
+
while (step = iterator.next(), !step.done) A.delete(step.value);
|
|
1720
|
+
};
|
|
1721
|
+
/**
|
|
1722
|
+
* Function intersecting the items of A & B.
|
|
1723
|
+
*
|
|
1724
|
+
* @param {Set} A - First set.
|
|
1725
|
+
* @param {Set} B - Second set.
|
|
1726
|
+
*/
|
|
1727
|
+
exports.intersect = function(A, B) {
|
|
1728
|
+
var iterator = A.values(), step;
|
|
1729
|
+
while (step = iterator.next(), !step.done) if (!B.has(step.value)) A.delete(step.value);
|
|
1730
|
+
};
|
|
1731
|
+
/**
|
|
1732
|
+
* Function disjuncting the items of A & B.
|
|
1733
|
+
*
|
|
1734
|
+
* @param {Set} A - First set.
|
|
1735
|
+
* @param {Set} B - Second set.
|
|
1736
|
+
*/
|
|
1737
|
+
exports.disjunct = function(A, B) {
|
|
1738
|
+
var iterator = A.values(), step;
|
|
1739
|
+
var toRemove = [];
|
|
1740
|
+
while (step = iterator.next(), !step.done) if (B.has(step.value)) toRemove.push(step.value);
|
|
1741
|
+
iterator = B.values();
|
|
1742
|
+
while (step = iterator.next(), !step.done) if (!A.has(step.value)) A.add(step.value);
|
|
1743
|
+
for (var i = 0, l = toRemove.length; i < l; i++) A.delete(toRemove[i]);
|
|
1744
|
+
};
|
|
1745
|
+
/**
|
|
1746
|
+
* Function returning the size of the intersection of A & B.
|
|
1747
|
+
*
|
|
1748
|
+
* @param {Set} A - First set.
|
|
1749
|
+
* @param {Set} B - Second set.
|
|
1750
|
+
* @return {number}
|
|
1751
|
+
*/
|
|
1752
|
+
exports.intersectionSize = function(A, B) {
|
|
1753
|
+
var tmp;
|
|
1754
|
+
if (A.size > B.size) {
|
|
1755
|
+
tmp = A;
|
|
1756
|
+
A = B;
|
|
1757
|
+
B = tmp;
|
|
1758
|
+
}
|
|
1759
|
+
if (A.size === 0) return 0;
|
|
1760
|
+
if (A === B) return A.size;
|
|
1761
|
+
var iterator = A.values(), step;
|
|
1762
|
+
var I = 0;
|
|
1763
|
+
while (step = iterator.next(), !step.done) if (B.has(step.value)) I++;
|
|
1764
|
+
return I;
|
|
1765
|
+
};
|
|
1766
|
+
/**
|
|
1767
|
+
* Function returning the size of the union of A & B.
|
|
1768
|
+
*
|
|
1769
|
+
* @param {Set} A - First set.
|
|
1770
|
+
* @param {Set} B - Second set.
|
|
1771
|
+
* @return {number}
|
|
1772
|
+
*/
|
|
1773
|
+
exports.unionSize = function(A, B) {
|
|
1774
|
+
var I = exports.intersectionSize(A, B);
|
|
1775
|
+
return A.size + B.size - I;
|
|
1776
|
+
};
|
|
1777
|
+
/**
|
|
1778
|
+
* Function returning the Jaccard similarity between A & B.
|
|
1779
|
+
*
|
|
1780
|
+
* @param {Set} A - First set.
|
|
1781
|
+
* @param {Set} B - Second set.
|
|
1782
|
+
* @return {number}
|
|
1783
|
+
*/
|
|
1784
|
+
exports.jaccard = function(A, B) {
|
|
1785
|
+
var I = exports.intersectionSize(A, B);
|
|
1786
|
+
if (I === 0) return 0;
|
|
1787
|
+
return I / (A.size + B.size - I);
|
|
1788
|
+
};
|
|
1789
|
+
/**
|
|
1790
|
+
* Function returning the overlap coefficient between A & B.
|
|
1791
|
+
*
|
|
1792
|
+
* @param {Set} A - First set.
|
|
1793
|
+
* @param {Set} B - Second set.
|
|
1794
|
+
* @return {number}
|
|
1795
|
+
*/
|
|
1796
|
+
exports.overlap = function(A, B) {
|
|
1797
|
+
var I = exports.intersectionSize(A, B);
|
|
1798
|
+
if (I === 0) return 0;
|
|
1799
|
+
return I / Math.min(A.size, B.size);
|
|
1800
|
+
};
|
|
1801
|
+
}));
|
|
1802
|
+
|
|
1803
|
+
//#endregion
|
|
1804
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/stack.js
|
|
1805
|
+
var require_stack = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1806
|
+
/**
|
|
1807
|
+
* Mnemonist Stack
|
|
1808
|
+
* ================
|
|
1809
|
+
*
|
|
1810
|
+
* Stack implementation relying on JavaScript arrays, which are fast enough &
|
|
1811
|
+
* correctly optimized for this kind of work.
|
|
1812
|
+
*/
|
|
1813
|
+
var Iterator = require_iterator(), forEach = require_foreach();
|
|
1814
|
+
/**
|
|
1815
|
+
* Stack
|
|
1816
|
+
*
|
|
1817
|
+
* @constructor
|
|
1818
|
+
*/
|
|
1819
|
+
function Stack() {
|
|
1820
|
+
this.clear();
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Method used to clear the stack.
|
|
1824
|
+
*
|
|
1825
|
+
* @return {undefined}
|
|
1826
|
+
*/
|
|
1827
|
+
Stack.prototype.clear = function() {
|
|
1828
|
+
this.items = [];
|
|
1829
|
+
this.size = 0;
|
|
1830
|
+
};
|
|
1831
|
+
/**
|
|
1832
|
+
* Method used to add an item to the stack.
|
|
1833
|
+
*
|
|
1834
|
+
* @param {any} item - Item to add.
|
|
1835
|
+
* @return {number}
|
|
1836
|
+
*/
|
|
1837
|
+
Stack.prototype.push = function(item) {
|
|
1838
|
+
this.items.push(item);
|
|
1839
|
+
return ++this.size;
|
|
1840
|
+
};
|
|
1841
|
+
/**
|
|
1842
|
+
* Method used to retrieve & remove the last item of the stack.
|
|
1843
|
+
*
|
|
1844
|
+
* @return {any}
|
|
1845
|
+
*/
|
|
1846
|
+
Stack.prototype.pop = function() {
|
|
1847
|
+
if (this.size === 0) return;
|
|
1848
|
+
this.size--;
|
|
1849
|
+
return this.items.pop();
|
|
1850
|
+
};
|
|
1851
|
+
/**
|
|
1852
|
+
* Method used to get the last item of the stack.
|
|
1853
|
+
*
|
|
1854
|
+
* @return {any}
|
|
1855
|
+
*/
|
|
1856
|
+
Stack.prototype.peek = function() {
|
|
1857
|
+
return this.items[this.size - 1];
|
|
1858
|
+
};
|
|
1859
|
+
/**
|
|
1860
|
+
* Method used to iterate over the stack.
|
|
1861
|
+
*
|
|
1862
|
+
* @param {function} callback - Function to call for each item.
|
|
1863
|
+
* @param {object} scope - Optional scope.
|
|
1864
|
+
* @return {undefined}
|
|
1865
|
+
*/
|
|
1866
|
+
Stack.prototype.forEach = function(callback, scope) {
|
|
1867
|
+
scope = arguments.length > 1 ? scope : this;
|
|
1868
|
+
for (var i = 0, l = this.items.length; i < l; i++) callback.call(scope, this.items[l - i - 1], i, this);
|
|
1869
|
+
};
|
|
1870
|
+
/**
|
|
1871
|
+
* Method used to convert the stack to a JavaScript array.
|
|
1872
|
+
*
|
|
1873
|
+
* @return {array}
|
|
1874
|
+
*/
|
|
1875
|
+
Stack.prototype.toArray = function() {
|
|
1876
|
+
var array = new Array(this.size), l = this.size - 1, i = this.size;
|
|
1877
|
+
while (i--) array[i] = this.items[l - i];
|
|
1878
|
+
return array;
|
|
1879
|
+
};
|
|
1880
|
+
/**
|
|
1881
|
+
* Method used to create an iterator over a stack's values.
|
|
1882
|
+
*
|
|
1883
|
+
* @return {Iterator}
|
|
1884
|
+
*/
|
|
1885
|
+
Stack.prototype.values = function() {
|
|
1886
|
+
var items = this.items, l = items.length, i = 0;
|
|
1887
|
+
return new Iterator(function() {
|
|
1888
|
+
if (i >= l) return { done: true };
|
|
1889
|
+
var value = items[l - i - 1];
|
|
1890
|
+
i++;
|
|
1891
|
+
return {
|
|
1892
|
+
value,
|
|
1893
|
+
done: false
|
|
1894
|
+
};
|
|
1895
|
+
});
|
|
1896
|
+
};
|
|
1897
|
+
/**
|
|
1898
|
+
* Method used to create an iterator over a stack's entries.
|
|
1899
|
+
*
|
|
1900
|
+
* @return {Iterator}
|
|
1901
|
+
*/
|
|
1902
|
+
Stack.prototype.entries = function() {
|
|
1903
|
+
var items = this.items, l = items.length, i = 0;
|
|
1904
|
+
return new Iterator(function() {
|
|
1905
|
+
if (i >= l) return { done: true };
|
|
1906
|
+
var value = items[l - i - 1];
|
|
1907
|
+
return {
|
|
1908
|
+
value: [i++, value],
|
|
1909
|
+
done: false
|
|
1910
|
+
};
|
|
1911
|
+
});
|
|
1912
|
+
};
|
|
1913
|
+
/**
|
|
1914
|
+
* Attaching the #.values method to Symbol.iterator if possible.
|
|
1915
|
+
*/
|
|
1916
|
+
if (typeof Symbol !== "undefined") Stack.prototype[Symbol.iterator] = Stack.prototype.values;
|
|
1917
|
+
/**
|
|
1918
|
+
* Convenience known methods.
|
|
1919
|
+
*/
|
|
1920
|
+
Stack.prototype.toString = function() {
|
|
1921
|
+
return this.toArray().join(",");
|
|
1922
|
+
};
|
|
1923
|
+
Stack.prototype.toJSON = function() {
|
|
1924
|
+
return this.toArray();
|
|
1925
|
+
};
|
|
1926
|
+
Stack.prototype.inspect = function() {
|
|
1927
|
+
var array = this.toArray();
|
|
1928
|
+
Object.defineProperty(array, "constructor", {
|
|
1929
|
+
value: Stack,
|
|
1930
|
+
enumerable: false
|
|
1931
|
+
});
|
|
1932
|
+
return array;
|
|
1933
|
+
};
|
|
1934
|
+
if (typeof Symbol !== "undefined") Stack.prototype[Symbol.for("nodejs.util.inspect.custom")] = Stack.prototype.inspect;
|
|
1935
|
+
/**
|
|
1936
|
+
* Static @.from function taking an arbitrary iterable & converting it into
|
|
1937
|
+
* a stack.
|
|
1938
|
+
*
|
|
1939
|
+
* @param {Iterable} iterable - Target iterable.
|
|
1940
|
+
* @return {Stack}
|
|
1941
|
+
*/
|
|
1942
|
+
Stack.from = function(iterable) {
|
|
1943
|
+
var stack = new Stack();
|
|
1944
|
+
forEach(iterable, function(value) {
|
|
1945
|
+
stack.push(value);
|
|
1946
|
+
});
|
|
1947
|
+
return stack;
|
|
1948
|
+
};
|
|
1949
|
+
/**
|
|
1950
|
+
* Static @.of function taking an arbitrary number of arguments & converting it
|
|
1951
|
+
* into a stack.
|
|
1952
|
+
*
|
|
1953
|
+
* @param {...any} args
|
|
1954
|
+
* @return {Stack}
|
|
1955
|
+
*/
|
|
1956
|
+
Stack.of = function() {
|
|
1957
|
+
return Stack.from(arguments);
|
|
1958
|
+
};
|
|
1959
|
+
/**
|
|
1960
|
+
* Exporting.
|
|
1961
|
+
*/
|
|
1962
|
+
module.exports = Stack;
|
|
1963
|
+
}));
|
|
1964
|
+
|
|
1965
|
+
//#endregion
|
|
1966
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.3_patch_hash=70301b9c235e13bc146bb9528b7979c278952196d5dac8048ab3850adac8f4cf/node_modules/mnemonist/patch.mjs
|
|
1967
|
+
var import_bi_map = /* @__PURE__ */ __toESM(require_bi_map(), 1);
|
|
1968
|
+
var import_default_map = /* @__PURE__ */ __toESM(require_default_map(), 1);
|
|
1969
|
+
var import_default_weak_map = /* @__PURE__ */ __toESM(require_default_weak_map(), 1);
|
|
1970
|
+
var import_linked_list = /* @__PURE__ */ __toESM(require_linked_list(), 1);
|
|
1971
|
+
var import_multi_map = /* @__PURE__ */ __toESM(require_multi_map(), 1);
|
|
1972
|
+
var import_queue = /* @__PURE__ */ __toESM(require_queue(), 1);
|
|
1973
|
+
var import_lru_map = /* @__PURE__ */ __toESM(require_lru_map(), 1);
|
|
1974
|
+
var import_set = require_set();
|
|
1975
|
+
var import_stack = /* @__PURE__ */ __toESM(require_stack(), 1);
|
|
1976
|
+
|
|
1977
|
+
//#endregion
|
|
1978
|
+
export { import_lru_map as a, import_set as c, import_linked_list as i, import_stack as l, import_default_map as n, import_multi_map as o, import_default_weak_map as r, import_queue as s, import_bi_map as t };
|