@bemoje/map 1.2.1 → 1.2.3
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/README.md +23 -21
- package/lib/index.cjs +33 -122
- package/lib/index.d.cts +364 -17
- package/lib/index.d.ts +364 -17
- package/lib/index.js +15 -104
- package/package.json +21 -221
- package/lib/ExtMap.cjs +0 -354
- package/lib/ExtMap.d.cts +0 -110
- package/lib/ExtMap.d.ts +0 -110
- package/lib/ExtMap.js +0 -352
- package/lib/TimeoutWeakMap.cjs +0 -122
- package/lib/TimeoutWeakMap.d.cts +0 -75
- package/lib/TimeoutWeakMap.d.ts +0 -75
- package/lib/TimeoutWeakMap.js +0 -120
- package/lib/countUniques.cjs +0 -363
- package/lib/countUniques.d.cts +0 -9
- package/lib/countUniques.d.ts +0 -9
- package/lib/countUniques.js +0 -361
- package/lib/entriesArray.cjs +0 -12
- package/lib/entriesArray.d.cts +0 -19
- package/lib/entriesArray.d.ts +0 -19
- package/lib/entriesArray.js +0 -10
- package/lib/isGenericMap.cjs +0 -18
- package/lib/isGenericMap.d.cts +0 -6
- package/lib/isGenericMap.d.ts +0 -6
- package/lib/isGenericMap.js +0 -16
- package/lib/keysArray.cjs +0 -12
- package/lib/keysArray.d.cts +0 -19
- package/lib/keysArray.d.ts +0 -19
- package/lib/keysArray.js +0 -10
- package/lib/mapGetOrDefault.cjs +0 -18
- package/lib/mapGetOrDefault.d.cts +0 -8
- package/lib/mapGetOrDefault.d.ts +0 -8
- package/lib/mapGetOrDefault.js +0 -16
- package/lib/mapLoad.cjs +0 -15
- package/lib/mapLoad.d.cts +0 -11
- package/lib/mapLoad.d.ts +0 -11
- package/lib/mapLoad.js +0 -13
- package/lib/mapReverse.cjs +0 -24
- package/lib/mapReverse.d.cts +0 -15
- package/lib/mapReverse.d.ts +0 -15
- package/lib/mapReverse.js +0 -22
- package/lib/mapUpdate.cjs +0 -14
- package/lib/mapUpdate.d.cts +0 -13
- package/lib/mapUpdate.d.ts +0 -13
- package/lib/mapUpdate.js +0 -12
- package/lib/sort.cjs +0 -17
- package/lib/sort.d.cts +0 -25
- package/lib/sort.d.ts +0 -25
- package/lib/sort.js +0 -15
- package/lib/sortByKeys.cjs +0 -19
- package/lib/sortByKeys.d.cts +0 -24
- package/lib/sortByKeys.d.ts +0 -24
- package/lib/sortByKeys.js +0 -17
- package/lib/sortByValues.cjs +0 -19
- package/lib/sortByValues.d.cts +0 -25
- package/lib/sortByValues.d.ts +0 -25
- package/lib/sortByValues.js +0 -17
- package/lib/toMap.cjs +0 -12
- package/lib/toMap.d.cts +0 -20
- package/lib/toMap.d.ts +0 -20
- package/lib/toMap.js +0 -10
- package/lib/valuesArray.cjs +0 -12
- package/lib/valuesArray.d.cts +0 -19
- package/lib/valuesArray.d.ts +0 -19
- package/lib/valuesArray.js +0 -10
package/lib/countUniques.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { isIterable, map, filter, reduce } from 'iter-tools';
|
|
2
|
-
import { inspect } from 'util';
|
|
3
|
-
import { MultiSet } from 'mnemonist';
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
|
|
8
|
-
// ../object/src/defineMethod.ts
|
|
9
|
-
function defineMethod(obj, key, value, des = {}) {
|
|
10
|
-
return Object.defineProperty(obj, key, {
|
|
11
|
-
value,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
enumerable: false,
|
|
15
|
-
...des
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
__name(defineMethod, "defineMethod");
|
|
19
|
-
|
|
20
|
-
// ../object/src/entriesOf.ts
|
|
21
|
-
function entriesOf(obj) {
|
|
22
|
-
return Object.entries(obj);
|
|
23
|
-
}
|
|
24
|
-
__name(entriesOf, "entriesOf");
|
|
25
|
-
|
|
26
|
-
// ../composition/src/View.ts
|
|
27
|
-
var TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
|
|
28
|
-
var View = class {
|
|
29
|
-
static {
|
|
30
|
-
__name(this, "View");
|
|
31
|
-
}
|
|
32
|
-
[TARGET_SYMBOL];
|
|
33
|
-
constructor(target) {
|
|
34
|
-
this[TARGET_SYMBOL] = target;
|
|
35
|
-
}
|
|
36
|
-
get [Symbol.toStringTag]() {
|
|
37
|
-
return this.constructor.name;
|
|
38
|
-
}
|
|
39
|
-
get target() {
|
|
40
|
-
return this[TARGET_SYMBOL];
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// ../composition/src/inheritProxifiedPrototypeProperty.ts
|
|
45
|
-
function inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, key) {
|
|
46
|
-
const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key);
|
|
47
|
-
if (!des) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (des.value && typeof des.value === "function") {
|
|
51
|
-
return Object.defineProperty(ViewerClass.prototype, key, {
|
|
52
|
-
value(...args) {
|
|
53
|
-
return this.target[key](...args);
|
|
54
|
-
},
|
|
55
|
-
writable: true,
|
|
56
|
-
configurable: true,
|
|
57
|
-
enumerable: false
|
|
58
|
-
});
|
|
59
|
-
} else if (des && !des.get && !des.set) {
|
|
60
|
-
return Object.defineProperty(ViewerClass.prototype, key, {
|
|
61
|
-
get() {
|
|
62
|
-
return this.target[key];
|
|
63
|
-
},
|
|
64
|
-
set: des.writable ? /* @__PURE__ */ __name(function set(value) {
|
|
65
|
-
this.target[key] = value;
|
|
66
|
-
}, "set") : void 0,
|
|
67
|
-
configurable: true,
|
|
68
|
-
enumerable: false
|
|
69
|
-
});
|
|
70
|
-
} else {
|
|
71
|
-
Object.defineProperty(ViewerClass.prototype, key, {
|
|
72
|
-
get: des.get ? function() {
|
|
73
|
-
return this.target[key];
|
|
74
|
-
} : void 0,
|
|
75
|
-
set: des.set ? function(value) {
|
|
76
|
-
this.target[key] = value;
|
|
77
|
-
} : void 0,
|
|
78
|
-
configurable: true,
|
|
79
|
-
enumerable: false
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
__name(inheritProxifiedPrototypeProperty, "inheritProxifiedPrototypeProperty");
|
|
84
|
-
|
|
85
|
-
// ../composition/src/inheritProxifiedPrototype.ts
|
|
86
|
-
function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
|
|
87
|
-
Reflect.ownKeys(TargetClass.prototype).filter((k) => {
|
|
88
|
-
return k !== "constructor" && k !== Symbol.toStringTag;
|
|
89
|
-
}).filter((k) => {
|
|
90
|
-
return omitKeys ? !omitKeys.includes(k) : true;
|
|
91
|
-
}).forEach((k) => {
|
|
92
|
-
return inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k);
|
|
93
|
-
});
|
|
94
|
-
return ViewerClass;
|
|
95
|
-
}
|
|
96
|
-
__name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
|
|
97
|
-
|
|
98
|
-
// src/entriesArray.ts
|
|
99
|
-
function entriesArray(ins) {
|
|
100
|
-
return Array.from(ins);
|
|
101
|
-
}
|
|
102
|
-
__name(entriesArray, "entriesArray");
|
|
103
|
-
function filterIterableValues(mapLike, predicate) {
|
|
104
|
-
return filter(([k, v]) => {
|
|
105
|
-
return predicate(v, k);
|
|
106
|
-
}, mapLike);
|
|
107
|
-
}
|
|
108
|
-
__name(filterIterableValues, "filterIterableValues");
|
|
109
|
-
|
|
110
|
-
// src/keysArray.ts
|
|
111
|
-
function keysArray(ins) {
|
|
112
|
-
return Array.from(ins.keys());
|
|
113
|
-
}
|
|
114
|
-
__name(keysArray, "keysArray");
|
|
115
|
-
|
|
116
|
-
// src/mapGetOrDefault.ts
|
|
117
|
-
function mapGetOrDefault(map3, key, factory) {
|
|
118
|
-
let value = map3.get(key);
|
|
119
|
-
if (value !== void 0 || map3.has(key)) {
|
|
120
|
-
return value;
|
|
121
|
-
}
|
|
122
|
-
value = factory(key, map3);
|
|
123
|
-
map3.set(key, value);
|
|
124
|
-
return value;
|
|
125
|
-
}
|
|
126
|
-
__name(mapGetOrDefault, "mapGetOrDefault");
|
|
127
|
-
function mapIterableKeys(mapLike, mapper) {
|
|
128
|
-
return map(([k, v]) => {
|
|
129
|
-
return [
|
|
130
|
-
mapper(k, v),
|
|
131
|
-
v
|
|
132
|
-
];
|
|
133
|
-
}, mapLike);
|
|
134
|
-
}
|
|
135
|
-
__name(mapIterableKeys, "mapIterableKeys");
|
|
136
|
-
function mapIterableValues(mapLike, mapper) {
|
|
137
|
-
return map(([k, v]) => {
|
|
138
|
-
return [
|
|
139
|
-
k,
|
|
140
|
-
mapper(v, k)
|
|
141
|
-
];
|
|
142
|
-
}, mapLike);
|
|
143
|
-
}
|
|
144
|
-
__name(mapIterableValues, "mapIterableValues");
|
|
145
|
-
|
|
146
|
-
// src/mapLoad.ts
|
|
147
|
-
function mapLoad(ins, entries) {
|
|
148
|
-
for (const [key, value] of entries) {
|
|
149
|
-
ins.set(key, value);
|
|
150
|
-
}
|
|
151
|
-
return ins;
|
|
152
|
-
}
|
|
153
|
-
__name(mapLoad, "mapLoad");
|
|
154
|
-
|
|
155
|
-
// src/mapReverse.ts
|
|
156
|
-
function mapReverse(ins) {
|
|
157
|
-
const entries = Array.from(ins).reverse();
|
|
158
|
-
ins.clear();
|
|
159
|
-
mapLoad(ins, entries);
|
|
160
|
-
return ins;
|
|
161
|
-
}
|
|
162
|
-
__name(mapReverse, "mapReverse");
|
|
163
|
-
|
|
164
|
-
// src/mapUpdate.ts
|
|
165
|
-
function mapUpdate(ins, key, update) {
|
|
166
|
-
const newValue = update(ins.get(key), key, ins);
|
|
167
|
-
ins.set(key, newValue);
|
|
168
|
-
return ins;
|
|
169
|
-
}
|
|
170
|
-
__name(mapUpdate, "mapUpdate");
|
|
171
|
-
|
|
172
|
-
// ../iter/src/reduceIterableValues.ts
|
|
173
|
-
function reduceIterableValues(mapLike, reducer, initial) {
|
|
174
|
-
let accumulator = initial;
|
|
175
|
-
for (const [k, v] of mapLike) {
|
|
176
|
-
accumulator = reducer(accumulator, v, k);
|
|
177
|
-
}
|
|
178
|
-
return accumulator;
|
|
179
|
-
}
|
|
180
|
-
__name(reduceIterableValues, "reduceIterableValues");
|
|
181
|
-
|
|
182
|
-
// src/sort.ts
|
|
183
|
-
function sort(ins, compare) {
|
|
184
|
-
const entries = Array.from(ins).sort(compare);
|
|
185
|
-
ins.clear();
|
|
186
|
-
for (const [k, v] of entries) {
|
|
187
|
-
ins.set(k, v);
|
|
188
|
-
}
|
|
189
|
-
return ins;
|
|
190
|
-
}
|
|
191
|
-
__name(sort, "sort");
|
|
192
|
-
|
|
193
|
-
// src/sortByKeys.ts
|
|
194
|
-
function sortByKeys(ins, compare) {
|
|
195
|
-
const entries = Array.from(ins).sort((a, b) => {
|
|
196
|
-
return compare(a[0], b[0]);
|
|
197
|
-
});
|
|
198
|
-
ins.clear();
|
|
199
|
-
for (const [k, v] of entries) {
|
|
200
|
-
ins.set(k, v);
|
|
201
|
-
}
|
|
202
|
-
return ins;
|
|
203
|
-
}
|
|
204
|
-
__name(sortByKeys, "sortByKeys");
|
|
205
|
-
|
|
206
|
-
// src/sortByValues.ts
|
|
207
|
-
function sortByValues(ins, compare) {
|
|
208
|
-
const entries = Array.from(ins).sort((a, b) => {
|
|
209
|
-
return compare(a[1], b[1]);
|
|
210
|
-
});
|
|
211
|
-
ins.clear();
|
|
212
|
-
for (const [k, v] of entries) {
|
|
213
|
-
ins.set(k, v);
|
|
214
|
-
}
|
|
215
|
-
return ins;
|
|
216
|
-
}
|
|
217
|
-
__name(sortByValues, "sortByValues");
|
|
218
|
-
|
|
219
|
-
// ../fn/src/setNameAndLength.ts
|
|
220
|
-
function setNameAndLength(source, target, lengthDelta = 0) {
|
|
221
|
-
return Object.defineProperties(target, {
|
|
222
|
-
name: {
|
|
223
|
-
configurable: true,
|
|
224
|
-
value: source.name
|
|
225
|
-
},
|
|
226
|
-
length: {
|
|
227
|
-
configurable: true,
|
|
228
|
-
value: source.length + lengthDelta
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
__name(setNameAndLength, "setNameAndLength");
|
|
233
|
-
|
|
234
|
-
// ../fn/src/thisify.ts
|
|
235
|
-
function thisify(fn) {
|
|
236
|
-
return setNameAndLength(fn, /* @__PURE__ */ __name(function f(...args) {
|
|
237
|
-
return fn(this, ...args);
|
|
238
|
-
}, "f"), -1);
|
|
239
|
-
}
|
|
240
|
-
__name(thisify, "thisify");
|
|
241
|
-
|
|
242
|
-
// src/toMap.ts
|
|
243
|
-
function toMap(ins) {
|
|
244
|
-
return new Map(ins);
|
|
245
|
-
}
|
|
246
|
-
__name(toMap, "toMap");
|
|
247
|
-
|
|
248
|
-
// ../iter/src/toObjectIterable.ts
|
|
249
|
-
function toObjectIterable(mapLike) {
|
|
250
|
-
const object = {};
|
|
251
|
-
for (const [key, value] of mapLike) {
|
|
252
|
-
if (typeof key !== "string" && typeof key !== "number" && typeof key !== "symbol") {
|
|
253
|
-
object[String(key)] = value;
|
|
254
|
-
} else {
|
|
255
|
-
object[key] = value;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return object;
|
|
259
|
-
}
|
|
260
|
-
__name(toObjectIterable, "toObjectIterable");
|
|
261
|
-
|
|
262
|
-
// ../fn/src/transformReturnValue.ts
|
|
263
|
-
function transformReturnValue(fn, transform) {
|
|
264
|
-
return setNameAndLength(fn, function(...args) {
|
|
265
|
-
const result = fn.apply(this, args);
|
|
266
|
-
return transform(result);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
__name(transformReturnValue, "transformReturnValue");
|
|
270
|
-
|
|
271
|
-
// src/valuesArray.ts
|
|
272
|
-
function valuesArray(ins) {
|
|
273
|
-
return Array.from(ins.values());
|
|
274
|
-
}
|
|
275
|
-
__name(valuesArray, "valuesArray");
|
|
276
|
-
|
|
277
|
-
// src/ExtMap.ts
|
|
278
|
-
var ExtMap = class _ExtMap extends View {
|
|
279
|
-
static {
|
|
280
|
-
__name(this, "ExtMap");
|
|
281
|
-
}
|
|
282
|
-
constructor(arg) {
|
|
283
|
-
super(new Map(isIterable(arg) ? arg : arg ? entriesOf(arg) : void 0));
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Creates a new ExtMap instance from a regular object.
|
|
287
|
-
*
|
|
288
|
-
* @param obj - An object whose key-value pairs will be used to initialize the map
|
|
289
|
-
* @returns A new ExtMap instance containing the entries from the object
|
|
290
|
-
*/
|
|
291
|
-
static fromObject(obj) {
|
|
292
|
-
return new _ExtMap(Object.entries(obj));
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Creates a new ExtMap instance from an iterable of key-value pairs.
|
|
296
|
-
*
|
|
297
|
-
* @param entries - An iterable of key-value pairs to initialize the map
|
|
298
|
-
* @returns A new ExtMap instance containing the provided entries
|
|
299
|
-
*/
|
|
300
|
-
static fromIterable(entries) {
|
|
301
|
-
return new _ExtMap(entries);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Creates a shallow copy of the map.
|
|
305
|
-
*
|
|
306
|
-
* @returns A new ExtMap instance with the same entries
|
|
307
|
-
*/
|
|
308
|
-
clone() {
|
|
309
|
-
return new _ExtMap(this);
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Converts the map to a JSON-serializable format.
|
|
313
|
-
*
|
|
314
|
-
* @returns Array of key-value pairs suitable for JSON serialization
|
|
315
|
-
*/
|
|
316
|
-
toJSON() {
|
|
317
|
-
return [
|
|
318
|
-
...this.entries()
|
|
319
|
-
];
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Custom inspection method for better debugging output.
|
|
323
|
-
*
|
|
324
|
-
* @param _depth - The depth of inspection
|
|
325
|
-
* @param _options - Options for inspection
|
|
326
|
-
* @returns A string representation of the map
|
|
327
|
-
*/
|
|
328
|
-
[inspect.custom](_depth, _options) {
|
|
329
|
-
return inspect(this.target, {
|
|
330
|
-
breakLength: 50
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
inheritProxifiedPrototype(ExtMap, Map, []);
|
|
335
|
-
defineMethod(ExtMap.prototype, "load", thisify(mapLoad));
|
|
336
|
-
defineMethod(ExtMap.prototype, "sort", thisify(sort));
|
|
337
|
-
defineMethod(ExtMap.prototype, "sortByKeys", thisify(sortByKeys));
|
|
338
|
-
defineMethod(ExtMap.prototype, "sortByValues", thisify(sortByValues));
|
|
339
|
-
defineMethod(ExtMap.prototype, "reverse", thisify(mapReverse));
|
|
340
|
-
defineMethod(ExtMap.prototype, "update", thisify(mapUpdate));
|
|
341
|
-
defineMethod(ExtMap.prototype, "getOrDefault", thisify(mapGetOrDefault));
|
|
342
|
-
defineMethod(ExtMap.prototype, "keysArray", thisify(keysArray));
|
|
343
|
-
defineMethod(ExtMap.prototype, "valuesArray", thisify(valuesArray));
|
|
344
|
-
defineMethod(ExtMap.prototype, "entriesArray", thisify(entriesArray));
|
|
345
|
-
defineMethod(ExtMap.prototype, "toObject", thisify(toObjectIterable));
|
|
346
|
-
defineMethod(ExtMap.prototype, "toMap", thisify(toMap));
|
|
347
|
-
defineMethod(ExtMap.prototype, "reduce", thisify(reduceIterableValues));
|
|
348
|
-
defineMethod(ExtMap.prototype, "map", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
|
|
349
|
-
defineMethod(ExtMap.prototype, "mapKeys", thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)));
|
|
350
|
-
defineMethod(ExtMap.prototype, "mapValues", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
|
|
351
|
-
defineMethod(ExtMap.prototype, "filter", thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)));
|
|
352
|
-
function countUniques(input) {
|
|
353
|
-
return new ExtMap(reduce(new MultiSet(), (acc, imp) => {
|
|
354
|
-
return acc.add(imp);
|
|
355
|
-
}, input).multiplicities()).sortByValues((a, b) => {
|
|
356
|
-
return b - a;
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
__name(countUniques, "countUniques");
|
|
360
|
-
|
|
361
|
-
export { countUniques };
|
package/lib/entriesArray.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
|
|
6
|
-
// src/entriesArray.ts
|
|
7
|
-
function entriesArray(ins) {
|
|
8
|
-
return Array.from(ins);
|
|
9
|
-
}
|
|
10
|
-
__name(entriesArray, "entriesArray");
|
|
11
|
-
|
|
12
|
-
exports.entriesArray = entriesArray;
|
package/lib/entriesArray.d.cts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { G as GenericMap } from './GenericMap-B4OM3vGu.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns an array of all key-value pairs in the map.
|
|
5
|
-
* Convenience method that converts the entries iterator to an array.
|
|
6
|
-
*
|
|
7
|
-
* @returns Array of all key-value pairs
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const map = new ExtMap<string, number>()
|
|
12
|
-
* .load([['a', 1], ['b', 2], ['c', 3]])
|
|
13
|
-
*
|
|
14
|
-
* console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
declare function entriesArray<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): [K, V][];
|
|
18
|
-
|
|
19
|
-
export { entriesArray };
|
package/lib/entriesArray.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { G as GenericMap } from './GenericMap-B4OM3vGu.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns an array of all key-value pairs in the map.
|
|
5
|
-
* Convenience method that converts the entries iterator to an array.
|
|
6
|
-
*
|
|
7
|
-
* @returns Array of all key-value pairs
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const map = new ExtMap<string, number>()
|
|
12
|
-
* .load([['a', 1], ['b', 2], ['c', 3]])
|
|
13
|
-
*
|
|
14
|
-
* console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
declare function entriesArray<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): [K, V][];
|
|
18
|
-
|
|
19
|
-
export { entriesArray };
|
package/lib/entriesArray.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/entriesArray.ts
|
|
5
|
-
function entriesArray(ins) {
|
|
6
|
-
return Array.from(ins);
|
|
7
|
-
}
|
|
8
|
-
__name(entriesArray, "entriesArray");
|
|
9
|
-
|
|
10
|
-
export { entriesArray };
|
package/lib/isGenericMap.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
|
|
6
|
-
// src/isGenericMap.ts
|
|
7
|
-
function isGenericMap(target, requiredProps = [
|
|
8
|
-
"get",
|
|
9
|
-
"set",
|
|
10
|
-
"has"
|
|
11
|
-
]) {
|
|
12
|
-
return !!target && requiredProps.every((prop) => {
|
|
13
|
-
return typeof target[prop] === typeof Map.prototype[prop];
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
__name(isGenericMap, "isGenericMap");
|
|
17
|
-
|
|
18
|
-
exports.isGenericMap = isGenericMap;
|
package/lib/isGenericMap.d.cts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the provided value implements the Map interface with the specified required properties.
|
|
3
|
-
*/
|
|
4
|
-
declare function isGenericMap<Props extends (keyof Map<K, V>)[], K, V>(target: unknown, requiredProps?: Props): target is Pick<Map<K, V>, Props[number]>;
|
|
5
|
-
|
|
6
|
-
export { isGenericMap };
|
package/lib/isGenericMap.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the provided value implements the Map interface with the specified required properties.
|
|
3
|
-
*/
|
|
4
|
-
declare function isGenericMap<Props extends (keyof Map<K, V>)[], K, V>(target: unknown, requiredProps?: Props): target is Pick<Map<K, V>, Props[number]>;
|
|
5
|
-
|
|
6
|
-
export { isGenericMap };
|
package/lib/isGenericMap.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/isGenericMap.ts
|
|
5
|
-
function isGenericMap(target, requiredProps = [
|
|
6
|
-
"get",
|
|
7
|
-
"set",
|
|
8
|
-
"has"
|
|
9
|
-
]) {
|
|
10
|
-
return !!target && requiredProps.every((prop) => {
|
|
11
|
-
return typeof target[prop] === typeof Map.prototype[prop];
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
__name(isGenericMap, "isGenericMap");
|
|
15
|
-
|
|
16
|
-
export { isGenericMap };
|
package/lib/keysArray.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
|
|
6
|
-
// src/keysArray.ts
|
|
7
|
-
function keysArray(ins) {
|
|
8
|
-
return Array.from(ins.keys());
|
|
9
|
-
}
|
|
10
|
-
__name(keysArray, "keysArray");
|
|
11
|
-
|
|
12
|
-
exports.keysArray = keysArray;
|
package/lib/keysArray.d.cts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { G as GenericMap } from './GenericMap-B4OM3vGu.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns an array of all keys in the map.
|
|
5
|
-
* Convenience method that converts the keys iterator to an array.
|
|
6
|
-
*
|
|
7
|
-
* @returns Array of all keys
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const map = new ExtMap<string, number>()
|
|
12
|
-
* .load([['a', 1], ['b', 2], ['c', 3]])
|
|
13
|
-
*
|
|
14
|
-
* console.log(keysArray(map)) // ['a', 'b', 'c']
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
declare function keysArray<K, V>(ins: GenericMap<K, V, 'keys'>): K[];
|
|
18
|
-
|
|
19
|
-
export { keysArray };
|
package/lib/keysArray.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { G as GenericMap } from './GenericMap-B4OM3vGu.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns an array of all keys in the map.
|
|
5
|
-
* Convenience method that converts the keys iterator to an array.
|
|
6
|
-
*
|
|
7
|
-
* @returns Array of all keys
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const map = new ExtMap<string, number>()
|
|
12
|
-
* .load([['a', 1], ['b', 2], ['c', 3]])
|
|
13
|
-
*
|
|
14
|
-
* console.log(keysArray(map)) // ['a', 'b', 'c']
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
declare function keysArray<K, V>(ins: GenericMap<K, V, 'keys'>): K[];
|
|
18
|
-
|
|
19
|
-
export { keysArray };
|
package/lib/keysArray.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/keysArray.ts
|
|
5
|
-
function keysArray(ins) {
|
|
6
|
-
return Array.from(ins.keys());
|
|
7
|
-
}
|
|
8
|
-
__name(keysArray, "keysArray");
|
|
9
|
-
|
|
10
|
-
export { keysArray };
|
package/lib/mapGetOrDefault.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
|
|
6
|
-
// src/mapGetOrDefault.ts
|
|
7
|
-
function mapGetOrDefault(map, key, factory) {
|
|
8
|
-
let value = map.get(key);
|
|
9
|
-
if (value !== void 0 || map.has(key)) {
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
value = factory(key, map);
|
|
13
|
-
map.set(key, value);
|
|
14
|
-
return value;
|
|
15
|
-
}
|
|
16
|
-
__name(mapGetOrDefault, "mapGetOrDefault");
|
|
17
|
-
|
|
18
|
-
exports.mapGetOrDefault = mapGetOrDefault;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { G as GenericMap } from './GenericMap-B4OM3vGu.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Gets a value from a map or creates it using a factory function if it doesn't exist.
|
|
5
|
-
*/
|
|
6
|
-
declare function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(map: T, key: K, factory: (key: K, map: T) => V): V;
|
|
7
|
-
|
|
8
|
-
export { mapGetOrDefault };
|
package/lib/mapGetOrDefault.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { G as GenericMap } from './GenericMap-B4OM3vGu.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Gets a value from a map or creates it using a factory function if it doesn't exist.
|
|
5
|
-
*/
|
|
6
|
-
declare function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(map: T, key: K, factory: (key: K, map: T) => V): V;
|
|
7
|
-
|
|
8
|
-
export { mapGetOrDefault };
|
package/lib/mapGetOrDefault.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/mapGetOrDefault.ts
|
|
5
|
-
function mapGetOrDefault(map, key, factory) {
|
|
6
|
-
let value = map.get(key);
|
|
7
|
-
if (value !== void 0 || map.has(key)) {
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
value = factory(key, map);
|
|
11
|
-
map.set(key, value);
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
__name(mapGetOrDefault, "mapGetOrDefault");
|
|
15
|
-
|
|
16
|
-
export { mapGetOrDefault };
|
package/lib/mapLoad.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
|
|
6
|
-
// src/mapLoad.ts
|
|
7
|
-
function mapLoad(ins, entries) {
|
|
8
|
-
for (const [key, value] of entries) {
|
|
9
|
-
ins.set(key, value);
|
|
10
|
-
}
|
|
11
|
-
return ins;
|
|
12
|
-
}
|
|
13
|
-
__name(mapLoad, "mapLoad");
|
|
14
|
-
|
|
15
|
-
exports.mapLoad = mapLoad;
|
package/lib/mapLoad.d.cts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { G as GenericMap } from './GenericMap-B4OM3vGu.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Loads multiple entries into the map from an iterable.
|
|
5
|
-
*
|
|
6
|
-
* @param entries - An iterable of key-value pairs to load into the map
|
|
7
|
-
* @returns The map instance for method chaining
|
|
8
|
-
*/
|
|
9
|
-
declare function mapLoad<T extends GenericMap<K, V, 'set'>, K, V>(ins: T, entries: Iterable<[K, V]>): T;
|
|
10
|
-
|
|
11
|
-
export { mapLoad };
|
package/lib/mapLoad.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { G as GenericMap } from './GenericMap-B4OM3vGu.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Loads multiple entries into the map from an iterable.
|
|
5
|
-
*
|
|
6
|
-
* @param entries - An iterable of key-value pairs to load into the map
|
|
7
|
-
* @returns The map instance for method chaining
|
|
8
|
-
*/
|
|
9
|
-
declare function mapLoad<T extends GenericMap<K, V, 'set'>, K, V>(ins: T, entries: Iterable<[K, V]>): T;
|
|
10
|
-
|
|
11
|
-
export { mapLoad };
|
package/lib/mapLoad.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/mapLoad.ts
|
|
5
|
-
function mapLoad(ins, entries) {
|
|
6
|
-
for (const [key, value] of entries) {
|
|
7
|
-
ins.set(key, value);
|
|
8
|
-
}
|
|
9
|
-
return ins;
|
|
10
|
-
}
|
|
11
|
-
__name(mapLoad, "mapLoad");
|
|
12
|
-
|
|
13
|
-
export { mapLoad };
|
package/lib/mapReverse.cjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
|
|
6
|
-
// src/mapLoad.ts
|
|
7
|
-
function mapLoad(ins, entries) {
|
|
8
|
-
for (const [key, value] of entries) {
|
|
9
|
-
ins.set(key, value);
|
|
10
|
-
}
|
|
11
|
-
return ins;
|
|
12
|
-
}
|
|
13
|
-
__name(mapLoad, "mapLoad");
|
|
14
|
-
|
|
15
|
-
// src/mapReverse.ts
|
|
16
|
-
function mapReverse(ins) {
|
|
17
|
-
const entries = Array.from(ins).reverse();
|
|
18
|
-
ins.clear();
|
|
19
|
-
mapLoad(ins, entries);
|
|
20
|
-
return ins;
|
|
21
|
-
}
|
|
22
|
-
__name(mapReverse, "mapReverse");
|
|
23
|
-
|
|
24
|
-
exports.mapReverse = mapReverse;
|