@jiovan-labs/ts-multi-map 0.0.0-stage → 2.0.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.txt +21 -0
- package/README.md +46 -2
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/type/declaration.d.ts +10 -0
- package/dist/cjs/type/declaration.js +17 -0
- package/dist/cjs/util/MultiKeyMap.d.ts +34 -0
- package/dist/cjs/util/MultiKeyMap.js +530 -0
- package/dist/cjs/util/MultiValueMap.d.ts +35 -0
- package/dist/cjs/util/MultiValueMap.js +527 -0
- package/dist/cjs/util/RangeMap.d.ts +36 -0
- package/dist/cjs/util/RangeMap.js +584 -0
- package/dist/cjs/util/ReadonlyMultiKeyMap.d.ts +27 -0
- package/dist/cjs/util/ReadonlyMultiKeyMap.js +364 -0
- package/dist/cjs/util/ReadonlyMultiValueMap.d.ts +27 -0
- package/dist/cjs/util/ReadonlyMultiValueMap.js +365 -0
- package/dist/cjs/util/ReadonlyRangeMap.d.ts +27 -0
- package/dist/cjs/util/ReadonlyRangeMap.js +376 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/type/declaration.d.ts +10 -0
- package/dist/esm/type/declaration.js +1 -0
- package/dist/esm/util/MultiKeyMap.d.ts +34 -0
- package/dist/esm/util/MultiKeyMap.js +318 -0
- package/dist/esm/util/MultiValueMap.d.ts +35 -0
- package/dist/esm/util/MultiValueMap.js +328 -0
- package/dist/esm/util/RangeMap.d.ts +36 -0
- package/dist/esm/util/RangeMap.js +358 -0
- package/dist/esm/util/ReadonlyMultiKeyMap.d.ts +27 -0
- package/dist/esm/util/ReadonlyMultiKeyMap.js +136 -0
- package/dist/esm/util/ReadonlyMultiValueMap.d.ts +27 -0
- package/dist/esm/util/ReadonlyMultiValueMap.js +136 -0
- package/dist/esm/util/ReadonlyRangeMap.d.ts +27 -0
- package/dist/esm/util/ReadonlyRangeMap.js +135 -0
- package/dist/umd/ts-multi-map.min.js +1 -0
- package/package.json +111 -5
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type RangeMapKey } from "..";
|
|
2
|
+
export declare class RangeMap<V> implements Omit<Map<RangeMapKey, V>, 'delete' | 'forEach' | 'get' | 'has' | 'set' | 'entries' | 'keys' | 'values' | 'push'> {
|
|
3
|
+
private readonly keyMap;
|
|
4
|
+
private readonly valueMap;
|
|
5
|
+
static of<V>(entries?: [RangeMapKey | [number, number] | [number, number, boolean, boolean], V][], validation?: boolean): RangeMap<V>;
|
|
6
|
+
constructor(entries?: [RangeMapKey | [number, number] | [number, number, boolean, boolean], V][], validation?: boolean);
|
|
7
|
+
get(key: RangeMapKey | [number, number] | [number, number, boolean, boolean], defaults?: V): V | undefined;
|
|
8
|
+
getByDigit(digit: number, defaults?: V): V | undefined;
|
|
9
|
+
set(key: RangeMapKey | [number, number] | [number, number, boolean, boolean], value: V, validation?: boolean): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
keys(): RangeMapKey[];
|
|
12
|
+
values(): V[];
|
|
13
|
+
entries(): [RangeMapKey, V][];
|
|
14
|
+
deleteByKey(key: RangeMapKey | [number, number] | [number, number, boolean, boolean]): boolean;
|
|
15
|
+
deleteByKeys(keys: Array<RangeMapKey | [number, number] | [number, number, boolean, boolean]>): boolean;
|
|
16
|
+
deleteByValue(value: V): boolean;
|
|
17
|
+
deleteByValues(values: V[]): boolean;
|
|
18
|
+
forEach(callback: (value?: V, key?: RangeMapKey) => void, thisArg?: any): void;
|
|
19
|
+
forEachIndexing(callback: (value?: V, key?: RangeMapKey, index?: number) => void, thisArg?: any): void;
|
|
20
|
+
forEachBreakable(callback: (value?: V, key?: RangeMapKey) => boolean, thisArg?: any): void;
|
|
21
|
+
hasKey(key: RangeMapKey | [number, number] | [number, number, boolean, boolean]): boolean;
|
|
22
|
+
hasKeyValue(key: RangeMapKey | [number, number] | [number, number, boolean, boolean], value: V): boolean;
|
|
23
|
+
hasAnyKeys(keys: Array<RangeMapKey | [number, number] | [number, number, boolean, boolean]>): boolean;
|
|
24
|
+
hasAllKeys(keys: Array<RangeMapKey | [number, number] | [number, number, boolean, boolean]>): boolean;
|
|
25
|
+
hasValue(value: V): boolean;
|
|
26
|
+
hasAnyValues(values: V[]): boolean;
|
|
27
|
+
hasAllValues(values: V[]): boolean;
|
|
28
|
+
isEmpty(): boolean;
|
|
29
|
+
isNotEmpty(): boolean;
|
|
30
|
+
[Symbol.iterator](): IterableIterator<[RangeMapKey, V]>;
|
|
31
|
+
get size(): number;
|
|
32
|
+
get [Symbol.toStringTag](): string;
|
|
33
|
+
toString(): string;
|
|
34
|
+
private toInternalKey;
|
|
35
|
+
private checkRangeConflict;
|
|
36
|
+
}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
+
var _Symbol$iterator, _Symbol$toStringTag;
|
|
8
|
+
import objectHash from 'object-hash';
|
|
9
|
+
_Symbol$iterator = Symbol.iterator;
|
|
10
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
11
|
+
export var RangeMap = /*#__PURE__*/function () {
|
|
12
|
+
function RangeMap(entries) {
|
|
13
|
+
var _this = this;
|
|
14
|
+
var validation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
15
|
+
_classCallCheck(this, RangeMap);
|
|
16
|
+
_defineProperty(this, "keyMap", new Map());
|
|
17
|
+
_defineProperty(this, "valueMap", new Map());
|
|
18
|
+
entries === null || entries === void 0 || entries.forEach(function (entry) {
|
|
19
|
+
var _entry = _slicedToArray(entry, 2),
|
|
20
|
+
k = _entry[0],
|
|
21
|
+
v = _entry[1];
|
|
22
|
+
_this.set(k, v, validation);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
_createClass(RangeMap, [{
|
|
26
|
+
key: "get",
|
|
27
|
+
value: function get(key, defaults) {
|
|
28
|
+
var _this$valueMap$get;
|
|
29
|
+
var hash = objectHash(this.toInternalKey(key));
|
|
30
|
+
return (_this$valueMap$get = this.valueMap.get(hash)) !== null && _this$valueMap$get !== void 0 ? _this$valueMap$get : defaults;
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "getByDigit",
|
|
34
|
+
value: function getByDigit(digit, defaults) {
|
|
35
|
+
if (this.isEmpty()) {
|
|
36
|
+
return defaults;
|
|
37
|
+
}
|
|
38
|
+
var _iterator = _createForOfIteratorHelper(this.keyMap.entries()),
|
|
39
|
+
_step;
|
|
40
|
+
try {
|
|
41
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
42
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
43
|
+
k = _step$value[0],
|
|
44
|
+
v = _step$value[1];
|
|
45
|
+
if ((v.startInclusive ? digit >= v.start : digit > v.start) && (v.endInclusive ? digit <= v.end : digit < v.end)) {
|
|
46
|
+
return this.valueMap.get(k);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} catch (err) {
|
|
50
|
+
_iterator.e(err);
|
|
51
|
+
} finally {
|
|
52
|
+
_iterator.f();
|
|
53
|
+
}
|
|
54
|
+
return defaults;
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "set",
|
|
58
|
+
value: function set(key, value) {
|
|
59
|
+
var validation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
60
|
+
var alias = this.toInternalKey(key);
|
|
61
|
+
if (alias.start > alias.end || alias.start === alias.end && !alias.startInclusive && !alias.endInclusive) {
|
|
62
|
+
throw RangeError("Range start ".concat(alias.start, " must be less than or equal to it's end ").concat(alias.end));
|
|
63
|
+
}
|
|
64
|
+
if (validation) {
|
|
65
|
+
this.checkRangeConflict(alias);
|
|
66
|
+
}
|
|
67
|
+
var hash = objectHash(alias);
|
|
68
|
+
this.keyMap.set(hash, alias);
|
|
69
|
+
this.valueMap.set(hash, value);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "clear",
|
|
73
|
+
value: function clear() {
|
|
74
|
+
this.keyMap.clear();
|
|
75
|
+
this.valueMap.clear();
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "keys",
|
|
79
|
+
value: function keys() {
|
|
80
|
+
return _toConsumableArray(this.keyMap.values());
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "values",
|
|
84
|
+
value: function values() {
|
|
85
|
+
return _toConsumableArray(this.valueMap.values());
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
88
|
+
key: "entries",
|
|
89
|
+
value: function entries() {
|
|
90
|
+
if (this.isEmpty()) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
if (this.keyMap.size !== this.valueMap.size) {
|
|
94
|
+
throw EvalError("Internal maps size mismatch!");
|
|
95
|
+
}
|
|
96
|
+
var result = [];
|
|
97
|
+
var _iterator2 = _createForOfIteratorHelper(this.valueMap),
|
|
98
|
+
_step2;
|
|
99
|
+
try {
|
|
100
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
101
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
102
|
+
k = _step2$value[0],
|
|
103
|
+
v = _step2$value[1];
|
|
104
|
+
result.push([this.keyMap.get(k), v]);
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
_iterator2.e(err);
|
|
108
|
+
} finally {
|
|
109
|
+
_iterator2.f();
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "deleteByKey",
|
|
115
|
+
value: function deleteByKey(key) {
|
|
116
|
+
if (this.isEmpty()) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
var hash = objectHash(this.toInternalKey(key));
|
|
120
|
+
return this.keyMap.delete(hash) && this.valueMap.delete(hash);
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "deleteByKeys",
|
|
124
|
+
value: function deleteByKeys(keys) {
|
|
125
|
+
if (!keys.length || this.isEmpty()) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
var result = false;
|
|
129
|
+
var _iterator3 = _createForOfIteratorHelper(keys),
|
|
130
|
+
_step3;
|
|
131
|
+
try {
|
|
132
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
133
|
+
var _key = _step3.value;
|
|
134
|
+
if (this.deleteByKey(_key)) {
|
|
135
|
+
result = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} catch (err) {
|
|
139
|
+
_iterator3.e(err);
|
|
140
|
+
} finally {
|
|
141
|
+
_iterator3.f();
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "deleteByValue",
|
|
147
|
+
value: function deleteByValue(value) {
|
|
148
|
+
if (this.isEmpty()) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
var result = false;
|
|
152
|
+
var _iterator4 = _createForOfIteratorHelper(this.valueMap.entries()),
|
|
153
|
+
_step4;
|
|
154
|
+
try {
|
|
155
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
156
|
+
var _step4$value = _slicedToArray(_step4.value, 2),
|
|
157
|
+
k = _step4$value[0],
|
|
158
|
+
v = _step4$value[1];
|
|
159
|
+
if (v === value && this.keyMap.delete(k) && this.valueMap.delete(k)) {
|
|
160
|
+
result = true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} catch (err) {
|
|
164
|
+
_iterator4.e(err);
|
|
165
|
+
} finally {
|
|
166
|
+
_iterator4.f();
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
key: "deleteByValues",
|
|
172
|
+
value: function deleteByValues(values) {
|
|
173
|
+
if (!values.length || this.isEmpty()) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
var result = false;
|
|
177
|
+
var _iterator5 = _createForOfIteratorHelper(values),
|
|
178
|
+
_step5;
|
|
179
|
+
try {
|
|
180
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
181
|
+
var _value = _step5.value;
|
|
182
|
+
if (this.deleteByValue(_value)) {
|
|
183
|
+
result = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} catch (err) {
|
|
187
|
+
_iterator5.e(err);
|
|
188
|
+
} finally {
|
|
189
|
+
_iterator5.f();
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "forEach",
|
|
195
|
+
value: function forEach(callback, thisArg) {
|
|
196
|
+
this.entries().forEach(function (entry) {
|
|
197
|
+
var _entry2 = _slicedToArray(entry, 2),
|
|
198
|
+
k = _entry2[0],
|
|
199
|
+
v = _entry2[1];
|
|
200
|
+
callback(v, k);
|
|
201
|
+
}, thisArg);
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "forEachIndexing",
|
|
205
|
+
value: function forEachIndexing(callback, thisArg) {
|
|
206
|
+
var index = 0;
|
|
207
|
+
this.entries().forEach(function (entry) {
|
|
208
|
+
var _entry3 = _slicedToArray(entry, 2),
|
|
209
|
+
k = _entry3[0],
|
|
210
|
+
v = _entry3[1];
|
|
211
|
+
callback(v, k, index++);
|
|
212
|
+
}, thisArg);
|
|
213
|
+
}
|
|
214
|
+
}, {
|
|
215
|
+
key: "forEachBreakable",
|
|
216
|
+
value: function forEachBreakable(callback, thisArg) {
|
|
217
|
+
this.entries().forEach(function (entry) {
|
|
218
|
+
var _entry4 = _slicedToArray(entry, 2),
|
|
219
|
+
k = _entry4[0],
|
|
220
|
+
v = _entry4[1];
|
|
221
|
+
if (!callback(v, k)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
}, thisArg);
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
key: "hasKey",
|
|
228
|
+
value: function hasKey(key) {
|
|
229
|
+
return this.isNotEmpty() && this.keyMap.has(objectHash(this.toInternalKey(key)));
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "hasKeyValue",
|
|
233
|
+
value: function hasKeyValue(key, value) {
|
|
234
|
+
return this.isNotEmpty() && this.get(key) === value;
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
key: "hasAnyKeys",
|
|
238
|
+
value: function hasAnyKeys(keys) {
|
|
239
|
+
var _this2 = this;
|
|
240
|
+
return this.isNotEmpty() && keys.length > 0 && keys.some(function (item) {
|
|
241
|
+
return _this2.hasKey(item);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}, {
|
|
245
|
+
key: "hasAllKeys",
|
|
246
|
+
value: function hasAllKeys(keys) {
|
|
247
|
+
var _this3 = this;
|
|
248
|
+
return this.isNotEmpty() && keys.length > 0 && keys.every(function (item) {
|
|
249
|
+
return _this3.hasKey(item);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}, {
|
|
253
|
+
key: "hasValue",
|
|
254
|
+
value: function hasValue(value) {
|
|
255
|
+
return this.isNotEmpty() && this.values().includes(value);
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "hasAnyValues",
|
|
259
|
+
value: function hasAnyValues(values) {
|
|
260
|
+
var _this4 = this;
|
|
261
|
+
return this.isNotEmpty() && values.length > 0 && values.some(function (item) {
|
|
262
|
+
return _this4.hasValue(item);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
key: "hasAllValues",
|
|
267
|
+
value: function hasAllValues(values) {
|
|
268
|
+
var _this5 = this;
|
|
269
|
+
return this.isNotEmpty() && values.length > 0 && values.every(function (item) {
|
|
270
|
+
return _this5.hasValue(item);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}, {
|
|
274
|
+
key: "isEmpty",
|
|
275
|
+
value: function isEmpty() {
|
|
276
|
+
return !this.valueMap.size;
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "isNotEmpty",
|
|
280
|
+
value: function isNotEmpty() {
|
|
281
|
+
return this.valueMap.size > 0;
|
|
282
|
+
}
|
|
283
|
+
}, {
|
|
284
|
+
key: _Symbol$iterator,
|
|
285
|
+
value: function value() {
|
|
286
|
+
return this.entries()[Symbol.iterator]();
|
|
287
|
+
}
|
|
288
|
+
}, {
|
|
289
|
+
key: "size",
|
|
290
|
+
get: function get() {
|
|
291
|
+
return this.valueMap.size;
|
|
292
|
+
}
|
|
293
|
+
}, {
|
|
294
|
+
key: _Symbol$toStringTag,
|
|
295
|
+
get: function get() {
|
|
296
|
+
return 'RangeMap';
|
|
297
|
+
}
|
|
298
|
+
}, {
|
|
299
|
+
key: "toString",
|
|
300
|
+
value: function toString() {
|
|
301
|
+
return _toConsumableArray(this).map(function (entry) {
|
|
302
|
+
var _ref = entry,
|
|
303
|
+
_ref2 = _slicedToArray(_ref, 2),
|
|
304
|
+
k = _ref2[0],
|
|
305
|
+
v = _ref2[1];
|
|
306
|
+
var ks = Object.keys(k).map(function (item) {
|
|
307
|
+
return "".concat(item, ":").concat(k[item]);
|
|
308
|
+
}).join();
|
|
309
|
+
return "[".concat(ks, "]:").concat(v);
|
|
310
|
+
}).join(';');
|
|
311
|
+
}
|
|
312
|
+
}, {
|
|
313
|
+
key: "toInternalKey",
|
|
314
|
+
value: function toInternalKey(key) {
|
|
315
|
+
return !Array.isArray(key) ? key : {
|
|
316
|
+
start: key.length > 0 ? key[0] : 0,
|
|
317
|
+
end: key.length > 1 ? key[1] : 0,
|
|
318
|
+
startInclusive: key.length > 2 ? key[2] : true,
|
|
319
|
+
endInclusive: key.length > 3 ? key[3] : false
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}, {
|
|
323
|
+
key: "checkRangeConflict",
|
|
324
|
+
value: function checkRangeConflict(key) {
|
|
325
|
+
if (this.isEmpty()) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
var keyExpress = "".concat(key.startInclusive ? '[' : '(').concat(key.start, ",").concat(key.end).concat(key.endInclusive ? ']' : ')');
|
|
329
|
+
var _iterator6 = _createForOfIteratorHelper(this.keyMap.values()),
|
|
330
|
+
_step6;
|
|
331
|
+
try {
|
|
332
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
333
|
+
var k = _step6.value;
|
|
334
|
+
var kExpress = "".concat(k.startInclusive ? '[' : '(').concat(k.start, ",").concat(k.end).concat(k.endInclusive ? ']' : ')');
|
|
335
|
+
if (key.start <= k.start && key.end >= k.end) {
|
|
336
|
+
throw RangeError("Range ".concat(keyExpress, " must not override the range ").concat(kExpress));
|
|
337
|
+
}
|
|
338
|
+
var badStart = (key.startInclusive ? key.start >= k.start : key.start > k.start) && (key.startInclusive && k.endInclusive ? key.start <= k.end : key.start < k.end);
|
|
339
|
+
var badEnd = (key.endInclusive && k.startInclusive ? key.end >= k.start : key.end > k.start) && key.end <= k.end;
|
|
340
|
+
if (badStart || badEnd) {
|
|
341
|
+
throw RangeError("Range ".concat(keyExpress, " must not intersect the range ").concat(kExpress));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
} catch (err) {
|
|
345
|
+
_iterator6.e(err);
|
|
346
|
+
} finally {
|
|
347
|
+
_iterator6.f();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}], [{
|
|
351
|
+
key: "of",
|
|
352
|
+
value: function of(entries) {
|
|
353
|
+
var validation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
354
|
+
return new RangeMap(entries, validation);
|
|
355
|
+
}
|
|
356
|
+
}]);
|
|
357
|
+
return RangeMap;
|
|
358
|
+
}();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type MultiKeyMapEntries } from "..";
|
|
2
|
+
export declare class ReadonlyMultiKeyMap<K, V> implements Omit<ReadonlyMap<K[], V>, 'forEach' | 'get' | 'has' | 'entries' | 'keys' | 'values'> {
|
|
3
|
+
private readonly map;
|
|
4
|
+
static of<K, V>(entries?: MultiKeyMapEntries<K, V>): ReadonlyMultiKeyMap<K, V>;
|
|
5
|
+
constructor(entries?: MultiKeyMapEntries<K, V>);
|
|
6
|
+
get(keys: K[], defaults?: V): V | undefined;
|
|
7
|
+
keys(): K[][];
|
|
8
|
+
values(): V[];
|
|
9
|
+
entries(): [K[], V][];
|
|
10
|
+
forEach(callback: (value?: V, keys?: K[]) => void, thisArg?: any): void;
|
|
11
|
+
forEachIndexing(callback: (value?: V, keys?: K[], index?: number) => void, thisArg?: any): void;
|
|
12
|
+
forEachBreakable(callback: (value?: V, keys?: K[]) => boolean, thisArg?: any): void;
|
|
13
|
+
hasKey(keys: K[], exact?: boolean): boolean;
|
|
14
|
+
hasKeyValue(keys: K[], value: V): boolean;
|
|
15
|
+
hasAnyKeys(keys: K[][], exact?: boolean): boolean;
|
|
16
|
+
hasAllKeys(keys: K[][], exact?: boolean): boolean;
|
|
17
|
+
hasValue(value: V): boolean;
|
|
18
|
+
hasAnyValues(values: V[]): boolean;
|
|
19
|
+
hasAllValues(values: V[]): boolean;
|
|
20
|
+
isEmpty(): boolean;
|
|
21
|
+
isNotEmpty(): boolean;
|
|
22
|
+
getKey(value: V, defaults?: K[]): K[] | undefined;
|
|
23
|
+
[Symbol.iterator](): IterableIterator<[K[], V]>;
|
|
24
|
+
get size(): number;
|
|
25
|
+
get [Symbol.toStringTag](): string;
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
+
var _Symbol$iterator, _Symbol$toStringTag;
|
|
6
|
+
import { MultiKeyMap } from "./..";
|
|
7
|
+
_Symbol$iterator = Symbol.iterator;
|
|
8
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
9
|
+
export var ReadonlyMultiKeyMap = /*#__PURE__*/function () {
|
|
10
|
+
function ReadonlyMultiKeyMap(entries) {
|
|
11
|
+
var _this = this;
|
|
12
|
+
_classCallCheck(this, ReadonlyMultiKeyMap);
|
|
13
|
+
_defineProperty(this, "map", new MultiKeyMap());
|
|
14
|
+
entries === null || entries === void 0 || entries.forEach(function (entry) {
|
|
15
|
+
var _entry = _slicedToArray(entry, 2),
|
|
16
|
+
ks = _entry[0],
|
|
17
|
+
v = _entry[1];
|
|
18
|
+
_this.map.set(ks, v);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
_createClass(ReadonlyMultiKeyMap, [{
|
|
22
|
+
key: "get",
|
|
23
|
+
value: function get(keys, defaults) {
|
|
24
|
+
return this.map.get(keys, defaults);
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
key: "keys",
|
|
28
|
+
value: function keys() {
|
|
29
|
+
return this.map.keys();
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
key: "values",
|
|
33
|
+
value: function values() {
|
|
34
|
+
return this.map.values();
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "entries",
|
|
38
|
+
value: function entries() {
|
|
39
|
+
return this.map.entries();
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "forEach",
|
|
43
|
+
value: function forEach(callback, thisArg) {
|
|
44
|
+
this.map.forEach(callback, thisArg);
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "forEachIndexing",
|
|
48
|
+
value: function forEachIndexing(callback, thisArg) {
|
|
49
|
+
this.map.forEachIndexing(callback, thisArg);
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "forEachBreakable",
|
|
53
|
+
value: function forEachBreakable(callback, thisArg) {
|
|
54
|
+
this.map.forEachBreakable(callback, thisArg);
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "hasKey",
|
|
58
|
+
value: function hasKey(keys) {
|
|
59
|
+
var exact = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
60
|
+
return this.map.hasKey(keys, exact);
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "hasKeyValue",
|
|
64
|
+
value: function hasKeyValue(keys, value) {
|
|
65
|
+
return this.map.hasKeyValue(keys, value);
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "hasAnyKeys",
|
|
69
|
+
value: function hasAnyKeys(keys) {
|
|
70
|
+
var exact = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
71
|
+
return this.map.hasAnyKeys(keys, exact);
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "hasAllKeys",
|
|
75
|
+
value: function hasAllKeys(keys) {
|
|
76
|
+
var exact = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
77
|
+
return this.map.hasAllKeys(keys, exact);
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "hasValue",
|
|
81
|
+
value: function hasValue(value) {
|
|
82
|
+
return this.map.hasValue(value);
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "hasAnyValues",
|
|
86
|
+
value: function hasAnyValues(values) {
|
|
87
|
+
return this.map.hasAnyValues(values);
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "hasAllValues",
|
|
91
|
+
value: function hasAllValues(values) {
|
|
92
|
+
return this.map.hasAllValues(values);
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "isEmpty",
|
|
96
|
+
value: function isEmpty() {
|
|
97
|
+
return this.map.isEmpty();
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "isNotEmpty",
|
|
101
|
+
value: function isNotEmpty() {
|
|
102
|
+
return this.map.isNotEmpty();
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "getKey",
|
|
106
|
+
value: function getKey(value, defaults) {
|
|
107
|
+
return this.map.getKey(value, defaults);
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: _Symbol$iterator,
|
|
111
|
+
value: function value() {
|
|
112
|
+
return this.map[Symbol.iterator]();
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "size",
|
|
116
|
+
get: function get() {
|
|
117
|
+
return this.map.size;
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: _Symbol$toStringTag,
|
|
121
|
+
get: function get() {
|
|
122
|
+
return 'ReadonlyMultiKeyMap';
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
key: "toString",
|
|
126
|
+
value: function toString() {
|
|
127
|
+
return this.map.toString();
|
|
128
|
+
}
|
|
129
|
+
}], [{
|
|
130
|
+
key: "of",
|
|
131
|
+
value: function of(entries) {
|
|
132
|
+
return new ReadonlyMultiKeyMap(entries);
|
|
133
|
+
}
|
|
134
|
+
}]);
|
|
135
|
+
return ReadonlyMultiKeyMap;
|
|
136
|
+
}();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type MultiValueMapEntries } from "..";
|
|
2
|
+
export declare class ReadonlyMultiValueMap<K, V> implements Omit<ReadonlyMap<K, V[]>, 'forEach' | 'get' | 'has' | 'entries' | 'keys' | 'values'> {
|
|
3
|
+
private readonly map;
|
|
4
|
+
static of<K, V>(entries?: MultiValueMapEntries<K, V>): ReadonlyMultiValueMap<K, V>;
|
|
5
|
+
constructor(entries?: MultiValueMapEntries<K, V>);
|
|
6
|
+
get(key: K, defaults?: V[]): V[] | undefined;
|
|
7
|
+
keys(): K[];
|
|
8
|
+
values(): V[][];
|
|
9
|
+
entries(): [K, V[]][];
|
|
10
|
+
forEach(callback: (values?: V[], key?: K) => void, thisArg?: any): void;
|
|
11
|
+
forEachIndexing(callback: (values?: V[], key?: K, index?: number) => void, thisArg?: any): void;
|
|
12
|
+
forEachBreakable(callback: (values?: V[], key?: K) => boolean, thisArg?: any): void;
|
|
13
|
+
hasKey(key: K): boolean;
|
|
14
|
+
hasKeyValue(key: K, value: V): boolean;
|
|
15
|
+
hasAnyKeys(keys: K[]): boolean;
|
|
16
|
+
hasAllKeys(keys: K[]): boolean;
|
|
17
|
+
hasValue(values: V[], exact?: boolean): boolean;
|
|
18
|
+
hasAnyValues(values: V[][], exact?: boolean): boolean;
|
|
19
|
+
hasAllValues(values: V[][], exact?: boolean): boolean;
|
|
20
|
+
isEmpty(): boolean;
|
|
21
|
+
isNotEmpty(): boolean;
|
|
22
|
+
getKey(values: V[], defaults?: K): K | undefined;
|
|
23
|
+
[Symbol.iterator](): IterableIterator<[K, V[]]>;
|
|
24
|
+
get size(): number;
|
|
25
|
+
get [Symbol.toStringTag](): string;
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|