@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.
Files changed (66) hide show
  1. package/README.md +23 -21
  2. package/lib/index.cjs +33 -122
  3. package/lib/index.d.cts +364 -17
  4. package/lib/index.d.ts +364 -17
  5. package/lib/index.js +15 -104
  6. package/package.json +21 -221
  7. package/lib/ExtMap.cjs +0 -354
  8. package/lib/ExtMap.d.cts +0 -110
  9. package/lib/ExtMap.d.ts +0 -110
  10. package/lib/ExtMap.js +0 -352
  11. package/lib/TimeoutWeakMap.cjs +0 -122
  12. package/lib/TimeoutWeakMap.d.cts +0 -75
  13. package/lib/TimeoutWeakMap.d.ts +0 -75
  14. package/lib/TimeoutWeakMap.js +0 -120
  15. package/lib/countUniques.cjs +0 -363
  16. package/lib/countUniques.d.cts +0 -9
  17. package/lib/countUniques.d.ts +0 -9
  18. package/lib/countUniques.js +0 -361
  19. package/lib/entriesArray.cjs +0 -12
  20. package/lib/entriesArray.d.cts +0 -19
  21. package/lib/entriesArray.d.ts +0 -19
  22. package/lib/entriesArray.js +0 -10
  23. package/lib/isGenericMap.cjs +0 -18
  24. package/lib/isGenericMap.d.cts +0 -6
  25. package/lib/isGenericMap.d.ts +0 -6
  26. package/lib/isGenericMap.js +0 -16
  27. package/lib/keysArray.cjs +0 -12
  28. package/lib/keysArray.d.cts +0 -19
  29. package/lib/keysArray.d.ts +0 -19
  30. package/lib/keysArray.js +0 -10
  31. package/lib/mapGetOrDefault.cjs +0 -18
  32. package/lib/mapGetOrDefault.d.cts +0 -8
  33. package/lib/mapGetOrDefault.d.ts +0 -8
  34. package/lib/mapGetOrDefault.js +0 -16
  35. package/lib/mapLoad.cjs +0 -15
  36. package/lib/mapLoad.d.cts +0 -11
  37. package/lib/mapLoad.d.ts +0 -11
  38. package/lib/mapLoad.js +0 -13
  39. package/lib/mapReverse.cjs +0 -24
  40. package/lib/mapReverse.d.cts +0 -15
  41. package/lib/mapReverse.d.ts +0 -15
  42. package/lib/mapReverse.js +0 -22
  43. package/lib/mapUpdate.cjs +0 -14
  44. package/lib/mapUpdate.d.cts +0 -13
  45. package/lib/mapUpdate.d.ts +0 -13
  46. package/lib/mapUpdate.js +0 -12
  47. package/lib/sort.cjs +0 -17
  48. package/lib/sort.d.cts +0 -25
  49. package/lib/sort.d.ts +0 -25
  50. package/lib/sort.js +0 -15
  51. package/lib/sortByKeys.cjs +0 -19
  52. package/lib/sortByKeys.d.cts +0 -24
  53. package/lib/sortByKeys.d.ts +0 -24
  54. package/lib/sortByKeys.js +0 -17
  55. package/lib/sortByValues.cjs +0 -19
  56. package/lib/sortByValues.d.cts +0 -25
  57. package/lib/sortByValues.d.ts +0 -25
  58. package/lib/sortByValues.js +0 -17
  59. package/lib/toMap.cjs +0 -12
  60. package/lib/toMap.d.cts +0 -20
  61. package/lib/toMap.d.ts +0 -20
  62. package/lib/toMap.js +0 -10
  63. package/lib/valuesArray.cjs +0 -12
  64. package/lib/valuesArray.d.cts +0 -19
  65. package/lib/valuesArray.d.ts +0 -19
  66. package/lib/valuesArray.js +0 -10
package/lib/index.d.ts CHANGED
@@ -1,17 +1,364 @@
1
- export { ExtMap } from './ExtMap.js';
2
- export { TimeoutWeakMap } from './TimeoutWeakMap.js';
3
- export { countUniques } from './countUniques.js';
4
- export { entriesArray } from './entriesArray.js';
5
- export { isGenericMap } from './isGenericMap.js';
6
- export { keysArray } from './keysArray.js';
7
- export { mapGetOrDefault } from './mapGetOrDefault.js';
8
- export { mapLoad } from './mapLoad.js';
9
- export { mapReverse } from './mapReverse.js';
10
- export { mapUpdate } from './mapUpdate.js';
11
- export { sort } from './sort.js';
12
- export { sortByKeys } from './sortByKeys.js';
13
- export { sortByValues } from './sortByValues.js';
14
- export { toMap } from './toMap.js';
15
- export { valuesArray } from './valuesArray.js';
16
- import 'util';
17
- import './GenericMap-B4OM3vGu.js';
1
+ import { inspect, InspectOptions } from 'util';
2
+
3
+ /**
4
+ * Interface for a View that wraps a target object.
5
+ * View methods are redirected to the wrapped object which acts as
6
+ * a surrogate 'this'.
7
+ *
8
+ * To create a method that redirects to 'target', @see {@link defineProxifiedPrototypeProperty}
9
+ */
10
+ interface IView<T extends object> {
11
+ readonly target: T;
12
+ }
13
+
14
+ declare const TARGET_SYMBOL: unique symbol;
15
+ /**
16
+ * Base class providing view functionality over a target object using the Composition pattern.
17
+ */
18
+ declare class View<Target extends object> implements IView<Target> {
19
+ private [TARGET_SYMBOL];
20
+ constructor(target: Target);
21
+ get [Symbol.toStringTag](): string;
22
+ get target(): Target;
23
+ }
24
+
25
+ type MapKeys = keyof Map<any, any>;
26
+ type GenericMap<K, V, P extends MapKeys> = {
27
+ [Method in P]: Method extends 'set' ? (key: K, value: V) => any : Method extends 'get' ? (key: K) => V | undefined : Method extends 'has' ? (key: K) => boolean : Method extends 'delete' ? (key: K) => boolean : Method extends 'clear' ? () => void : Method extends 'forEach' ? (callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void : Method extends 'entries' ? () => IterableIterator<[K, V]> : Method extends 'keys' ? () => IterableIterator<K> : Method extends 'values' ? () => IterableIterator<V> : Method extends typeof Symbol.iterator ? () => IterableIterator<[K, V]> : Method extends 'size' ? number : Method extends typeof Symbol.toStringTag ? string : any;
28
+ };
29
+
30
+ declare module './ExtMap' {
31
+ interface ExtMap<K = any, V = any> extends Map<K, V> {
32
+ load(entries: Iterable<[K, V]>): this;
33
+ sort(compare: (a: [K, V], b: [K, V]) => number): this;
34
+ sortByKeys(compare: (a: K, b: K) => number): this;
35
+ sortByValues(compare: (a: V, b: V) => number): this;
36
+ reverse(): this;
37
+ update(key: K, update: (value: V | undefined, key: K, map: this) => V): this;
38
+ getOrDefault(key: K, factory: (key: K, map: this) => V): V;
39
+ keysArray(): K[];
40
+ valuesArray(): V[];
41
+ entriesArray(): [K, V][];
42
+ toMap(): Map<K, V>;
43
+ toObject<K extends string, V>(): Record<K, V>;
44
+ toObject<K, V>(): Record<Extract<K, PropertyKey> | string, V>;
45
+ reduce<R>(reducer: (accumulator: R, value: V, key: K) => R, initialValue: R): R;
46
+ map<NewK, NewV>(mapper: (value: V, key: K) => [NewK, NewV]): ExtMap<NewK, NewV>;
47
+ mapKeys<NewK>(mapper: (key: K, value: V) => NewK): ExtMap<NewK, V>;
48
+ mapValues<NewV>(mapper: (value: V, key: K) => NewV): ExtMap<K, NewV>;
49
+ filter(predicate: (value: V, key: K) => boolean): ExtMap<K, V>;
50
+ }
51
+ }
52
+ /**
53
+ * Minimal Extended Map class focused only on Map-specific utilities.
54
+ *
55
+ * @template K - The type of keys in the map
56
+ * @template V - The type of values in the map
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * import { map as iterMap, filter } from 'iter-tools'
61
+ *
62
+ * const extMap = new ExtMap<string, number>()
63
+ * .load([['a', 1], ['b', 2], ['c', 3]])
64
+ * .update('a', v => (v ?? 0) + 10)
65
+ * .sortByValues((a, b) => a - b)
66
+ *
67
+ * // Use iter-tools for transformations
68
+ * const doubled = new ExtMap<string, number>()
69
+ * .load(iterMap(([k, v]) => [k, v * 2], extMap))
70
+ *
71
+ * // Use iter-tools for filtering
72
+ * const filtered = new ExtMap<string, number>()
73
+ * .load(filter(([k, v]) => v > 5, extMap))
74
+ * ```
75
+ */
76
+ declare class ExtMap<K = any, V = any> extends View<Map<K, V>> implements Map<K, V> {
77
+ constructor(iterable?: Iterable<readonly [K, V]> | null | undefined);
78
+ constructor(obj?: Record<Extract<K, PropertyKey>, V>);
79
+ /**
80
+ * Creates a new ExtMap instance from a regular object.
81
+ *
82
+ * @param obj - An object whose key-value pairs will be used to initialize the map
83
+ * @returns A new ExtMap instance containing the entries from the object
84
+ */
85
+ static fromObject<K extends PropertyKey, V>(obj: Record<K, V>): ExtMap<K, V>;
86
+ /**
87
+ * Creates a new ExtMap instance from an iterable of key-value pairs.
88
+ *
89
+ * @param entries - An iterable of key-value pairs to initialize the map
90
+ * @returns A new ExtMap instance containing the provided entries
91
+ */
92
+ static fromIterable<K, V>(entries: Iterable<readonly [K, V]>): ExtMap<K, V>;
93
+ /**
94
+ * Creates a shallow copy of the map.
95
+ *
96
+ * @returns A new ExtMap instance with the same entries
97
+ */
98
+ clone(): ExtMap<K, V>;
99
+ /**
100
+ * Converts the map to a JSON-serializable format.
101
+ *
102
+ * @returns Array of key-value pairs suitable for JSON serialization
103
+ */
104
+ toJSON(): [K, V][];
105
+ /**
106
+ * Custom inspection method for better debugging output.
107
+ *
108
+ * @param _depth - The depth of inspection
109
+ * @param _options - Options for inspection
110
+ * @returns A string representation of the map
111
+ */
112
+ [inspect.custom](_depth: number, _options: InspectOptions): string;
113
+ }
114
+
115
+ /**
116
+ * A WeakMap with automatic timeout-based expiry for entries.
117
+ *
118
+ * Entries are automatically removed after a specified timeout period.
119
+ * Accessing an entry refreshes its timeout, extending its lifetime.
120
+ * This is useful for caching scenarios where you want automatic cleanup
121
+ * of unused entries while keeping frequently accessed ones alive.
122
+ */
123
+ declare class TimeoutWeakMap<K extends object, V> {
124
+ readonly timeoutMs: number;
125
+ protected readonly wmap: WeakMap<K, [V, NodeJS.Timeout]>;
126
+ /**
127
+ * @param timeoutMs Default timeout in milliseconds for entries
128
+ */
129
+ constructor(timeoutMs: number);
130
+ /**
131
+ * Retrieves the value for the given key and refreshes its timeout.
132
+ *
133
+ * @param key The key to retrieve
134
+ * @returns The value if found, undefined otherwise
135
+ */
136
+ get(key: K): V | undefined;
137
+ /**
138
+ * Sets a key-value pair with an optional custom timeout.
139
+ *
140
+ * @param key The key to set
141
+ * @param value The value to associate with the key
142
+ * @param timeoutMs Optional timeout override for this entry
143
+ * @returns This instance for chaining
144
+ */
145
+ set(key: K, value: V, timeoutMs?: number): this;
146
+ /**
147
+ * Removes a key-value pair and clears its timeout.
148
+ *
149
+ * @param key The key to delete
150
+ * @returns True if the key existed and was deleted, false otherwise
151
+ */
152
+ delete(key: K): boolean;
153
+ /**
154
+ * Checks if a key exists in the map.
155
+ * Does not refresh the timeout.
156
+ *
157
+ * @param key The key to check
158
+ * @returns True if the key exists, false otherwise
159
+ */
160
+ has(key: K): boolean;
161
+ /**
162
+ * Loads multiple key-value pairs into the map.
163
+ *
164
+ * @param entries Iterable of key-value pairs to load
165
+ * @param timeoutMs Optional timeout override for all entries
166
+ * @returns This instance for chaining
167
+ */
168
+ load(entries: Iterable<[K, V]>, timeoutMs?: number): this;
169
+ /**
170
+ * Updates an existing value or creates a new one using an update function.
171
+ *
172
+ * @param key The key to update
173
+ * @param update Function that receives the current value and returns the new value
174
+ * @returns This instance for chaining
175
+ */
176
+ update(key: K, update: (value: V | undefined, key: K, map: this) => V): this;
177
+ /**
178
+ * Gets a value or creates it using a factory function if it doesn't exist.
179
+ * Refreshes timeout if the value exists.
180
+ *
181
+ * @param key The key to get or create
182
+ * @param factory Function to create the value if it doesn't exist
183
+ * @param timeoutMs Optional timeout override for new entries
184
+ * @returns The existing or newly created value
185
+ */
186
+ getOrDefault(key: K, factory: (key: K, map: this) => V, timeoutMs?: number): V;
187
+ }
188
+
189
+ /**
190
+ * Count unique occurrences of values in an iterable, returning a sorted map by count descending.
191
+ */
192
+ declare function countUniques<V>(input: Iterable<V>): ExtMap<V, number>;
193
+
194
+ /**
195
+ * Returns an array of all key-value pairs in the map.
196
+ * Convenience method that converts the entries iterator to an array.
197
+ *
198
+ * @returns Array of all key-value pairs
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const map = new ExtMap<string, number>()
203
+ * .load([['a', 1], ['b', 2], ['c', 3]])
204
+ *
205
+ * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]
206
+ * ```
207
+ */
208
+ declare function entriesArray<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): [K, V][];
209
+
210
+ /**
211
+ * Checks if the provided value implements the Map interface with the specified required properties.
212
+ */
213
+ declare function isGenericMap<Props extends (keyof Map<K, V>)[], K, V>(target: unknown, requiredProps?: Props): target is Pick<Map<K, V>, Props[number]>;
214
+
215
+ /**
216
+ * Returns an array of all keys in the map.
217
+ * Convenience method that converts the keys iterator to an array.
218
+ *
219
+ * @returns Array of all keys
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const map = new ExtMap<string, number>()
224
+ * .load([['a', 1], ['b', 2], ['c', 3]])
225
+ *
226
+ * console.log(keysArray(map)) // ['a', 'b', 'c']
227
+ * ```
228
+ */
229
+ declare function keysArray<K, V>(ins: GenericMap<K, V, 'keys'>): K[];
230
+
231
+ /**
232
+ * Gets a value from a map or creates it using a factory function if it doesn't exist.
233
+ */
234
+ declare function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(map: T, key: K, factory: (key: K, map: T) => V): V;
235
+
236
+ /**
237
+ * Loads multiple entries into the map from an iterable.
238
+ *
239
+ * @param entries - An iterable of key-value pairs to load into the map
240
+ * @returns The map instance for method chaining
241
+ */
242
+ declare function mapLoad<T extends GenericMap<K, V, 'set'>, K, V>(ins: T, entries: Iterable<[K, V]>): T;
243
+
244
+ /**
245
+ * Reverses the order of entries in a Map.
246
+ * @remarks This function creates a new Map with the entries of the original Map in reverse order.
247
+ * The original Map is not modified.
248
+ * @example ```ts
249
+ * mapReverse(new Map([['a', 1], ['b', 2], ['c', 3]]));
250
+ * //=> [['c', 3], ['b', 2], ['a', 1]]
251
+ * ```
252
+ */
253
+ declare function mapReverse<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(ins: T): T;
254
+ declare function mapReverse<K, V>(ins: Map<K, V>): Map<K, V>;
255
+
256
+ /**
257
+ * Updates a value in the map using an update function.
258
+ *
259
+ * @param key - The key to update
260
+ * @param update - Function that receives the current value and returns the new value
261
+ * @returns The map instance for method chaining
262
+ */
263
+ 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;
264
+ declare function mapUpdate<K, V>(ins: Map<K, V>, key: K, update: (value: V | undefined, key: K, map: Map<K, V>) => V): typeof ins;
265
+
266
+ /**
267
+ * Sorts the map entries using a custom comparison function and updates the map in place.
268
+ * This is Map-specific because it maintains insertion order.
269
+ *
270
+ * @param ins - The map instance to sort
271
+ * @param compare - Function that compares two entries
272
+ * @returns The map instance for method chaining
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * const map = new ExtMap<string, number>([
277
+ * ['c', 3],
278
+ * ['a', 1],
279
+ * ['b', 2],
280
+ * ])
281
+ *
282
+ * sort(map, ([k1], [k2]) => k1.localeCompare(k2))
283
+ * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]
284
+ * ```
285
+ */
286
+ declare function sort<K, V>(ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, compare: (a: [K, V], b: [K, V]) => number): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>;
287
+
288
+ /**
289
+ * Sorts the map entries by their keys and updates the map in place.
290
+ *
291
+ * @param ins - The map instance to sort
292
+ * @param compare - Function that compares two keys
293
+ * @returns The map instance for method chaining
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * const map = new ExtMap<string, number>([
298
+ * ['c', 3],
299
+ * ['a', 1],
300
+ * ['b', 2],
301
+ * ])
302
+ *
303
+ * sortByKeys(map, (a, b) => a.localeCompare(b))
304
+ * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]
305
+ * ```
306
+ */
307
+ declare function sortByKeys<K, V>(ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, compare: (a: K, b: K) => number): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>;
308
+
309
+ /**
310
+ * Sorts the map entries by their values and updates the map in place.
311
+ *
312
+ * @param ins - The map instance to sort
313
+ * @param compare - Function that compares two values
314
+ * @returns The map instance for method chaining
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * const map = new ExtMap<string, number>([
319
+ * ['c', 3],
320
+ * ['a', 1],
321
+ * ['b', 2],
322
+ * ])
323
+ *
324
+ * sortByValues(map, (a, b) => a - b)
325
+ * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]
326
+ * ```
327
+ */
328
+ declare function sortByValues<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(ins: T, compare: (a: V, b: V) => number): T;
329
+ declare function sortByValues<K, V>(ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, compare: (a: V, b: V) => number): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>;
330
+
331
+ /**
332
+ * Converts a GenericMap to a native Map.
333
+ *
334
+ * @param ins - The GenericMap instance to convert
335
+ * @returns A new native Map with the same entries
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * const extMap = new ExtMap<string, number>()
340
+ * .load([['a', 1], ['b', 2], ['c', 3]])
341
+ *
342
+ * const nativeMap = toMap(extMap)
343
+ * console.log(nativeMap instanceof Map) // true
344
+ * ```
345
+ */
346
+ declare function toMap<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): Map<K, V>;
347
+
348
+ /**
349
+ * Returns an array of all values in the map.
350
+ * Convenience method that converts the values iterator to an array.
351
+ *
352
+ * @returns Array of all values
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * const map = new ExtMap<string, number>()
357
+ * .load([['a', 1], ['b', 2], ['c', 3]])
358
+ *
359
+ * console.log(valuesArray(map)) // [1, 2, 3]
360
+ * ```
361
+ */
362
+ declare function valuesArray<K, V>(ins: GenericMap<K, V, 'values'>): V[];
363
+
364
+ export { ExtMap, TimeoutWeakMap, countUniques, entriesArray, isGenericMap, keysArray, mapGetOrDefault, mapLoad, mapReverse, mapUpdate, sort, sortByKeys, sortByValues, toMap, valuesArray };
package/lib/index.js CHANGED
@@ -1,28 +1,19 @@
1
- import { isIterable, map, filter, reduce } from 'iter-tools';
1
+ import { defineMethod } from '@mono/object/defineMethod';
2
+ import { entriesOf } from '@mono/object/entriesOf';
3
+ import { filterIterableValues } from '@mono/iter/filterIterableValues';
2
4
  import { inspect } from 'util';
5
+ import { isIterable, reduce } from 'iter-tools';
6
+ import { mapIterableKeys } from '@mono/iter/mapIterableKeys';
7
+ import { mapIterableValues } from '@mono/iter/mapIterableValues';
8
+ import { reduceIterableValues } from '@mono/iter/reduceIterableValues';
9
+ import { thisify } from '@mono/fn/thisify';
10
+ import { toObjectIterable } from '@mono/iter/toObjectIterable';
11
+ import { transformReturnValue } from '@mono/fn/transformReturnValue';
3
12
  import { MultiSet } from 'mnemonist';
4
13
 
5
14
  var __defProp = Object.defineProperty;
6
15
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
16
 
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
17
  // ../composition/src/View.ts
27
18
  var TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
28
19
  var View = class {
@@ -100,12 +91,6 @@ function entriesArray(ins) {
100
91
  return Array.from(ins);
101
92
  }
102
93
  __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
94
 
110
95
  // src/keysArray.ts
111
96
  function keysArray(ins) {
@@ -114,34 +99,16 @@ function keysArray(ins) {
114
99
  __name(keysArray, "keysArray");
115
100
 
116
101
  // src/mapGetOrDefault.ts
117
- function mapGetOrDefault(map3, key, factory) {
118
- let value = map3.get(key);
119
- if (value !== void 0 || map3.has(key)) {
102
+ function mapGetOrDefault(map, key, factory) {
103
+ let value = map.get(key);
104
+ if (value !== void 0 || map.has(key)) {
120
105
  return value;
121
106
  }
122
- value = factory(key, map3);
123
- map3.set(key, value);
107
+ value = factory(key, map);
108
+ map.set(key, value);
124
109
  return value;
125
110
  }
126
111
  __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
112
 
146
113
  // src/mapLoad.ts
147
114
  function mapLoad(ins, entries) {
@@ -169,16 +136,6 @@ function mapUpdate(ins, key, update) {
169
136
  }
170
137
  __name(mapUpdate, "mapUpdate");
171
138
 
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
139
  // src/sort.ts
183
140
  function sort(ins, compare) {
184
141
  const entries = Array.from(ins).sort(compare);
@@ -216,58 +173,12 @@ function sortByValues(ins, compare) {
216
173
  }
217
174
  __name(sortByValues, "sortByValues");
218
175
 
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
176
  // src/toMap.ts
243
177
  function toMap(ins) {
244
178
  return new Map(ins);
245
179
  }
246
180
  __name(toMap, "toMap");
247
181
 
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
182
  // src/valuesArray.ts
272
183
  function valuesArray(ins) {
273
184
  return Array.from(ins.values());