@bemoje/map 1.0.1 → 1.2.1

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.
Files changed (66) hide show
  1. package/lib/ExtMap.cjs +354 -0
  2. package/lib/ExtMap.d.cts +110 -0
  3. package/lib/ExtMap.d.ts +110 -0
  4. package/lib/ExtMap.js +352 -0
  5. package/lib/TimeoutWeakMap.cjs +122 -0
  6. package/lib/TimeoutWeakMap.d.cts +75 -0
  7. package/lib/TimeoutWeakMap.d.ts +75 -0
  8. package/lib/TimeoutWeakMap.js +120 -0
  9. package/lib/countUniques.cjs +363 -0
  10. package/lib/countUniques.d.cts +9 -0
  11. package/lib/countUniques.d.ts +9 -0
  12. package/lib/countUniques.js +361 -0
  13. package/lib/entriesArray.cjs +12 -0
  14. package/lib/entriesArray.d.cts +19 -0
  15. package/lib/entriesArray.d.ts +19 -0
  16. package/lib/entriesArray.js +10 -0
  17. package/lib/index.cjs +505 -0
  18. package/lib/index.d.cts +17 -0
  19. package/lib/index.d.ts +17 -0
  20. package/{index.mjs → lib/index.js} +104 -90
  21. package/lib/isGenericMap.cjs +18 -0
  22. package/lib/isGenericMap.d.cts +6 -0
  23. package/lib/isGenericMap.d.ts +6 -0
  24. package/lib/isGenericMap.js +16 -0
  25. package/lib/keysArray.cjs +12 -0
  26. package/lib/keysArray.d.cts +19 -0
  27. package/lib/keysArray.d.ts +19 -0
  28. package/lib/keysArray.js +10 -0
  29. package/lib/mapGetOrDefault.cjs +18 -0
  30. package/lib/mapGetOrDefault.d.cts +8 -0
  31. package/lib/mapGetOrDefault.d.ts +8 -0
  32. package/lib/mapGetOrDefault.js +16 -0
  33. package/lib/mapLoad.cjs +15 -0
  34. package/lib/mapLoad.d.cts +11 -0
  35. package/lib/mapLoad.d.ts +11 -0
  36. package/lib/mapLoad.js +13 -0
  37. package/lib/mapReverse.cjs +24 -0
  38. package/lib/mapReverse.d.cts +15 -0
  39. package/lib/mapReverse.d.ts +15 -0
  40. package/lib/mapReverse.js +22 -0
  41. package/lib/mapUpdate.cjs +14 -0
  42. package/lib/mapUpdate.d.cts +13 -0
  43. package/lib/mapUpdate.d.ts +13 -0
  44. package/lib/mapUpdate.js +12 -0
  45. package/lib/sort.cjs +17 -0
  46. package/lib/sort.d.cts +25 -0
  47. package/lib/sort.d.ts +25 -0
  48. package/lib/sort.js +15 -0
  49. package/lib/sortByKeys.cjs +19 -0
  50. package/lib/sortByKeys.d.cts +24 -0
  51. package/lib/sortByKeys.d.ts +24 -0
  52. package/lib/sortByKeys.js +17 -0
  53. package/lib/sortByValues.cjs +19 -0
  54. package/lib/sortByValues.d.cts +25 -0
  55. package/lib/sortByValues.d.ts +25 -0
  56. package/lib/sortByValues.js +17 -0
  57. package/lib/toMap.cjs +12 -0
  58. package/lib/toMap.d.cts +20 -0
  59. package/lib/toMap.d.ts +20 -0
  60. package/lib/toMap.js +10 -0
  61. package/lib/valuesArray.cjs +12 -0
  62. package/lib/valuesArray.d.cts +19 -0
  63. package/lib/valuesArray.d.ts +19 -0
  64. package/lib/valuesArray.js +10 -0
  65. package/package.json +248 -18
  66. package/index.d.ts +0 -364
@@ -5,6 +5,24 @@ import { MultiSet } from 'mnemonist';
5
5
  var __defProp = Object.defineProperty;
6
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
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
+
8
26
  // ../composition/src/View.ts
9
27
  var TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
10
28
  var View = class {
@@ -77,101 +95,54 @@ function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
77
95
  }
78
96
  __name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
79
97
 
80
- // ../object/src/entriesOf.ts
81
- function entriesOf(obj) {
82
- return Object.entries(obj);
83
- }
84
- __name(entriesOf, "entriesOf");
85
-
86
- // ../object/src/defineMethod.ts
87
- function defineMethod(obj, key, value, des = {}) {
88
- return Object.defineProperty(obj, key, {
89
- value,
90
- configurable: true,
91
- writable: true,
92
- enumerable: false,
93
- ...des
94
- });
98
+ // src/entriesArray.ts
99
+ function entriesArray(ins) {
100
+ return Array.from(ins);
95
101
  }
96
- __name(defineMethod, "defineMethod");
97
- function filterIterableEntries(mapLike, predicate) {
102
+ __name(entriesArray, "entriesArray");
103
+ function filterIterableValues(mapLike, predicate) {
98
104
  return filter(([k, v]) => {
99
105
  return predicate(v, k);
100
106
  }, mapLike);
101
107
  }
102
- __name(filterIterableEntries, "filterIterableEntries");
103
- function mapIterableEntries(mapLike, transform) {
104
- return map(([k, v]) => {
105
- return transform(v, k);
106
- }, mapLike);
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;
107
125
  }
108
- __name(mapIterableEntries, "mapIterableEntries");
109
- function mapIterableKeys(mapLike, transform) {
126
+ __name(mapGetOrDefault, "mapGetOrDefault");
127
+ function mapIterableKeys(mapLike, mapper) {
110
128
  return map(([k, v]) => {
111
129
  return [
112
- transform(k, v),
130
+ mapper(k, v),
113
131
  v
114
132
  ];
115
133
  }, mapLike);
116
134
  }
117
135
  __name(mapIterableKeys, "mapIterableKeys");
118
- function mapIterableValues(mapLike, transform) {
136
+ function mapIterableValues(mapLike, mapper) {
119
137
  return map(([k, v]) => {
120
138
  return [
121
139
  k,
122
- transform(v, k)
140
+ mapper(v, k)
123
141
  ];
124
142
  }, mapLike);
125
143
  }
126
144
  __name(mapIterableValues, "mapIterableValues");
127
145
 
128
- // ../iter/src/reduceIterableEntries.ts
129
- function reduceIterableEntries(mapLike, reducer, initialValue) {
130
- for (const [key, value] of mapLike) {
131
- initialValue = reducer(initialValue, value, key);
132
- }
133
- return initialValue;
134
- }
135
- __name(reduceIterableEntries, "reduceIterableEntries");
136
-
137
- // ../iter/src/toObjectIterable.ts
138
- function toObjectIterable(mapLike) {
139
- const object = {};
140
- for (const [key, value] of mapLike) {
141
- if (typeof key !== "string" && typeof key !== "number" && typeof key !== "symbol") {
142
- object[String(key)] = value;
143
- } else {
144
- object[key] = value;
145
- }
146
- }
147
- return object;
148
- }
149
- __name(toObjectIterable, "toObjectIterable");
150
-
151
- // src/entriesArray.ts
152
- function entriesArray(ins) {
153
- return Array.from(ins);
154
- }
155
- __name(entriesArray, "entriesArray");
156
-
157
- // src/keysArray.ts
158
- function keysArray(ins) {
159
- return Array.from(ins.keys());
160
- }
161
- __name(keysArray, "keysArray");
162
-
163
- // src/mapGetOrDefault.ts
164
- function mapGetOrDefault(map4, key, factory) {
165
- let value = map4.get(key);
166
- if (value !== void 0 || map4.has(key)) {
167
- return value;
168
- }
169
- value = factory(key, map4);
170
- map4.set(key, value);
171
- return value;
172
- }
173
- __name(mapGetOrDefault, "mapGetOrDefault");
174
-
175
146
  // src/mapLoad.ts
176
147
  function mapLoad(ins, entries) {
177
148
  for (const [key, value] of entries) {
@@ -198,6 +169,16 @@ function mapUpdate(ins, key, update) {
198
169
  }
199
170
  __name(mapUpdate, "mapUpdate");
200
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
+
201
182
  // src/sort.ts
202
183
  function sort(ins, compare) {
203
184
  const entries = Array.from(ins).sort(compare);
@@ -235,12 +216,58 @@ function sortByValues(ins, compare) {
235
216
  }
236
217
  __name(sortByValues, "sortByValues");
237
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
+
238
242
  // src/toMap.ts
239
243
  function toMap(ins) {
240
244
  return new Map(ins);
241
245
  }
242
246
  __name(toMap, "toMap");
243
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
+
244
271
  // src/valuesArray.ts
245
272
  function valuesArray(ins) {
246
273
  return Array.from(ins.values());
@@ -304,19 +331,6 @@ var ExtMap = class _ExtMap extends View {
304
331
  });
305
332
  }
306
333
  };
307
- function thisify(fn) {
308
- return /* @__PURE__ */ __name(function wrapped(...args) {
309
- return fn(this, ...args);
310
- }, "wrapped");
311
- }
312
- __name(thisify, "thisify");
313
- function transformReturnValue(fn, transform) {
314
- return /* @__PURE__ */ __name(function wrapped(...args) {
315
- const result = fn.apply(this, args);
316
- return transform(result);
317
- }, "wrapped");
318
- }
319
- __name(transformReturnValue, "transformReturnValue");
320
334
  inheritProxifiedPrototype(ExtMap, Map, []);
321
335
  defineMethod(ExtMap.prototype, "load", thisify(mapLoad));
322
336
  defineMethod(ExtMap.prototype, "sort", thisify(sort));
@@ -330,11 +344,11 @@ defineMethod(ExtMap.prototype, "valuesArray", thisify(valuesArray));
330
344
  defineMethod(ExtMap.prototype, "entriesArray", thisify(entriesArray));
331
345
  defineMethod(ExtMap.prototype, "toObject", thisify(toObjectIterable));
332
346
  defineMethod(ExtMap.prototype, "toMap", thisify(toMap));
333
- defineMethod(ExtMap.prototype, "reduce", thisify(reduceIterableEntries));
334
- defineMethod(ExtMap.prototype, "map", thisify(transformReturnValue(mapIterableEntries, ExtMap.fromIterable)));
347
+ defineMethod(ExtMap.prototype, "reduce", thisify(reduceIterableValues));
348
+ defineMethod(ExtMap.prototype, "map", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
335
349
  defineMethod(ExtMap.prototype, "mapKeys", thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)));
336
350
  defineMethod(ExtMap.prototype, "mapValues", thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)));
337
- defineMethod(ExtMap.prototype, "filter", thisify(transformReturnValue(filterIterableEntries, ExtMap.fromIterable)));
351
+ defineMethod(ExtMap.prototype, "filter", thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)));
338
352
 
339
353
  // src/TimeoutWeakMap.ts
340
354
  var TimeoutWeakMap = class {
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,6 @@
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 };
@@ -0,0 +1,6 @@
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 };
@@ -0,0 +1,16 @@
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 };
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,19 @@
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 };
@@ -0,0 +1,19 @@
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 };
@@ -0,0 +1,10 @@
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 };
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,8 @@
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 };
@@ -0,0 +1,8 @@
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 };
@@ -0,0 +1,16 @@
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 };
@@ -0,0 +1,15 @@
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;
@@ -0,0 +1,11 @@
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 };
@@ -0,0 +1,11 @@
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 ADDED
@@ -0,0 +1,13 @@
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 };
@@ -0,0 +1,24 @@
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;
@@ -0,0 +1,15 @@
1
+ import { G as GenericMap } from './GenericMap-B4OM3vGu.cjs';
2
+
3
+ /**
4
+ * Reverses the order of entries in a Map.
5
+ * @remarks This function creates a new Map with the entries of the original Map in reverse order.
6
+ * The original Map is not modified.
7
+ * @example ```ts
8
+ * mapReverse(new Map([['a', 1], ['b', 2], ['c', 3]]));
9
+ * //=> [['c', 3], ['b', 2], ['a', 1]]
10
+ * ```
11
+ */
12
+ declare function mapReverse<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(ins: T): T;
13
+ declare function mapReverse<K, V>(ins: Map<K, V>): Map<K, V>;
14
+
15
+ export { mapReverse };
@@ -0,0 +1,15 @@
1
+ import { G as GenericMap } from './GenericMap-B4OM3vGu.js';
2
+
3
+ /**
4
+ * Reverses the order of entries in a Map.
5
+ * @remarks This function creates a new Map with the entries of the original Map in reverse order.
6
+ * The original Map is not modified.
7
+ * @example ```ts
8
+ * mapReverse(new Map([['a', 1], ['b', 2], ['c', 3]]));
9
+ * //=> [['c', 3], ['b', 2], ['a', 1]]
10
+ * ```
11
+ */
12
+ declare function mapReverse<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(ins: T): T;
13
+ declare function mapReverse<K, V>(ins: Map<K, V>): Map<K, V>;
14
+
15
+ export { mapReverse };
@@ -0,0 +1,22 @@
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
+ // src/mapReverse.ts
14
+ function mapReverse(ins) {
15
+ const entries = Array.from(ins).reverse();
16
+ ins.clear();
17
+ mapLoad(ins, entries);
18
+ return ins;
19
+ }
20
+ __name(mapReverse, "mapReverse");
21
+
22
+ export { mapReverse };
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ // src/mapUpdate.ts
7
+ function mapUpdate(ins, key, update) {
8
+ const newValue = update(ins.get(key), key, ins);
9
+ ins.set(key, newValue);
10
+ return ins;
11
+ }
12
+ __name(mapUpdate, "mapUpdate");
13
+
14
+ exports.mapUpdate = mapUpdate;
@@ -0,0 +1,13 @@
1
+ import { G as GenericMap } from './GenericMap-B4OM3vGu.cjs';
2
+
3
+ /**
4
+ * Updates a value in the map using an update function.
5
+ *
6
+ * @param key - The key to update
7
+ * @param update - Function that receives the current value and returns the new value
8
+ * @returns The map instance for method chaining
9
+ */
10
+ declare function mapUpdate<T extends GenericMap<K, V, 'set' | 'get'>, K, V>(ins: T, key: K, update: (value: V | undefined, key: K, map: T) => V): T;
11
+ declare function mapUpdate<K, V>(ins: Map<K, V>, key: K, update: (value: V | undefined, key: K, map: Map<K, V>) => V): typeof ins;
12
+
13
+ export { mapUpdate };
@@ -0,0 +1,13 @@
1
+ import { G as GenericMap } from './GenericMap-B4OM3vGu.js';
2
+
3
+ /**
4
+ * Updates a value in the map using an update function.
5
+ *
6
+ * @param key - The key to update
7
+ * @param update - Function that receives the current value and returns the new value
8
+ * @returns The map instance for method chaining
9
+ */
10
+ declare function mapUpdate<T extends GenericMap<K, V, 'set' | 'get'>, K, V>(ins: T, key: K, update: (value: V | undefined, key: K, map: T) => V): T;
11
+ declare function mapUpdate<K, V>(ins: Map<K, V>, key: K, update: (value: V | undefined, key: K, map: Map<K, V>) => V): typeof ins;
12
+
13
+ export { mapUpdate };
@@ -0,0 +1,12 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/mapUpdate.ts
5
+ function mapUpdate(ins, key, update) {
6
+ const newValue = update(ins.get(key), key, ins);
7
+ ins.set(key, newValue);
8
+ return ins;
9
+ }
10
+ __name(mapUpdate, "mapUpdate");
11
+
12
+ export { mapUpdate };
package/lib/sort.cjs ADDED
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ // src/sort.ts
7
+ function sort(ins, compare) {
8
+ const entries = Array.from(ins).sort(compare);
9
+ ins.clear();
10
+ for (const [k, v] of entries) {
11
+ ins.set(k, v);
12
+ }
13
+ return ins;
14
+ }
15
+ __name(sort, "sort");
16
+
17
+ exports.sort = sort;