@bemoje/iter 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 (138) hide show
  1. package/README.md +41 -15
  2. package/lib/index.cjs +5 -18
  3. package/lib/index.d.cts +524 -33
  4. package/lib/index.d.ts +524 -33
  5. package/lib/index.js +1 -14
  6. package/package.json +20 -472
  7. package/lib/filterArray.cjs +0 -20
  8. package/lib/filterArray.d.cts +0 -18
  9. package/lib/filterArray.d.ts +0 -18
  10. package/lib/filterArray.js +0 -18
  11. package/lib/filterIterable.cjs +0 -14
  12. package/lib/filterIterable.d.cts +0 -18
  13. package/lib/filterIterable.d.ts +0 -18
  14. package/lib/filterIterable.js +0 -12
  15. package/lib/filterIterableEntries.cjs +0 -12
  16. package/lib/filterIterableEntries.d.cts +0 -18
  17. package/lib/filterIterableEntries.d.ts +0 -18
  18. package/lib/filterIterableEntries.js +0 -10
  19. package/lib/filterIterableKeys.cjs +0 -14
  20. package/lib/filterIterableKeys.d.cts +0 -18
  21. package/lib/filterIterableKeys.d.ts +0 -18
  22. package/lib/filterIterableKeys.js +0 -12
  23. package/lib/filterIterableValues.cjs +0 -14
  24. package/lib/filterIterableValues.d.cts +0 -18
  25. package/lib/filterIterableValues.d.ts +0 -18
  26. package/lib/filterIterableValues.js +0 -12
  27. package/lib/filterMap.cjs +0 -18
  28. package/lib/filterMap.d.cts +0 -18
  29. package/lib/filterMap.d.ts +0 -18
  30. package/lib/filterMap.js +0 -16
  31. package/lib/filterObject.cjs +0 -24
  32. package/lib/filterObject.d.cts +0 -18
  33. package/lib/filterObject.d.ts +0 -18
  34. package/lib/filterObject.js +0 -22
  35. package/lib/filterSet.cjs +0 -18
  36. package/lib/filterSet.d.cts +0 -18
  37. package/lib/filterSet.d.ts +0 -18
  38. package/lib/filterSet.js +0 -16
  39. package/lib/forEachArray.cjs +0 -16
  40. package/lib/forEachArray.d.cts +0 -17
  41. package/lib/forEachArray.d.ts +0 -17
  42. package/lib/forEachArray.js +0 -14
  43. package/lib/forEachIterable.cjs +0 -14
  44. package/lib/forEachIterable.d.cts +0 -17
  45. package/lib/forEachIterable.d.ts +0 -17
  46. package/lib/forEachIterable.js +0 -12
  47. package/lib/forEachIterableEntries.cjs +0 -14
  48. package/lib/forEachIterableEntries.d.cts +0 -6
  49. package/lib/forEachIterableEntries.d.ts +0 -6
  50. package/lib/forEachIterableEntries.js +0 -12
  51. package/lib/forEachIterableKeys.cjs +0 -14
  52. package/lib/forEachIterableKeys.d.cts +0 -17
  53. package/lib/forEachIterableKeys.d.ts +0 -17
  54. package/lib/forEachIterableKeys.js +0 -12
  55. package/lib/forEachIterableValues.cjs +0 -14
  56. package/lib/forEachIterableValues.d.cts +0 -17
  57. package/lib/forEachIterableValues.d.ts +0 -17
  58. package/lib/forEachIterableValues.js +0 -12
  59. package/lib/forEachMap.cjs +0 -14
  60. package/lib/forEachMap.d.cts +0 -17
  61. package/lib/forEachMap.d.ts +0 -17
  62. package/lib/forEachMap.js +0 -12
  63. package/lib/forEachObject.cjs +0 -20
  64. package/lib/forEachObject.d.cts +0 -17
  65. package/lib/forEachObject.d.ts +0 -17
  66. package/lib/forEachObject.js +0 -18
  67. package/lib/forEachSet.cjs +0 -14
  68. package/lib/forEachSet.d.cts +0 -17
  69. package/lib/forEachSet.d.ts +0 -17
  70. package/lib/forEachSet.js +0 -12
  71. package/lib/mapArray.cjs +0 -18
  72. package/lib/mapArray.d.cts +0 -17
  73. package/lib/mapArray.d.ts +0 -17
  74. package/lib/mapArray.js +0 -16
  75. package/lib/mapIterable.cjs +0 -14
  76. package/lib/mapIterable.d.cts +0 -17
  77. package/lib/mapIterable.d.ts +0 -17
  78. package/lib/mapIterable.js +0 -12
  79. package/lib/mapIterableEntries.cjs +0 -12
  80. package/lib/mapIterableEntries.d.cts +0 -17
  81. package/lib/mapIterableEntries.d.ts +0 -17
  82. package/lib/mapIterableEntries.js +0 -10
  83. package/lib/mapIterableKeys.cjs +0 -17
  84. package/lib/mapIterableKeys.d.cts +0 -17
  85. package/lib/mapIterableKeys.d.ts +0 -17
  86. package/lib/mapIterableKeys.js +0 -15
  87. package/lib/mapIterableValues.cjs +0 -17
  88. package/lib/mapIterableValues.d.cts +0 -17
  89. package/lib/mapIterableValues.d.ts +0 -17
  90. package/lib/mapIterableValues.js +0 -15
  91. package/lib/mapMap.cjs +0 -16
  92. package/lib/mapMap.d.cts +0 -17
  93. package/lib/mapMap.d.ts +0 -17
  94. package/lib/mapMap.js +0 -14
  95. package/lib/mapObject.cjs +0 -22
  96. package/lib/mapObject.d.cts +0 -17
  97. package/lib/mapObject.d.ts +0 -17
  98. package/lib/mapObject.js +0 -20
  99. package/lib/mapSet.cjs +0 -16
  100. package/lib/mapSet.d.cts +0 -17
  101. package/lib/mapSet.d.ts +0 -17
  102. package/lib/mapSet.js +0 -14
  103. package/lib/reduceArray.cjs +0 -18
  104. package/lib/reduceArray.d.cts +0 -18
  105. package/lib/reduceArray.d.ts +0 -18
  106. package/lib/reduceArray.js +0 -16
  107. package/lib/reduceIterable.cjs +0 -16
  108. package/lib/reduceIterable.d.cts +0 -18
  109. package/lib/reduceIterable.d.ts +0 -18
  110. package/lib/reduceIterable.js +0 -14
  111. package/lib/reduceIterableEntries.cjs +0 -16
  112. package/lib/reduceIterableEntries.d.cts +0 -18
  113. package/lib/reduceIterableEntries.d.ts +0 -18
  114. package/lib/reduceIterableEntries.js +0 -14
  115. package/lib/reduceIterableKeys.cjs +0 -16
  116. package/lib/reduceIterableKeys.d.cts +0 -18
  117. package/lib/reduceIterableKeys.d.ts +0 -18
  118. package/lib/reduceIterableKeys.js +0 -14
  119. package/lib/reduceIterableValues.cjs +0 -16
  120. package/lib/reduceIterableValues.d.cts +0 -18
  121. package/lib/reduceIterableValues.d.ts +0 -18
  122. package/lib/reduceIterableValues.js +0 -14
  123. package/lib/reduceMap.cjs +0 -16
  124. package/lib/reduceMap.d.cts +0 -18
  125. package/lib/reduceMap.d.ts +0 -18
  126. package/lib/reduceMap.js +0 -14
  127. package/lib/reduceObject.cjs +0 -22
  128. package/lib/reduceObject.d.cts +0 -18
  129. package/lib/reduceObject.d.ts +0 -18
  130. package/lib/reduceObject.js +0 -20
  131. package/lib/reduceSet.cjs +0 -16
  132. package/lib/reduceSet.d.cts +0 -18
  133. package/lib/reduceSet.d.ts +0 -18
  134. package/lib/reduceSet.js +0 -14
  135. package/lib/toObjectIterable.cjs +0 -20
  136. package/lib/toObjectIterable.d.cts +0 -7
  137. package/lib/toObjectIterable.d.ts +0 -7
  138. package/lib/toObjectIterable.js +0 -18
package/lib/index.d.cts CHANGED
@@ -1,33 +1,524 @@
1
- export { filterArray } from './filterArray.cjs';
2
- export { filterIterable } from './filterIterable.cjs';
3
- export { filterIterableEntries } from './filterIterableEntries.cjs';
4
- export { filterIterableKeys } from './filterIterableKeys.cjs';
5
- export { filterIterableValues } from './filterIterableValues.cjs';
6
- export { filterMap } from './filterMap.cjs';
7
- export { filterObject } from './filterObject.cjs';
8
- export { filterSet } from './filterSet.cjs';
9
- export { forEachArray } from './forEachArray.cjs';
10
- export { forEachIterable } from './forEachIterable.cjs';
11
- export { forEachIterableEntries } from './forEachIterableEntries.cjs';
12
- export { forEachIterableKeys } from './forEachIterableKeys.cjs';
13
- export { forEachIterableValues } from './forEachIterableValues.cjs';
14
- export { forEachMap } from './forEachMap.cjs';
15
- export { forEachObject } from './forEachObject.cjs';
16
- export { forEachSet } from './forEachSet.cjs';
17
- export { mapArray } from './mapArray.cjs';
18
- export { mapIterable } from './mapIterable.cjs';
19
- export { mapIterableEntries } from './mapIterableEntries.cjs';
20
- export { mapIterableKeys } from './mapIterableKeys.cjs';
21
- export { mapIterableValues } from './mapIterableValues.cjs';
22
- export { mapMap } from './mapMap.cjs';
23
- export { mapObject } from './mapObject.cjs';
24
- export { mapSet } from './mapSet.cjs';
25
- export { reduceArray } from './reduceArray.cjs';
26
- export { reduceIterable } from './reduceIterable.cjs';
27
- export { reduceIterableEntries } from './reduceIterableEntries.cjs';
28
- export { reduceIterableKeys } from './reduceIterableKeys.cjs';
29
- export { reduceIterableValues } from './reduceIterableValues.cjs';
30
- export { reduceMap } from './reduceMap.cjs';
31
- export { reduceObject } from './reduceObject.cjs';
32
- export { reduceSet } from './reduceSet.cjs';
33
- export { toObjectIterable } from './toObjectIterable.cjs';
1
+ /**
2
+ * Filter an array based on a predicate function.
3
+ *
4
+ * @param array - The array to filter
5
+ * @param predicate - A function that tests each element. Returns `true` to keep the element, `false` otherwise.
6
+ * @returns A new array containing only the elements that satisfy the predicate
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const numbers = [1, 2, 3, 4, 5]
11
+ * const evens = filterArray(numbers, (n) => n % 2 === 0)
12
+ * // evens: [2, 4]
13
+ * ```
14
+ */
15
+ declare function filterArray<V, S extends V>(array: readonly V[], predicate: (value: V, index: number) => value is S): S[];
16
+ declare function filterArray<V>(array: readonly V[], predicate: (value: V, index: number) => boolean): V[];
17
+
18
+ /**
19
+ * Filter an iterable based on a predicate function.
20
+ *
21
+ * @param collection - The iterable to filter
22
+ * @param predicate - A function that tests each element. Returns `true` to keep the element, `false` otherwise.
23
+ * @returns An iterable containing only the elements that satisfy the predicate
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const numbers = [1, 2, 3, 4, 5]
28
+ * const evens = filterIterable(numbers, (n) => n % 2 === 0)
29
+ * // evens: Iterable of [2, 4]
30
+ * ```
31
+ */
32
+ declare function filterIterable<T, S extends T>(collection: Iterable<T>, predicate: (value: T) => value is S): Iterable<S>;
33
+ declare function filterIterable<T>(collection: Iterable<T>, predicate: (value: T) => boolean): Iterable<T>;
34
+
35
+ /**
36
+ * Filter an iterable of key-value entries based on a predicate function.
37
+ *
38
+ * @param mapLike - An iterable of key-value tuples to filter
39
+ * @param predicate - A function that tests each entry. Returns `true` to keep the entry, `false` otherwise.
40
+ * @returns An iterable containing only the entries that satisfy the predicate
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
45
+ * const filtered = filterIterableEntries(entries, ([key, value]) => value > 1)
46
+ * // filtered: Iterable of [['b', 2], ['c', 3]]
47
+ * ```
48
+ */
49
+ declare function filterIterableEntries<K, V, K2 extends K, V2 extends V>(mapLike: Iterable<[K, V]>, predicate: (entry: [K, V]) => entry is [K2, V2]): Iterable<[K2, V2]>;
50
+ declare function filterIterableEntries<K, V>(mapLike: Iterable<[K, V]>, predicate: (entry: [K, V]) => boolean): Iterable<[K, V]>;
51
+
52
+ /**
53
+ * Filter an iterable of key-value entries based on a predicate function that tests keys.
54
+ *
55
+ * @param mapLike - An iterable of key-value tuples to filter
56
+ * @param predicate - A function that tests each key-value pair. Returns `true` to keep the entry, `false` otherwise.
57
+ * @returns An iterable containing only the entries whose keys satisfy the predicate
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const entries: [string, number][] = [['apple', 1], ['banana', 2], ['apricot', 3]]
62
+ * const filtered = filterIterableKeys(entries, (key) => key.startsWith('a'))
63
+ * // filtered: Iterable of [['apple', 1], ['apricot', 3]]
64
+ * ```
65
+ */
66
+ declare function filterIterableKeys<K, V, K2 extends K>(mapLike: Iterable<[K, V]>, predicate: (key: K, value: V) => key is K2): Iterable<[K2, V]>;
67
+ declare function filterIterableKeys<K, V>(mapLike: Iterable<[K, V]>, predicate: (key: K, value: V) => boolean): Iterable<[K, V]>;
68
+
69
+ /**
70
+ * Filter an iterable of key-value entries based on a predicate function that tests values.
71
+ *
72
+ * @param mapLike - An iterable of key-value tuples to filter
73
+ * @param predicate - A function that tests each value. Returns `true` to keep the entry, `false` otherwise.
74
+ * @returns An iterable containing only the entries whose values satisfy the predicate
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
79
+ * const filtered = filterIterableValues(entries, (value) => value > 1)
80
+ * // filtered: Iterable of [['b', 2], ['c', 3]]
81
+ * ```
82
+ */
83
+ declare function filterIterableValues<K, V, V2 extends V>(mapLike: Iterable<[K, V]>, predicate: (value: V, key: K) => value is V2): Iterable<[K, V2]>;
84
+ declare function filterIterableValues<K, V>(mapLike: Iterable<[K, V]>, predicate: (value: V, key: K) => boolean): Iterable<[K, V]>;
85
+
86
+ /**
87
+ * Filter a Map based on a predicate function.
88
+ *
89
+ * @param map - The Map to filter
90
+ * @param predicate - A function that tests each value-key pair. Returns `true` to keep the entry, `false` otherwise.
91
+ * @returns A new Map containing only the entries that satisfy the predicate
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const map = new Map([['a', 1], ['b', 2], ['c', 3]])
96
+ * const filtered = filterMap(map, (value) => value > 1)
97
+ * // filtered: Map { 'b' => 2, 'c' => 3 }
98
+ * ```
99
+ */
100
+ declare function filterMap<K, V, V2 extends V>(map: ReadonlyMap<K, V>, predicate: (value: V, key: K) => value is V2): Map<K, V2>;
101
+ declare function filterMap<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V, key: K) => boolean): Map<K, V>;
102
+
103
+ /**
104
+ * Filter an object's properties based on a predicate function.
105
+ *
106
+ * @param object - The object to filter
107
+ * @param predicate - A function that tests each value-key pair. Returns `true` to keep the property, `false` otherwise.
108
+ * @returns A new object containing only the properties that satisfy the predicate
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * const obj = { a: 1, b: 2, c: 3 }
113
+ * const filtered = filterObject(obj, (value) => value > 1)
114
+ * // filtered: { b: 2, c: 3 }
115
+ * ```
116
+ */
117
+ declare function filterObject<T extends Record<string, unknown>, V2 extends T[keyof T]>(object: T, predicate: (value: T[keyof T], key: keyof T) => value is V2): Partial<Record<keyof T, V2>>;
118
+ declare function filterObject<T extends Record<string, unknown>>(object: T, predicate: (value: T[keyof T], key: keyof T) => boolean): Partial<T>;
119
+
120
+ /**
121
+ * Filter a Set based on a predicate function.
122
+ *
123
+ * @param set - The Set to filter
124
+ * @param predicate - A function that tests each value. Returns `true` to keep the value, `false` otherwise.
125
+ * @returns A new Set containing only the values that satisfy the predicate
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * const set = new Set([1, 2, 3, 4, 5])
130
+ * const evens = filterSet(set, (n) => n % 2 === 0)
131
+ * // evens: Set { 2, 4 }
132
+ * ```
133
+ */
134
+ declare function filterSet<V, S extends V>(set: ReadonlySet<V>, predicate: (value: V) => value is S): Set<S>;
135
+ declare function filterSet<V>(set: ReadonlySet<V>, predicate: (value: V) => boolean): Set<V>;
136
+
137
+ /**
138
+ * Execute a callback function for each element in an array.
139
+ *
140
+ * @param array - The array to iterate over
141
+ * @param callback - A function to execute for each element
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * const numbers = [1, 2, 3, 4, 5]
146
+ * forEachArray(numbers, (n, index) => {
147
+ * console.log(`Item ${index}: ${n}`)
148
+ * })
149
+ * ```
150
+ */
151
+ declare function forEachArray<V>(array: readonly V[], callback: (value: V, index: number) => void): void;
152
+
153
+ /**
154
+ * Execute a callback function for each element in an iterable.
155
+ *
156
+ * @param collection - The iterable to iterate over
157
+ * @param callback - A function to execute for each element
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * const numbers = [1, 2, 3, 4, 5]
162
+ * forEachIterable(numbers, (n) => {
163
+ * console.log(n)
164
+ * })
165
+ * ```
166
+ */
167
+ declare function forEachIterable<T>(collection: Iterable<T>, callback: (value: T) => void): void;
168
+
169
+ /**
170
+ * Execute a callback function for each entry in a map-like iterable.
171
+ */
172
+ declare function forEachIterableEntries<K, V>(mapLike: Iterable<[K, V]>, callback: (value: V, key: K) => void): void;
173
+
174
+ /**
175
+ * Execute a callback function for each key in an iterable of key-value pairs.
176
+ *
177
+ * @param mapLike - An iterable of key-value tuples to iterate over
178
+ * @param callback - A function to execute for each key-value pair
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * const entries: [string, number][] = [['apple', 1], ['banana', 2], ['apricot', 3]]
183
+ * forEachIterableKeys(entries, (key, value) => {
184
+ * console.log(`Key: ${key}, Value: ${value}`)
185
+ * })
186
+ * ```
187
+ */
188
+ declare function forEachIterableKeys<K, V>(mapLike: Iterable<[K, V]>, callback: (key: K, value: V) => void): void;
189
+
190
+ /**
191
+ * Execute a callback function for each value in an iterable of key-value pairs.
192
+ *
193
+ * @param mapLike - An iterable of key-value tuples to iterate over
194
+ * @param callback - A function to execute for each value
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
199
+ * forEachIterableValues(entries, (value, key) => {
200
+ * console.log(`Value: ${value}, Key: ${key}`)
201
+ * })
202
+ * ```
203
+ */
204
+ declare function forEachIterableValues<K, V>(mapLike: Iterable<[K, V]>, callback: (value: V, key: K) => void): void;
205
+
206
+ /**
207
+ * Execute a callback function for each entry in a Map.
208
+ *
209
+ * @param map - The Map to iterate over
210
+ * @param callback - A function to execute for each value-key pair
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * const map = new Map([['a', 1], ['b', 2], ['c', 3]])
215
+ * forEachMap(map, (value, key) => {
216
+ * console.log(`${key}: ${value}`)
217
+ * })
218
+ * ```
219
+ */
220
+ declare function forEachMap<K, V>(map: ReadonlyMap<K, V>, callback: (value: V, key: K) => void): void;
221
+
222
+ /**
223
+ * Execute a callback function for each property in an object.
224
+ *
225
+ * @param object - The object to iterate over
226
+ * @param callback - A function to execute for each value-key pair
227
+ *
228
+ * @example
229
+ * ```ts
230
+ * const obj = { a: 1, b: 2, c: 3 }
231
+ * forEachObject(obj, (value, key) => {
232
+ * console.log(`${key}: ${value}`)
233
+ * })
234
+ * ```
235
+ */
236
+ declare function forEachObject<T extends Record<string, unknown>>(object: T, callback: (value: T[keyof T], key: keyof T) => void): void;
237
+
238
+ /**
239
+ * Execute a callback function for each value in a Set.
240
+ *
241
+ * @param set - The Set to iterate over
242
+ * @param callback - A function to execute for each value
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * const set = new Set([1, 2, 3, 4, 5])
247
+ * forEachSet(set, (n) => {
248
+ * console.log(n)
249
+ * })
250
+ * ```
251
+ */
252
+ declare function forEachSet<V>(set: ReadonlySet<V>, callback: (value: V) => void): void;
253
+
254
+ /**
255
+ * Transform each element in an array using a mapper function.
256
+ *
257
+ * @param array - The array to transform
258
+ * @param mapper - A function that transforms each element
259
+ * @returns A new array containing the transformed elements
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * const numbers = [1, 2, 3, 4, 5]
264
+ * const doubled = mapArray(numbers, (n) => n * 2)
265
+ * // doubled: [2, 4, 6, 8, 10]
266
+ * ```
267
+ */
268
+ declare function mapArray<V, R>(array: readonly V[], mapper: (value: V, index: number) => R): R[];
269
+
270
+ /**
271
+ * Transform each element in an iterable using a mapper function.
272
+ *
273
+ * @param collection - The iterable to transform
274
+ * @param mapper - A function that transforms each element
275
+ * @returns An iterable containing the transformed elements
276
+ *
277
+ * @example
278
+ * ```ts
279
+ * const numbers = [1, 2, 3, 4, 5]
280
+ * const doubled = mapIterable(numbers, (n) => n * 2)
281
+ * // doubled: Iterable of [2, 4, 6, 8, 10]
282
+ * ```
283
+ */
284
+ declare function mapIterable<T, R>(collection: Iterable<T>, mapper: (value: T) => R): Iterable<R>;
285
+
286
+ /**
287
+ * Transform each entry in an iterable of key-value pairs using a mapper function.
288
+ *
289
+ * @param mapLike - An iterable of key-value tuples to transform
290
+ * @param mapper - A function that transforms each entry
291
+ * @returns An iterable containing the transformed entries
292
+ *
293
+ * @example
294
+ * ```ts
295
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
296
+ * const mapped = mapIterableEntries(entries, ([key, value]) => [key, value * 2])
297
+ * // mapped: Iterable of [['a', 2], ['b', 4], ['c', 6]]
298
+ * ```
299
+ */
300
+ declare function mapIterableEntries<K, V, K2, V2>(mapLike: Iterable<[K, V]>, mapper: (entry: [K, V]) => [K2, V2]): Iterable<[K2, V2]>;
301
+
302
+ /**
303
+ * Transform the keys in an iterable of key-value pairs using a mapper function.
304
+ *
305
+ * @param mapLike - An iterable of key-value tuples to transform
306
+ * @param mapper - A function that transforms each key
307
+ * @returns An iterable containing entries with transformed keys
308
+ *
309
+ * @example
310
+ * ```ts
311
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
312
+ * const mapped = mapIterableKeys(entries, (key) => key.toUpperCase())
313
+ * // mapped: Iterable of [['A', 1], ['B', 2], ['C', 3]]
314
+ * ```
315
+ */
316
+ declare function mapIterableKeys<K, V, K2>(mapLike: Iterable<[K, V]>, mapper: (key: K, value: V) => K2): Iterable<[K2, V]>;
317
+
318
+ /**
319
+ * Transform the values in an iterable of key-value pairs using a mapper function.
320
+ *
321
+ * @param mapLike - An iterable of key-value tuples to transform
322
+ * @param mapper - A function that transforms each value
323
+ * @returns An iterable containing entries with transformed values
324
+ *
325
+ * @example
326
+ * ```ts
327
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
328
+ * const mapped = mapIterableValues(entries, (value) => value * 2)
329
+ * // mapped: Iterable of [['a', 2], ['b', 4], ['c', 6]]
330
+ * ```
331
+ */
332
+ declare function mapIterableValues<K, V, V2>(mapLike: Iterable<[K, V]>, mapper: (value: V, key: K) => V2): Iterable<[K, V2]>;
333
+
334
+ /**
335
+ * Transform the values in a Map using a mapper function.
336
+ *
337
+ * @param map - The Map to transform
338
+ * @param mapper - A function that transforms each value
339
+ * @returns A new Map containing the transformed values
340
+ *
341
+ * @example
342
+ * ```ts
343
+ * const map = new Map([['a', 1], ['b', 2], ['c', 3]])
344
+ * const doubled = mapMap(map, (value) => value * 2)
345
+ * // doubled: Map { 'a' => 2, 'b' => 4, 'c' => 6 }
346
+ * ```
347
+ */
348
+ declare function mapMap<K, V, V2>(map: ReadonlyMap<K, V>, mapper: (value: V, key: K) => V2): Map<K, V2>;
349
+
350
+ /**
351
+ * Transform the values in an object using a mapper function.
352
+ *
353
+ * @param object - The object to transform
354
+ * @param mapper - A function that transforms each value
355
+ * @returns A new object containing the transformed values
356
+ *
357
+ * @example
358
+ * ```ts
359
+ * const obj = { a: 1, b: 2, c: 3 }
360
+ * const doubled = mapObject(obj, (value) => value * 2)
361
+ * // doubled: { a: 2, b: 4, c: 6 }
362
+ * ```
363
+ */
364
+ declare function mapObject<T extends Record<string, unknown>, R>(object: T, mapper: (value: T[keyof T], key: keyof T) => R): Record<keyof T, R>;
365
+
366
+ /**
367
+ * Transform each value in a Set using a mapper function.
368
+ *
369
+ * @param set - The Set to transform
370
+ * @param mapper - A function that transforms each value
371
+ * @returns A new Set containing the transformed values
372
+ *
373
+ * @example
374
+ * ```ts
375
+ * const set = new Set([1, 2, 3, 4, 5])
376
+ * const doubled = mapSet(set, (n) => n * 2)
377
+ * // doubled: Set { 2, 4, 6, 8, 10 }
378
+ * ```
379
+ */
380
+ declare function mapSet<V, R>(set: ReadonlySet<V>, mapper: (value: V) => R): Set<R>;
381
+
382
+ /**
383
+ * Reduce an array to a single value using a reducer function.
384
+ *
385
+ * @param array - The array to reduce
386
+ * @param reducer - A function that combines values
387
+ * @param initial - The initial value for the reduction
388
+ * @returns The reduced value
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * const numbers = [1, 2, 3, 4, 5]
393
+ * const sum = reduceArray(numbers, (acc, n) => acc + n, 0)
394
+ * // sum: 15
395
+ * ```
396
+ */
397
+ declare function reduceArray<V, R>(array: readonly V[], reducer: (accumulator: R, value: V, index: number) => R, initial: R): R;
398
+
399
+ /**
400
+ * Reduce an iterable to a single value using a reducer function.
401
+ *
402
+ * @param collection - The iterable to reduce
403
+ * @param reducer - A function that combines values
404
+ * @param initial - The initial value for the reduction
405
+ * @returns The reduced value
406
+ *
407
+ * @example
408
+ * ```ts
409
+ * const numbers = [1, 2, 3, 4, 5]
410
+ * const sum = reduceIterable(numbers, (acc, n) => acc + n, 0)
411
+ * // sum: 15
412
+ * ```
413
+ */
414
+ declare function reduceIterable<T, R>(collection: Iterable<T>, reducer: (accumulator: R, value: T) => R, initial: R): R;
415
+
416
+ /**
417
+ * Reduce an iterable of key-value entries to a single value using a reducer function.
418
+ *
419
+ * @param mapLike - An iterable of key-value tuples to reduce
420
+ * @param reducer - A function that combines entries
421
+ * @param initial - The initial value for the reduction
422
+ * @returns The reduced value
423
+ *
424
+ * @example
425
+ * ```ts
426
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
427
+ * const sum = reduceIterableEntries(entries, (acc, [key, value]) => acc + value, 0)
428
+ * // sum: 6
429
+ * ```
430
+ */
431
+ declare function reduceIterableEntries<K, V, R>(mapLike: Iterable<[K, V]>, reducer: (accumulator: R, entry: [K, V]) => R, initial: R): R;
432
+
433
+ /**
434
+ * Reduce an iterable of key-value entries based on keys using a reducer function.
435
+ *
436
+ * @param mapLike - An iterable of key-value tuples to reduce
437
+ * @param reducer - A function that combines keys
438
+ * @param initial - The initial value for the reduction
439
+ * @returns The reduced value
440
+ *
441
+ * @example
442
+ * ```ts
443
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
444
+ * const keys = reduceIterableKeys(entries, (acc, key, value) => acc + key, '')
445
+ * // keys: 'abc'
446
+ * ```
447
+ */
448
+ declare function reduceIterableKeys<K, V, R>(mapLike: Iterable<[K, V]>, reducer: (accumulator: R, key: K, value: V) => R, initial: R): R;
449
+
450
+ /**
451
+ * Reduce an iterable of key-value entries based on values using a reducer function.
452
+ *
453
+ * @param mapLike - An iterable of key-value tuples to reduce
454
+ * @param reducer - A function that combines values
455
+ * @param initial - The initial value for the reduction
456
+ * @returns The reduced value
457
+ *
458
+ * @example
459
+ * ```ts
460
+ * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]
461
+ * const sum = reduceIterableValues(entries, (acc, value, key) => acc + value, 0)
462
+ * // sum: 6
463
+ * ```
464
+ */
465
+ declare function reduceIterableValues<K, V, R>(mapLike: Iterable<[K, V]>, reducer: (accumulator: R, value: V, key: K) => R, initial: R): R;
466
+
467
+ /**
468
+ * Reduce a Map to a single value using a reducer function.
469
+ *
470
+ * @param map - The Map to reduce
471
+ * @param reducer - A function that combines values
472
+ * @param initial - The initial value for the reduction
473
+ * @returns The reduced value
474
+ *
475
+ * @example
476
+ * ```ts
477
+ * const map = new Map([['a', 1], ['b', 2], ['c', 3]])
478
+ * const sum = reduceMap(map, (acc, value, key) => acc + value, 0)
479
+ * // sum: 6
480
+ * ```
481
+ */
482
+ declare function reduceMap<K, V, R>(map: ReadonlyMap<K, V>, reducer: (accumulator: R, value: V, key: K) => R, initial: R): R;
483
+
484
+ /**
485
+ * Reduce an object to a single value using a reducer function.
486
+ *
487
+ * @param object - The object to reduce
488
+ * @param reducer - A function that combines values
489
+ * @param initial - The initial value for the reduction
490
+ * @returns The reduced value
491
+ *
492
+ * @example
493
+ * ```ts
494
+ * const obj = { a: 1, b: 2, c: 3 }
495
+ * const sum = reduceObject(obj, (acc, value, key) => acc + value, 0)
496
+ * // sum: 6
497
+ * ```
498
+ */
499
+ declare function reduceObject<T extends Record<string, unknown>, R>(object: T, reducer: (accumulator: R, value: T[keyof T], key: keyof T) => R, initial: R): R;
500
+
501
+ /**
502
+ * Reduce a Set to a single value using a reducer function.
503
+ *
504
+ * @param set - The Set to reduce
505
+ * @param reducer - A function that combines values
506
+ * @param initial - The initial value for the reduction
507
+ * @returns The reduced value
508
+ *
509
+ * @example
510
+ * ```ts
511
+ * const set = new Set([1, 2, 3, 4, 5])
512
+ * const sum = reduceSet(set, (acc, n) => acc + n, 0)
513
+ * // sum: 15
514
+ * ```
515
+ */
516
+ declare function reduceSet<V, R>(set: ReadonlySet<V>, reducer: (accumulator: R, value: V) => R, initial: R): R;
517
+
518
+ /**
519
+ * Convert a map-like iterable to a regular object.
520
+ */
521
+ declare function toObjectIterable<K extends string, V>(mapLike: Iterable<[K, V]>): Record<K, V>;
522
+ declare function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>): Record<Extract<K, string> | string, V>;
523
+
524
+ export { filterArray, filterIterable, filterIterableEntries, filterIterableKeys, filterIterableValues, filterMap, filterObject, filterSet, forEachArray, forEachIterable, forEachIterableEntries, forEachIterableKeys, forEachIterableValues, forEachMap, forEachObject, forEachSet, mapArray, mapIterable, mapIterableEntries, mapIterableKeys, mapIterableValues, mapMap, mapObject, mapSet, reduceArray, reduceIterable, reduceIterableEntries, reduceIterableKeys, reduceIterableValues, reduceMap, reduceObject, reduceSet, toObjectIterable };