iterflow 0.2.2

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.
@@ -0,0 +1,2264 @@
1
+ /**
2
+ * A fluent interface wrapper for working with iterators and iterables.
3
+ * Provides chainable methods for transforming, filtering, and analyzing data streams.
4
+ *
5
+ * @template T The type of elements in the iterator
6
+ * @example
7
+ * ```typescript
8
+ * const result = new iterflow([1, 2, 3, 4, 5])
9
+ * .filter(x => x % 2 === 0)
10
+ * .map(x => x * 2)
11
+ * .toArray(); // [4, 8]
12
+ * ```
13
+ */
14
+ declare class iterflow<T> implements Iterable<T> {
15
+ private source;
16
+ /**
17
+ * Creates a new iterflow instance from an iterable or iterator.
18
+ *
19
+ * @param source - The source iterable or iterator to wrap
20
+ * @example
21
+ * ```typescript
22
+ * const flow1 = new iterflow([1, 2, 3]);
23
+ * const flow2 = new iterflow(someIterator);
24
+ * ```
25
+ */
26
+ constructor(source: Iterable<T> | Iterator<T>);
27
+ /**
28
+ * Returns the iterator for this iterflow instance.
29
+ * This allows iterflow to be used in for...of loops.
30
+ *
31
+ * @returns The underlying iterator
32
+ */
33
+ [Symbol.iterator](): Iterator<T>;
34
+ /**
35
+ * Retrieves the next value from the iterator.
36
+ *
37
+ * @returns An IteratorResult containing the next value or indicating completion
38
+ */
39
+ next(): IteratorResult<T>;
40
+ /**
41
+ * Transforms each element using the provided function.
42
+ *
43
+ * @template U The type of the transformed elements
44
+ * @param fn - Function to transform each element
45
+ * @returns A new iterflow with transformed elements
46
+ * @example
47
+ * ```typescript
48
+ * iter([1, 2, 3]).map(x => x * 2).toArray(); // [2, 4, 6]
49
+ * ```
50
+ */
51
+ map<U>(fn: (value: T) => U): iterflow<U>;
52
+ /**
53
+ * Filters elements based on a predicate function.
54
+ * Only elements for which the predicate returns true are included.
55
+ *
56
+ * @param predicate - Function to test each element
57
+ * @returns A new iterflow with only elements that pass the predicate
58
+ * @example
59
+ * ```typescript
60
+ * iter([1, 2, 3, 4]).filter(x => x % 2 === 0).toArray(); // [2, 4]
61
+ * ```
62
+ */
63
+ filter(predicate: (value: T) => boolean): iterflow<T>;
64
+ /**
65
+ * Takes only the first `limit` elements from the iterator.
66
+ *
67
+ * @param limit - Maximum number of elements to take
68
+ * @returns A new iterflow with at most `limit` elements
69
+ * @example
70
+ * ```typescript
71
+ * iter([1, 2, 3, 4, 5]).take(3).toArray(); // [1, 2, 3]
72
+ * ```
73
+ */
74
+ take(limit: number): iterflow<T>;
75
+ /**
76
+ * Skips the first `count` elements from the iterator.
77
+ *
78
+ * @param count - Number of elements to skip
79
+ * @returns A new iterflow without the first `count` elements
80
+ * @example
81
+ * ```typescript
82
+ * iter([1, 2, 3, 4, 5]).drop(2).toArray(); // [3, 4, 5]
83
+ * ```
84
+ */
85
+ drop(count: number): iterflow<T>;
86
+ /**
87
+ * Maps each element to an iterable and flattens the results into a single iterator.
88
+ *
89
+ * @template U The type of elements in the resulting iterator
90
+ * @param fn - Function that maps each element to an iterable
91
+ * @returns A new iterflow with all mapped iterables flattened
92
+ * @example
93
+ * ```typescript
94
+ * iter([1, 2, 3]).flatMap(x => [x, x * 2]).toArray(); // [1, 2, 2, 4, 3, 6]
95
+ * ```
96
+ */
97
+ flatMap<U>(fn: (value: T) => Iterable<U>): iterflow<U>;
98
+ /**
99
+ * Concatenates multiple iterators sequentially.
100
+ * Yields all elements from this iterator, then from each provided iterator.
101
+ *
102
+ * @param iterables - Additional iterables to concatenate
103
+ * @returns A new iterflow with all elements from all iterables
104
+ * @example
105
+ * ```typescript
106
+ * iter([1, 2]).concat([3, 4], [5, 6]).toArray();
107
+ * // [1, 2, 3, 4, 5, 6]
108
+ * ```
109
+ */
110
+ concat(...iterables: Iterable<T>[]): iterflow<T>;
111
+ /**
112
+ * Inserts a separator element between each item.
113
+ * The separator is not added before the first element or after the last.
114
+ *
115
+ * @param separator - The element to insert between items
116
+ * @returns A new iterflow with separators interspersed
117
+ * @example
118
+ * ```typescript
119
+ * iter([1, 2, 3]).intersperse(0).toArray();
120
+ * // [1, 0, 2, 0, 3]
121
+ * iter(['a', 'b', 'c']).intersperse('-').toArray();
122
+ * // ['a', '-', 'b', '-', 'c']
123
+ * ```
124
+ */
125
+ intersperse(separator: T): iterflow<T>;
126
+ /**
127
+ * Like reduce, but emits all intermediate accumulator values.
128
+ * Similar to reduce but returns an iterator of partial results.
129
+ *
130
+ * @template U The type of the accumulated value
131
+ * @param fn - Function to combine the accumulator with each element
132
+ * @param initial - The initial value for the accumulator
133
+ * @returns A new iterflow of intermediate accumulator values
134
+ * @example
135
+ * ```typescript
136
+ * iter([1, 2, 3, 4]).scan((acc, x) => acc + x, 0).toArray();
137
+ * // [0, 1, 3, 6, 10]
138
+ * iter([1, 2, 3]).scan((acc, x) => acc * x, 1).toArray();
139
+ * // [1, 1, 2, 6]
140
+ * ```
141
+ */
142
+ scan<U>(fn: (accumulator: U, value: T) => U, initial: U): iterflow<U>;
143
+ /**
144
+ * Adds index as tuple with each element [index, value].
145
+ * Creates tuples pairing each element with its zero-based index.
146
+ *
147
+ * @returns A new iterflow of tuples containing [index, value]
148
+ * @example
149
+ * ```typescript
150
+ * iter(['a', 'b', 'c']).enumerate().toArray();
151
+ * // [[0, 'a'], [1, 'b'], [2, 'c']]
152
+ * ```
153
+ */
154
+ enumerate(): iterflow<[number, T]>;
155
+ /**
156
+ * Reverses the iterator order.
157
+ * Warning: This operation buffers all elements in memory and may cause
158
+ * performance issues with large iterables. Consider using only when necessary.
159
+ *
160
+ * @returns A new iterflow with elements in reverse order
161
+ * @example
162
+ * ```typescript
163
+ * iter([1, 2, 3, 4, 5]).reverse().toArray();
164
+ * // [5, 4, 3, 2, 1]
165
+ * ```
166
+ */
167
+ reverse(): iterflow<T>;
168
+ /**
169
+ * Sorts elements using default comparison.
170
+ * Numbers are sorted numerically, strings lexicographically.
171
+ * Warning: This operation buffers all elements in memory. Avoid chaining
172
+ * with other buffering operations (reverse, sort, sortBy) for better performance.
173
+ *
174
+ * @param this - iterflow instance constrained to numbers or strings
175
+ * @returns A new iterflow with elements sorted
176
+ * @example
177
+ * ```typescript
178
+ * iter([3, 1, 4, 1, 5]).sort().toArray();
179
+ * // [1, 1, 3, 4, 5]
180
+ * iter(['c', 'a', 'b']).sort().toArray();
181
+ * // ['a', 'b', 'c']
182
+ * ```
183
+ */
184
+ sort(this: iterflow<number | string>): iterflow<number | string>;
185
+ /**
186
+ * Sorts elements using a custom comparison function.
187
+ * Warning: This operation buffers all elements in memory. Avoid chaining
188
+ * with other buffering operations (reverse, sort, sortBy) for better performance.
189
+ *
190
+ * @param compareFn - Function that compares two elements (returns negative if a < b, 0 if equal, positive if a > b)
191
+ * @returns A new iterflow with elements sorted
192
+ * @example
193
+ * ```typescript
194
+ * iter([3, 1, 4, 1, 5]).sortBy((a, b) => a - b).toArray();
195
+ * // [1, 1, 3, 4, 5]
196
+ * iter([3, 1, 4, 1, 5]).sortBy((a, b) => b - a).toArray();
197
+ * // [5, 4, 3, 1, 1]
198
+ * iter(['alice', 'bob', 'charlie']).sortBy((a, b) => a.length - b.length).toArray();
199
+ * // ['bob', 'alice', 'charlie']
200
+ * ```
201
+ */
202
+ sortBy(compareFn: (a: T, b: T) => number): iterflow<T>;
203
+ /**
204
+ * Collects all elements into an array.
205
+ * This is a terminal operation that consumes the iterator.
206
+ *
207
+ * @returns An array containing all elements
208
+ * @example
209
+ * ```typescript
210
+ * iter([1, 2, 3]).map(x => x * 2).toArray(); // [2, 4, 6]
211
+ * ```
212
+ */
213
+ toArray(): T[];
214
+ /**
215
+ * Counts the total number of elements in the iterator.
216
+ * This is a terminal operation that consumes the iterator.
217
+ *
218
+ * @returns The total count of elements
219
+ * @example
220
+ * ```typescript
221
+ * iter([1, 2, 3, 4, 5]).count(); // 5
222
+ * ```
223
+ */
224
+ count(): number;
225
+ /**
226
+ * Calculates the sum of all numeric elements.
227
+ * This method is only available when T is number.
228
+ * This is a terminal operation that consumes the iterator.
229
+ *
230
+ * @param this - iterflow instance constrained to numbers
231
+ * @returns The sum of all elements
232
+ * @example
233
+ * ```typescript
234
+ * iter([1, 2, 3, 4, 5]).sum(); // 15
235
+ * ```
236
+ */
237
+ sum(this: iterflow<number>): number;
238
+ /**
239
+ * Calculates the arithmetic mean (average) of all numeric elements.
240
+ * This method is only available when T is number.
241
+ * This is a terminal operation that consumes the iterator.
242
+ *
243
+ * @param this - iterflow instance constrained to numbers
244
+ * @returns The mean value, or undefined if the iterator is empty
245
+ * @example
246
+ * ```typescript
247
+ * iter([1, 2, 3, 4, 5]).mean(); // 3
248
+ * iter([]).mean(); // undefined
249
+ * ```
250
+ */
251
+ mean(this: iterflow<number>): number | undefined;
252
+ /**
253
+ * Finds the minimum value among all numeric elements.
254
+ * This method is only available when T is number.
255
+ * This is a terminal operation that consumes the iterator.
256
+ *
257
+ * @param this - iterflow instance constrained to numbers
258
+ * @returns The minimum value, or undefined if the iterator is empty
259
+ * @example
260
+ * ```typescript
261
+ * iter([3, 1, 4, 1, 5]).min(); // 1
262
+ * iter([]).min(); // undefined
263
+ * ```
264
+ */
265
+ min(this: iterflow<number>): number | undefined;
266
+ /**
267
+ * Finds the maximum value among all numeric elements.
268
+ * This method is only available when T is number.
269
+ * This is a terminal operation that consumes the iterator.
270
+ *
271
+ * @param this - iterflow instance constrained to numbers
272
+ * @returns The maximum value, or undefined if the iterator is empty
273
+ * @example
274
+ * ```typescript
275
+ * iter([3, 1, 4, 1, 5]).max(); // 5
276
+ * iter([]).max(); // undefined
277
+ * ```
278
+ */
279
+ max(this: iterflow<number>): number | undefined;
280
+ /**
281
+ * Calculates the median value of all numeric elements.
282
+ * The median is the middle value when elements are sorted.
283
+ * This method is only available when T is number.
284
+ * This is a terminal operation that consumes the iterator.
285
+ *
286
+ * @param this - iterflow instance constrained to numbers
287
+ * @returns The median value, or undefined if the iterator is empty
288
+ * @example
289
+ * ```typescript
290
+ * iter([1, 2, 3, 4, 5]).median(); // 3
291
+ * iter([1, 2, 3, 4]).median(); // 2.5
292
+ * iter([]).median(); // undefined
293
+ * ```
294
+ */
295
+ median(this: iterflow<number>): number | undefined;
296
+ /**
297
+ * Calculates the variance of all numeric elements.
298
+ * Variance measures how far each number in the set is from the mean.
299
+ * This method is only available when T is number.
300
+ * This is a terminal operation that consumes the iterator.
301
+ *
302
+ * @param this - iterflow instance constrained to numbers
303
+ * @returns The variance, or undefined if the iterator is empty
304
+ * @example
305
+ * ```typescript
306
+ * iter([1, 2, 3, 4, 5]).variance(); // 2
307
+ * iter([]).variance(); // undefined
308
+ * ```
309
+ */
310
+ variance(this: iterflow<number>): number | undefined;
311
+ /**
312
+ * Calculates the standard deviation of all numeric elements.
313
+ * Standard deviation is the square root of variance and measures dispersion.
314
+ * This method is only available when T is number.
315
+ * This is a terminal operation that consumes the iterator.
316
+ *
317
+ * @param this - iterflow instance constrained to numbers
318
+ * @returns The standard deviation, or undefined if the iterator is empty
319
+ * @example
320
+ * ```typescript
321
+ * iter([2, 4, 4, 4, 5, 5, 7, 9]).stdDev(); // ~2
322
+ * iter([]).stdDev(); // undefined
323
+ * ```
324
+ */
325
+ stdDev(this: iterflow<number>): number | undefined;
326
+ /**
327
+ * Calculates the specified percentile of all numeric elements.
328
+ * Uses linear interpolation between closest ranks.
329
+ * This method is only available when T is number.
330
+ * This is a terminal operation that consumes the iterator.
331
+ *
332
+ * @param this - iterflow instance constrained to numbers
333
+ * @param p - The percentile to calculate (0-100)
334
+ * @returns The percentile value, or undefined if the iterator is empty
335
+ * @throws {Error} If p is not between 0 and 100
336
+ * @example
337
+ * ```typescript
338
+ * iter([1, 2, 3, 4, 5]).percentile(50); // 3 (median)
339
+ * iter([1, 2, 3, 4, 5]).percentile(75); // 4
340
+ * iter([]).percentile(50); // undefined
341
+ * ```
342
+ */
343
+ percentile(this: iterflow<number>, p: number): number | undefined;
344
+ /**
345
+ * Finds the most frequent value(s) in the dataset.
346
+ * Returns an array of all values that appear most frequently.
347
+ * This method is only available when T is number.
348
+ * This is a terminal operation that consumes the iterator.
349
+ *
350
+ * @param this - iterflow instance constrained to numbers
351
+ * @returns An array of the most frequent value(s), or undefined if the iterator is empty
352
+ * @example
353
+ * ```typescript
354
+ * iter([1, 2, 2, 3, 3, 3]).mode(); // [3]
355
+ * iter([1, 1, 2, 2, 3]).mode(); // [1, 2] (bimodal)
356
+ * iter([]).mode(); // undefined
357
+ * ```
358
+ */
359
+ mode(this: iterflow<number>): number[] | undefined;
360
+ /**
361
+ * Calculates the quartiles (Q1, Q2, Q3) of all numeric elements.
362
+ * Q1 is the 25th percentile, Q2 is the median (50th percentile), Q3 is the 75th percentile.
363
+ * This method is only available when T is number.
364
+ * This is a terminal operation that consumes the iterator.
365
+ *
366
+ * @param this - iterflow instance constrained to numbers
367
+ * @returns An object with Q1, Q2, and Q3 values, or undefined if the iterator is empty
368
+ * @example
369
+ * ```typescript
370
+ * iter([1, 2, 3, 4, 5, 6, 7, 8, 9]).quartiles();
371
+ * // { Q1: 3, Q2: 5, Q3: 7 }
372
+ * iter([]).quartiles(); // undefined
373
+ * ```
374
+ */
375
+ quartiles(this: iterflow<number>): {
376
+ Q1: number;
377
+ Q2: number;
378
+ Q3: number;
379
+ } | undefined;
380
+ /**
381
+ * Calculates the span (range from minimum to maximum value) of all numeric elements.
382
+ * This method is only available when T is number.
383
+ * This is a terminal operation that consumes the iterator.
384
+ *
385
+ * @param this - iterflow instance constrained to numbers
386
+ * @returns The span (max - min), or undefined if the iterator is empty
387
+ * @example
388
+ * ```typescript
389
+ * iter([1, 2, 3, 4, 5]).span(); // 4
390
+ * iter([10]).span(); // 0
391
+ * iter([]).span(); // undefined
392
+ * ```
393
+ */
394
+ span(this: iterflow<number>): number | undefined;
395
+ /**
396
+ * Calculates the product of all numeric elements.
397
+ * This method is only available when T is number.
398
+ * This is a terminal operation that consumes the iterator.
399
+ *
400
+ * @param this - iterflow instance constrained to numbers
401
+ * @returns The product of all elements, or 1 if the iterator is empty
402
+ * @example
403
+ * ```typescript
404
+ * iter([1, 2, 3, 4, 5]).product(); // 120
405
+ * iter([2, 3, 4]).product(); // 24
406
+ * iter([]).product(); // 1
407
+ * ```
408
+ */
409
+ product(this: iterflow<number>): number;
410
+ /**
411
+ * Calculates the covariance between two numeric sequences.
412
+ * Covariance measures the joint variability of two random variables.
413
+ * This method is only available when T is number.
414
+ * This is a terminal operation that consumes the iterator.
415
+ *
416
+ * @param this - iterflow instance constrained to numbers
417
+ * @param other - An iterable of numbers to compare with
418
+ * @returns The covariance, or undefined if either sequence is empty or sequences have different lengths
419
+ * @example
420
+ * ```typescript
421
+ * iter([1, 2, 3, 4, 5]).covariance([2, 4, 6, 8, 10]); // 4
422
+ * iter([]).covariance([1, 2, 3]); // undefined
423
+ * ```
424
+ */
425
+ covariance(this: iterflow<number>, other: Iterable<number>): number | undefined;
426
+ /**
427
+ * Calculates the Pearson correlation coefficient between two numeric sequences.
428
+ * Correlation measures the strength and direction of the linear relationship between two variables.
429
+ * Values range from -1 (perfect negative correlation) to 1 (perfect positive correlation).
430
+ * This method is only available when T is number.
431
+ * This is a terminal operation that consumes the iterator.
432
+ *
433
+ * @param this - iterflow instance constrained to numbers
434
+ * @param other - An iterable of numbers to compare with
435
+ * @returns The correlation coefficient, or undefined if either sequence is empty or sequences have different lengths
436
+ * @example
437
+ * ```typescript
438
+ * iter([1, 2, 3, 4, 5]).correlation([2, 4, 6, 8, 10]); // 1 (perfect positive correlation)
439
+ * iter([1, 2, 3]).correlation([3, 2, 1]); // -1 (perfect negative correlation)
440
+ * iter([]).correlation([1, 2, 3]); // undefined
441
+ * ```
442
+ */
443
+ correlation(this: iterflow<number>, other: Iterable<number>): number | undefined;
444
+ /**
445
+ * Creates a sliding window of the specified size over the elements.
446
+ * Each window contains `size` consecutive elements.
447
+ *
448
+ * @param size - The size of each window (must be at least 1)
449
+ * @returns A new iterflow of arrays, each containing `size` consecutive elements
450
+ * @throws {Error} If size is less than 1
451
+ * @example
452
+ * ```typescript
453
+ * iter([1, 2, 3, 4, 5]).window(3).toArray();
454
+ * // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
455
+ * ```
456
+ */
457
+ window(size: number): iterflow<T[]>;
458
+ /**
459
+ * Splits elements into chunks of the specified size.
460
+ * Unlike window, chunks don't overlap. The last chunk may be smaller.
461
+ *
462
+ * @param size - The size of each chunk (must be at least 1)
463
+ * @returns A new iterflow of arrays, each containing up to `size` elements
464
+ * @throws {Error} If size is less than 1
465
+ * @example
466
+ * ```typescript
467
+ * iter([1, 2, 3, 4, 5]).chunk(2).toArray();
468
+ * // [[1, 2], [3, 4], [5]]
469
+ * ```
470
+ */
471
+ chunk(size: number): iterflow<T[]>;
472
+ /**
473
+ * Creates pairs of consecutive elements.
474
+ * Equivalent to window(2) but returns tuples instead of arrays.
475
+ *
476
+ * @returns A new iterflow of tuples, each containing two consecutive elements
477
+ * @example
478
+ * ```typescript
479
+ * iter([1, 2, 3, 4]).pairwise().toArray();
480
+ * // [[1, 2], [2, 3], [3, 4]]
481
+ * ```
482
+ */
483
+ pairwise(): iterflow<[T, T]>;
484
+ /**
485
+ * Removes duplicate elements, keeping only the first occurrence of each.
486
+ * Uses strict equality (===) to compare elements.
487
+ *
488
+ * @returns A new iterflow with duplicate elements removed
489
+ * @example
490
+ * ```typescript
491
+ * iter([1, 2, 2, 3, 1, 4]).distinct().toArray();
492
+ * // [1, 2, 3, 4]
493
+ * ```
494
+ */
495
+ distinct(): iterflow<T>;
496
+ /**
497
+ * Removes duplicate elements based on a key function.
498
+ * Keeps only the first occurrence of each unique key.
499
+ *
500
+ * @template K The type of the key used for comparison
501
+ * @param keyFn - Function to extract the comparison key from each element
502
+ * @returns A new iterflow with duplicate elements (by key) removed
503
+ * @example
504
+ * ```typescript
505
+ * const users = [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 1, name: 'Charlie'}];
506
+ * iter(users).distinctBy(u => u.id).toArray();
507
+ * // [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}]
508
+ * ```
509
+ */
510
+ distinctBy<K>(keyFn: (value: T) => K): iterflow<T>;
511
+ /**
512
+ * Executes a side-effect function on each element without modifying the stream.
513
+ * Useful for debugging or performing operations like logging.
514
+ *
515
+ * @param fn - Function to execute for each element
516
+ * @returns A new iterflow with the same elements
517
+ * @example
518
+ * ```typescript
519
+ * iter([1, 2, 3])
520
+ * .tap(x => console.log('Processing:', x))
521
+ * .map(x => x * 2)
522
+ * .toArray(); // logs each value, returns [2, 4, 6]
523
+ * ```
524
+ */
525
+ tap(fn: (value: T) => void): iterflow<T>;
526
+ /**
527
+ * Takes elements while the predicate returns true, then stops.
528
+ * Stops at the first element that fails the predicate.
529
+ *
530
+ * @param predicate - Function to test each element
531
+ * @returns A new iterflow with elements up to the first failing predicate
532
+ * @example
533
+ * ```typescript
534
+ * iter([1, 2, 3, 4, 1, 2]).takeWhile(x => x < 4).toArray();
535
+ * // [1, 2, 3]
536
+ * ```
537
+ */
538
+ takeWhile(predicate: (value: T) => boolean): iterflow<T>;
539
+ /**
540
+ * Skips elements while the predicate returns true, then yields all remaining elements.
541
+ * Starts yielding from the first element that fails the predicate.
542
+ *
543
+ * @param predicate - Function to test each element
544
+ * @returns A new iterflow starting from the first element that fails the predicate
545
+ * @example
546
+ * ```typescript
547
+ * iter([1, 2, 3, 4, 1, 2]).dropWhile(x => x < 3).toArray();
548
+ * // [3, 4, 1, 2]
549
+ * ```
550
+ */
551
+ dropWhile(predicate: (value: T) => boolean): iterflow<T>;
552
+ /**
553
+ * Splits elements into two arrays based on a predicate.
554
+ * This is a terminal operation that consumes the iterator.
555
+ *
556
+ * @param predicate - Function to test each element
557
+ * @returns A tuple of two arrays: [elements passing predicate, elements failing predicate]
558
+ * @example
559
+ * ```typescript
560
+ * iter([1, 2, 3, 4, 5]).partition(x => x % 2 === 0);
561
+ * // [[2, 4], [1, 3, 5]]
562
+ * ```
563
+ */
564
+ partition(predicate: (value: T) => boolean): [T[], T[]];
565
+ /**
566
+ * Groups elements by a key function into a Map.
567
+ * This is a terminal operation that consumes the iterator.
568
+ *
569
+ * @template K The type of the grouping key
570
+ * @param keyFn - Function to extract the grouping key from each element
571
+ * @returns A Map where keys are the result of keyFn and values are arrays of elements
572
+ * @example
573
+ * ```typescript
574
+ * iter(['alice', 'bob', 'charlie', 'dave'])
575
+ * .groupBy(name => name.length);
576
+ * // Map { 3 => ['bob'], 5 => ['alice'], 7 => ['charlie'], 4 => ['dave'] }
577
+ * ```
578
+ */
579
+ groupBy<K>(keyFn: (value: T) => K): Map<K, T[]>;
580
+ /**
581
+ * Reduces the iterator to a single value using an accumulator function.
582
+ * This is a terminal operation that consumes the iterator.
583
+ *
584
+ * @template U The type of the accumulated value
585
+ * @param fn - Function to combine the accumulator with each element
586
+ * @param initial - The initial value for the accumulator
587
+ * @returns The final accumulated value
588
+ * @example
589
+ * ```typescript
590
+ * iter([1, 2, 3, 4]).reduce((acc, x) => acc + x, 0); // 10
591
+ * iter(['a', 'b', 'c']).reduce((acc, x) => acc + x, ''); // 'abc'
592
+ * ```
593
+ */
594
+ reduce<U>(fn: (accumulator: U, value: T) => U, initial: U): U;
595
+ /**
596
+ * Finds the first element that matches the predicate.
597
+ * This is a terminal operation that may consume part of the iterator.
598
+ *
599
+ * @param predicate - Function to test each element
600
+ * @returns The first matching element, or undefined if none found
601
+ * @example
602
+ * ```typescript
603
+ * iter([1, 2, 3, 4, 5]).find(x => x > 3); // 4
604
+ * iter([1, 2, 3]).find(x => x > 10); // undefined
605
+ * ```
606
+ */
607
+ find(predicate: (value: T) => boolean): T | undefined;
608
+ /**
609
+ * Finds the index of the first element that matches the predicate.
610
+ * This is a terminal operation that may consume part of the iterator.
611
+ *
612
+ * @param predicate - Function to test each element
613
+ * @returns The index of the first matching element, or -1 if none found
614
+ * @example
615
+ * ```typescript
616
+ * iter([1, 2, 3, 4, 5]).findIndex(x => x > 3); // 3
617
+ * iter([1, 2, 3]).findIndex(x => x > 10); // -1
618
+ * ```
619
+ */
620
+ findIndex(predicate: (value: T) => boolean): number;
621
+ /**
622
+ * Tests whether at least one element matches the predicate.
623
+ * This is a terminal operation that may consume part of the iterator.
624
+ *
625
+ * @param predicate - Function to test each element
626
+ * @returns true if any element matches, false otherwise
627
+ * @example
628
+ * ```typescript
629
+ * iter([1, 2, 3, 4, 5]).some(x => x > 3); // true
630
+ * iter([1, 2, 3]).some(x => x > 10); // false
631
+ * ```
632
+ */
633
+ some(predicate: (value: T) => boolean): boolean;
634
+ /**
635
+ * Tests whether all elements match the predicate.
636
+ * This is a terminal operation that may consume part or all of the iterator.
637
+ *
638
+ * @param predicate - Function to test each element
639
+ * @returns true if all elements match, false otherwise
640
+ * @example
641
+ * ```typescript
642
+ * iter([2, 4, 6]).every(x => x % 2 === 0); // true
643
+ * iter([1, 2, 3]).every(x => x % 2 === 0); // false
644
+ * ```
645
+ */
646
+ every(predicate: (value: T) => boolean): boolean;
647
+ /**
648
+ * Executes a function for each element in the iterator.
649
+ * This is a terminal operation that consumes the entire iterator.
650
+ *
651
+ * @param fn - Function to execute for each element
652
+ * @example
653
+ * ```typescript
654
+ * iter([1, 2, 3]).forEach(x => console.log(x));
655
+ * // Logs: 1, 2, 3
656
+ * ```
657
+ */
658
+ forEach(fn: (value: T) => void): void;
659
+ /**
660
+ * Gets the first element from the iterator.
661
+ * This is a terminal operation that consumes the first element.
662
+ *
663
+ * @param defaultValue - Optional default value to return if iterator is empty
664
+ * @returns The first element, the default value, or undefined if empty and no default
665
+ * @example
666
+ * ```typescript
667
+ * iter([1, 2, 3]).first(); // 1
668
+ * iter([]).first(); // undefined
669
+ * iter([]).first(0); // 0
670
+ * ```
671
+ */
672
+ first(defaultValue?: T): T | undefined;
673
+ /**
674
+ * Gets the last element from the iterator.
675
+ * This is a terminal operation that consumes the entire iterator.
676
+ *
677
+ * @param defaultValue - Optional default value to return if iterator is empty
678
+ * @returns The last element, the default value, or undefined if empty and no default
679
+ * @example
680
+ * ```typescript
681
+ * iter([1, 2, 3]).last(); // 3
682
+ * iter([]).last(); // undefined
683
+ * iter([]).last(0); // 0
684
+ * ```
685
+ */
686
+ last(defaultValue?: T): T | undefined;
687
+ /**
688
+ * Gets the element at the specified index.
689
+ * This is a terminal operation that may consume part of the iterator.
690
+ *
691
+ * @param index - Zero-based index of the element to retrieve
692
+ * @returns The element at the index, or undefined if index is out of bounds
693
+ * @example
694
+ * ```typescript
695
+ * iter([1, 2, 3, 4, 5]).nth(2); // 3
696
+ * iter([1, 2, 3]).nth(10); // undefined
697
+ * iter([1, 2, 3]).nth(-1); // undefined
698
+ * ```
699
+ */
700
+ nth(index: number): T | undefined;
701
+ /**
702
+ * Checks if the iterator is empty.
703
+ * This is a terminal operation that may consume the first element.
704
+ *
705
+ * @returns true if the iterator has no elements, false otherwise
706
+ * @example
707
+ * ```typescript
708
+ * iter([]).isEmpty(); // true
709
+ * iter([1, 2, 3]).isEmpty(); // false
710
+ * ```
711
+ */
712
+ isEmpty(): boolean;
713
+ /**
714
+ * Checks if the iterator includes a specific value.
715
+ * Uses strict equality (===) for comparison.
716
+ * This is a terminal operation that may consume part or all of the iterator.
717
+ *
718
+ * @param searchValue - The value to search for
719
+ * @returns true if the value is found, false otherwise
720
+ * @example
721
+ * ```typescript
722
+ * iter([1, 2, 3, 4, 5]).includes(3); // true
723
+ * iter([1, 2, 3]).includes(10); // false
724
+ * iter(['a', 'b', 'c']).includes('b'); // true
725
+ * ```
726
+ */
727
+ includes(searchValue: T): boolean;
728
+ /**
729
+ * Alias for stdDev() method for compatibility.
730
+ * Calculates the standard deviation of all numeric elements.
731
+ */
732
+ stddev(this: iterflow<number>): number | undefined;
733
+ /**
734
+ * Alias for drop() method for compatibility.
735
+ * Skips the first `count` elements from the iterator.
736
+ */
737
+ skip(count: number): iterflow<T>;
738
+ /**
739
+ * Interleaves elements from this iterator with elements from other iterables.
740
+ * Takes one element from each iterable in round-robin fashion.
741
+ *
742
+ * @param others - Variable number of iterables to interleave with
743
+ * @returns A new iterflow with elements from all iterables interleaved
744
+ * @example
745
+ * ```typescript
746
+ * iter([1, 2, 3]).interleave([4, 5, 6]).toArray(); // [1, 4, 2, 5, 3, 6]
747
+ * ```
748
+ */
749
+ interleave(...others: Iterable<T>[]): iterflow<T>;
750
+ /**
751
+ * Merges this iterator with other sorted iterables into a single sorted iterator.
752
+ * Assumes all input iterables are already sorted in ascending order.
753
+ *
754
+ * @param others - Variable number of sorted iterables to merge with
755
+ * @returns A new iterflow with all elements merged in sorted order
756
+ * @example
757
+ * ```typescript
758
+ * iter([1, 3, 5]).merge([2, 4, 6]).toArray(); // [1, 2, 3, 4, 5, 6]
759
+ * ```
760
+ */
761
+ merge(...others: Iterable<T>[]): iterflow<T>;
762
+ }
763
+
764
+ /**
765
+ * A fluent interface wrapper for working with async iterators and async iterables.
766
+ * Provides chainable methods for transforming, filtering, and analyzing async data streams.
767
+ *
768
+ * @template T The type of elements in the async iterator
769
+ * @example
770
+ * ```typescript
771
+ * const result = await new Asynciterflow(asyncIterable)
772
+ * .filter(async x => x % 2 === 0)
773
+ * .map(async x => x * 2)
774
+ * .toArray(); // [4, 8]
775
+ * ```
776
+ */
777
+ declare class Asynciterflow<T> implements AsyncIterable<T> {
778
+ private source;
779
+ /**
780
+ * Creates a new async iterflow instance from an async iterable or async iterator.
781
+ *
782
+ * @param source - The source async iterable or async iterator to wrap
783
+ * @example
784
+ * ```typescript
785
+ * const flow1 = new Asynciterflow(asyncIterable);
786
+ * const flow2 = new Asynciterflow(asyncIterator);
787
+ * ```
788
+ */
789
+ constructor(source: AsyncIterable<T> | AsyncIterator<T>);
790
+ /**
791
+ * Returns the async iterator for this iterflow instance.
792
+ * This allows iterflow to be used in for await...of loops.
793
+ *
794
+ * @returns The underlying async iterator
795
+ */
796
+ [Symbol.asyncIterator](): AsyncIterator<T>;
797
+ /**
798
+ * Retrieves the next value from the async iterator.
799
+ *
800
+ * @returns A promise of an IteratorResult containing the next value or indicating completion
801
+ */
802
+ next(): Promise<IteratorResult<T>>;
803
+ /**
804
+ * Transforms each element using the provided async or sync function.
805
+ *
806
+ * @template U The type of the transformed elements
807
+ * @param fn - Async or sync function to transform each element
808
+ * @returns A new async iterflow with transformed elements
809
+ * @example
810
+ * ```typescript
811
+ * await asyncIter([1, 2, 3]).map(async x => x * 2).toArray(); // [2, 4, 6]
812
+ * ```
813
+ */
814
+ map<U>(fn: (value: T) => U | Promise<U>): Asynciterflow<U>;
815
+ /**
816
+ * Filters elements based on an async or sync predicate function.
817
+ * Only elements for which the predicate returns true are included.
818
+ *
819
+ * @param predicate - Async or sync function to test each element
820
+ * @returns A new async iterflow with only elements that pass the predicate
821
+ * @example
822
+ * ```typescript
823
+ * await asyncIter([1, 2, 3, 4]).filter(async x => x % 2 === 0).toArray(); // [2, 4]
824
+ * ```
825
+ */
826
+ filter(predicate: (value: T) => boolean | Promise<boolean>): Asynciterflow<T>;
827
+ /**
828
+ * Takes only the first `limit` elements from the async iterator.
829
+ *
830
+ * @param limit - Maximum number of elements to take
831
+ * @returns A new async iterflow with at most `limit` elements
832
+ * @example
833
+ * ```typescript
834
+ * await asyncIter([1, 2, 3, 4, 5]).take(3).toArray(); // [1, 2, 3]
835
+ * ```
836
+ */
837
+ take(limit: number): Asynciterflow<T>;
838
+ /**
839
+ * Skips the first `count` elements from the async iterator.
840
+ *
841
+ * @param count - Number of elements to skip
842
+ * @returns A new async iterflow without the first `count` elements
843
+ * @example
844
+ * ```typescript
845
+ * await asyncIter([1, 2, 3, 4, 5]).drop(2).toArray(); // [3, 4, 5]
846
+ * ```
847
+ */
848
+ drop(count: number): Asynciterflow<T>;
849
+ /**
850
+ * Maps each element to an async iterable and flattens the results.
851
+ *
852
+ * @template U The type of elements in the resulting iterator
853
+ * @param fn - Async or sync function that maps each element to an async iterable
854
+ * @returns A new async iterflow with all mapped iterables flattened
855
+ * @example
856
+ * ```typescript
857
+ * await asyncIter([1, 2, 3]).flatMap(async x => [x, x * 2]).toArray(); // [1, 2, 2, 4, 3, 6]
858
+ * ```
859
+ */
860
+ flatMap<U>(fn: (value: T) => AsyncIterable<U> | Iterable<U> | Promise<AsyncIterable<U> | Iterable<U>>): Asynciterflow<U>;
861
+ /**
862
+ * Concatenates multiple async iterators sequentially.
863
+ *
864
+ * @param iterables - Additional async iterables to concatenate
865
+ * @returns A new async iterflow with all elements from all iterables
866
+ * @example
867
+ * ```typescript
868
+ * await asyncIter([1, 2]).concat([3, 4], [5, 6]).toArray();
869
+ * // [1, 2, 3, 4, 5, 6]
870
+ * ```
871
+ */
872
+ concat(...iterables: Array<AsyncIterable<T> | Iterable<T>>): Asynciterflow<T>;
873
+ /**
874
+ * Inserts a separator element between each item.
875
+ *
876
+ * @param separator - The element to insert between items
877
+ * @returns A new async iterflow with separators interspersed
878
+ * @example
879
+ * ```typescript
880
+ * await asyncIter([1, 2, 3]).intersperse(0).toArray();
881
+ * // [1, 0, 2, 0, 3]
882
+ * ```
883
+ */
884
+ intersperse(separator: T): Asynciterflow<T>;
885
+ /**
886
+ * Like reduce, but emits all intermediate accumulator values.
887
+ *
888
+ * @template U The type of the accumulated value
889
+ * @param fn - Async or sync function to combine the accumulator with each element
890
+ * @param initial - The initial value for the accumulator
891
+ * @returns A new async iterflow of intermediate accumulator values
892
+ * @example
893
+ * ```typescript
894
+ * await asyncIter([1, 2, 3, 4]).scan((acc, x) => acc + x, 0).toArray();
895
+ * // [0, 1, 3, 6, 10]
896
+ * ```
897
+ */
898
+ scan<U>(fn: (accumulator: U, value: T) => U | Promise<U>, initial: U): Asynciterflow<U>;
899
+ /**
900
+ * Adds index as tuple with each element [index, value].
901
+ *
902
+ * @returns A new async iterflow of tuples containing [index, value]
903
+ * @example
904
+ * ```typescript
905
+ * await asyncIter(['a', 'b', 'c']).enumerate().toArray();
906
+ * // [[0, 'a'], [1, 'b'], [2, 'c']]
907
+ * ```
908
+ */
909
+ enumerate(): Asynciterflow<[number, T]>;
910
+ /**
911
+ * Reverses the async iterator order.
912
+ * Warning: This operation buffers all elements in memory.
913
+ *
914
+ * @returns A new async iterflow with elements in reverse order
915
+ * @example
916
+ * ```typescript
917
+ * await asyncIter([1, 2, 3, 4, 5]).reverse().toArray();
918
+ * // [5, 4, 3, 2, 1]
919
+ * ```
920
+ */
921
+ reverse(): Asynciterflow<T>;
922
+ /**
923
+ * Sorts elements using default comparison.
924
+ * Warning: This operation buffers all elements in memory.
925
+ *
926
+ * @param this - async iterflow instance constrained to numbers or strings
927
+ * @returns A new async iterflow with elements sorted
928
+ * @example
929
+ * ```typescript
930
+ * await asyncIter([3, 1, 4, 1, 5]).sort().toArray();
931
+ * // [1, 1, 3, 4, 5]
932
+ * ```
933
+ */
934
+ sort(this: Asynciterflow<number | string>): Asynciterflow<number | string>;
935
+ /**
936
+ * Sorts elements using a custom comparison function.
937
+ * Warning: This operation buffers all elements in memory.
938
+ *
939
+ * @param compareFn - Function that compares two elements
940
+ * @returns A new async iterflow with elements sorted
941
+ * @example
942
+ * ```typescript
943
+ * await asyncIter([3, 1, 4, 1, 5]).sortBy((a, b) => a - b).toArray();
944
+ * // [1, 1, 3, 4, 5]
945
+ * ```
946
+ */
947
+ sortBy(compareFn: (a: T, b: T) => number): Asynciterflow<T>;
948
+ /**
949
+ * Collects all elements into an array.
950
+ * This is a terminal operation that consumes the async iterator.
951
+ *
952
+ * @returns A promise of an array containing all elements
953
+ * @example
954
+ * ```typescript
955
+ * await asyncIter([1, 2, 3]).map(async x => x * 2).toArray(); // [2, 4, 6]
956
+ * ```
957
+ */
958
+ toArray(): Promise<T[]>;
959
+ /**
960
+ * Counts the total number of elements in the async iterator.
961
+ * This is a terminal operation that consumes the async iterator.
962
+ *
963
+ * @returns A promise of the total count of elements
964
+ * @example
965
+ * ```typescript
966
+ * await asyncIter([1, 2, 3, 4, 5]).count(); // 5
967
+ * ```
968
+ */
969
+ count(): Promise<number>;
970
+ /**
971
+ * Executes a function for each element.
972
+ * This is a terminal operation that consumes the async iterator.
973
+ *
974
+ * @param fn - Async or sync function to execute for each element
975
+ * @returns A promise that resolves when all elements have been processed
976
+ * @example
977
+ * ```typescript
978
+ * await asyncIter([1, 2, 3]).forEach(async x => console.log(x));
979
+ * ```
980
+ */
981
+ forEach(fn: (value: T) => void | Promise<void>): Promise<void>;
982
+ /**
983
+ * Calculates the sum of all numeric elements.
984
+ * This is a terminal operation that consumes the async iterator.
985
+ *
986
+ * @param this - async iterflow instance constrained to numbers
987
+ * @returns A promise of the sum of all elements
988
+ * @example
989
+ * ```typescript
990
+ * await asyncIter([1, 2, 3, 4, 5]).sum(); // 15
991
+ * ```
992
+ */
993
+ sum(this: Asynciterflow<number>): Promise<number>;
994
+ /**
995
+ * Calculates the arithmetic mean (average) of all numeric elements.
996
+ * This is a terminal operation that consumes the async iterator.
997
+ *
998
+ * @param this - async iterflow instance constrained to numbers
999
+ * @returns A promise of the mean value, or undefined if empty
1000
+ * @example
1001
+ * ```typescript
1002
+ * await asyncIter([1, 2, 3, 4, 5]).mean(); // 3
1003
+ * ```
1004
+ */
1005
+ mean(this: Asynciterflow<number>): Promise<number | undefined>;
1006
+ /**
1007
+ * Finds the minimum value among all numeric elements.
1008
+ * This is a terminal operation that consumes the async iterator.
1009
+ *
1010
+ * @param this - async iterflow instance constrained to numbers
1011
+ * @returns A promise of the minimum value, or undefined if empty
1012
+ * @example
1013
+ * ```typescript
1014
+ * await asyncIter([3, 1, 4, 1, 5]).min(); // 1
1015
+ * ```
1016
+ */
1017
+ min(this: Asynciterflow<number>): Promise<number | undefined>;
1018
+ /**
1019
+ * Finds the maximum value among all numeric elements.
1020
+ * This is a terminal operation that consumes the async iterator.
1021
+ *
1022
+ * @param this - async iterflow instance constrained to numbers
1023
+ * @returns A promise of the maximum value, or undefined if empty
1024
+ * @example
1025
+ * ```typescript
1026
+ * await asyncIter([3, 1, 4, 1, 5]).max(); // 5
1027
+ * ```
1028
+ */
1029
+ max(this: Asynciterflow<number>): Promise<number | undefined>;
1030
+ /**
1031
+ * Calculates the median value of all numeric elements.
1032
+ * This is a terminal operation that consumes the async iterator.
1033
+ *
1034
+ * @param this - async iterflow instance constrained to numbers
1035
+ * @returns A promise of the median value, or undefined if empty
1036
+ * @example
1037
+ * ```typescript
1038
+ * await asyncIter([1, 2, 3, 4, 5]).median(); // 3
1039
+ * ```
1040
+ */
1041
+ median(this: Asynciterflow<number>): Promise<number | undefined>;
1042
+ /**
1043
+ * Calculates the variance of all numeric elements.
1044
+ * This is a terminal operation that consumes the async iterator.
1045
+ *
1046
+ * @param this - async iterflow instance constrained to numbers
1047
+ * @returns A promise of the variance, or undefined if empty
1048
+ * @example
1049
+ * ```typescript
1050
+ * await asyncIter([1, 2, 3, 4, 5]).variance(); // 2
1051
+ * ```
1052
+ */
1053
+ variance(this: Asynciterflow<number>): Promise<number | undefined>;
1054
+ /**
1055
+ * Calculates the standard deviation of all numeric elements.
1056
+ * This is a terminal operation that consumes the async iterator.
1057
+ *
1058
+ * @param this - async iterflow instance constrained to numbers
1059
+ * @returns A promise of the standard deviation, or undefined if empty
1060
+ * @example
1061
+ * ```typescript
1062
+ * await asyncIter([2, 4, 4, 4, 5, 5, 7, 9]).stdDev(); // ~2
1063
+ * ```
1064
+ */
1065
+ stdDev(this: Asynciterflow<number>): Promise<number | undefined>;
1066
+ /**
1067
+ * Calculates the specified percentile of all numeric elements.
1068
+ * This is a terminal operation that consumes the async iterator.
1069
+ *
1070
+ * @param this - async iterflow instance constrained to numbers
1071
+ * @param p - The percentile to calculate (0-100)
1072
+ * @returns A promise of the percentile value, or undefined if empty
1073
+ * @throws {Error} If p is not between 0 and 100
1074
+ * @example
1075
+ * ```typescript
1076
+ * await asyncIter([1, 2, 3, 4, 5]).percentile(50); // 3
1077
+ * ```
1078
+ */
1079
+ percentile(this: Asynciterflow<number>, p: number): Promise<number | undefined>;
1080
+ /**
1081
+ * Finds the most frequent value(s) in the dataset.
1082
+ * This is a terminal operation that consumes the async iterator.
1083
+ *
1084
+ * @param this - async iterflow instance constrained to numbers
1085
+ * @returns A promise of an array of the most frequent value(s), or undefined if empty
1086
+ * @example
1087
+ * ```typescript
1088
+ * await asyncIter([1, 2, 2, 3, 3, 3]).mode(); // [3]
1089
+ * ```
1090
+ */
1091
+ mode(this: Asynciterflow<number>): Promise<number[] | undefined>;
1092
+ /**
1093
+ * Calculates the quartiles (Q1, Q2, Q3) of all numeric elements.
1094
+ * This is a terminal operation that consumes the async iterator.
1095
+ *
1096
+ * @param this - async iterflow instance constrained to numbers
1097
+ * @returns A promise of an object with Q1, Q2, and Q3 values, or undefined if empty
1098
+ * @example
1099
+ * ```typescript
1100
+ * await asyncIter([1, 2, 3, 4, 5, 6, 7, 8, 9]).quartiles();
1101
+ * // { Q1: 3, Q2: 5, Q3: 7 }
1102
+ * ```
1103
+ */
1104
+ quartiles(this: Asynciterflow<number>): Promise<{
1105
+ Q1: number;
1106
+ Q2: number;
1107
+ Q3: number;
1108
+ } | undefined>;
1109
+ /**
1110
+ * Calculates the span (range from minimum to maximum value).
1111
+ * This is a terminal operation that consumes the async iterator.
1112
+ *
1113
+ * @param this - async iterflow instance constrained to numbers
1114
+ * @returns A promise of the span (max - min), or undefined if empty
1115
+ * @example
1116
+ * ```typescript
1117
+ * await asyncIter([1, 2, 3, 4, 5]).span(); // 4
1118
+ * ```
1119
+ */
1120
+ span(this: Asynciterflow<number>): Promise<number | undefined>;
1121
+ /**
1122
+ * Calculates the product of all numeric elements.
1123
+ * This is a terminal operation that consumes the async iterator.
1124
+ *
1125
+ * @param this - async iterflow instance constrained to numbers
1126
+ * @returns A promise of the product of all elements
1127
+ * @example
1128
+ * ```typescript
1129
+ * await asyncIter([1, 2, 3, 4, 5]).product(); // 120
1130
+ * ```
1131
+ */
1132
+ product(this: Asynciterflow<number>): Promise<number>;
1133
+ /**
1134
+ * Calculates the covariance between two numeric sequences.
1135
+ * This is a terminal operation that consumes the async iterator.
1136
+ *
1137
+ * @param this - async iterflow instance constrained to numbers
1138
+ * @param other - An async iterable of numbers to compare with
1139
+ * @returns A promise of the covariance, or undefined if sequences are empty or have different lengths
1140
+ * @example
1141
+ * ```typescript
1142
+ * await asyncIter([1, 2, 3, 4, 5]).covariance([2, 4, 6, 8, 10]); // 4
1143
+ * ```
1144
+ */
1145
+ covariance(this: Asynciterflow<number>, other: AsyncIterable<number> | Iterable<number>): Promise<number | undefined>;
1146
+ /**
1147
+ * Calculates the Pearson correlation coefficient between two numeric sequences.
1148
+ * This is a terminal operation that consumes the async iterator.
1149
+ *
1150
+ * @param this - async iterflow instance constrained to numbers
1151
+ * @param other - An async iterable of numbers to compare with
1152
+ * @returns A promise of the correlation coefficient, or undefined if sequences are empty or have different lengths
1153
+ * @example
1154
+ * ```typescript
1155
+ * await asyncIter([1, 2, 3, 4, 5]).correlation([2, 4, 6, 8, 10]); // 1
1156
+ * ```
1157
+ */
1158
+ correlation(this: Asynciterflow<number>, other: AsyncIterable<number> | Iterable<number>): Promise<number | undefined>;
1159
+ /**
1160
+ * Creates a sliding window of the specified size over the elements.
1161
+ *
1162
+ * @param size - The size of each window
1163
+ * @returns A new async iterflow of arrays, each containing `size` consecutive elements
1164
+ * @throws {Error} If size is less than 1
1165
+ * @example
1166
+ * ```typescript
1167
+ * await asyncIter([1, 2, 3, 4, 5]).window(3).toArray();
1168
+ * // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
1169
+ * ```
1170
+ */
1171
+ window(size: number): Asynciterflow<T[]>;
1172
+ /**
1173
+ * Splits elements into chunks of the specified size.
1174
+ *
1175
+ * @param size - The size of each chunk
1176
+ * @returns A new async iterflow of arrays, each containing up to `size` elements
1177
+ * @throws {Error} If size is less than 1
1178
+ * @example
1179
+ * ```typescript
1180
+ * await asyncIter([1, 2, 3, 4, 5]).chunk(2).toArray();
1181
+ * // [[1, 2], [3, 4], [5]]
1182
+ * ```
1183
+ */
1184
+ chunk(size: number): Asynciterflow<T[]>;
1185
+ /**
1186
+ * Creates pairs of consecutive elements.
1187
+ *
1188
+ * @returns A new async iterflow of tuples, each containing two consecutive elements
1189
+ * @example
1190
+ * ```typescript
1191
+ * await asyncIter([1, 2, 3, 4]).pairwise().toArray();
1192
+ * // [[1, 2], [2, 3], [3, 4]]
1193
+ * ```
1194
+ */
1195
+ pairwise(): Asynciterflow<[T, T]>;
1196
+ /**
1197
+ * Removes duplicate elements, keeping only the first occurrence.
1198
+ *
1199
+ * @returns A new async iterflow with duplicate elements removed
1200
+ * @example
1201
+ * ```typescript
1202
+ * await asyncIter([1, 2, 2, 3, 1, 4]).distinct().toArray();
1203
+ * // [1, 2, 3, 4]
1204
+ * ```
1205
+ */
1206
+ distinct(): Asynciterflow<T>;
1207
+ /**
1208
+ * Removes duplicate elements based on a key function.
1209
+ *
1210
+ * @template K The type of the key used for comparison
1211
+ * @param keyFn - Async or sync function to extract the comparison key
1212
+ * @returns A new async iterflow with duplicate elements (by key) removed
1213
+ * @example
1214
+ * ```typescript
1215
+ * const users = [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 1, name: 'Charlie'}];
1216
+ * await asyncIter(users).distinctBy(async u => u.id).toArray();
1217
+ * // [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}]
1218
+ * ```
1219
+ */
1220
+ distinctBy<K>(keyFn: (value: T) => K | Promise<K>): Asynciterflow<T>;
1221
+ /**
1222
+ * Executes a side-effect function on each element without modifying the stream.
1223
+ *
1224
+ * @param fn - Async or sync function to execute for each element
1225
+ * @returns A new async iterflow with the same elements
1226
+ * @example
1227
+ * ```typescript
1228
+ * await asyncIter([1, 2, 3])
1229
+ * .tap(async x => console.log('Processing:', x))
1230
+ * .map(async x => x * 2)
1231
+ * .toArray(); // logs each value, returns [2, 4, 6]
1232
+ * ```
1233
+ */
1234
+ tap(fn: (value: T) => void | Promise<void>): Asynciterflow<T>;
1235
+ /**
1236
+ * Takes elements while the predicate returns true, then stops.
1237
+ *
1238
+ * @param predicate - Async or sync function to test each element
1239
+ * @returns A new async iterflow with elements up to the first failing predicate
1240
+ * @example
1241
+ * ```typescript
1242
+ * await asyncIter([1, 2, 3, 4, 1, 2]).takeWhile(async x => x < 4).toArray();
1243
+ * // [1, 2, 3]
1244
+ * ```
1245
+ */
1246
+ takeWhile(predicate: (value: T) => boolean | Promise<boolean>): Asynciterflow<T>;
1247
+ /**
1248
+ * Skips elements while the predicate returns true, then yields all remaining.
1249
+ *
1250
+ * @param predicate - Async or sync function to test each element
1251
+ * @returns A new async iterflow starting from the first element that fails the predicate
1252
+ * @example
1253
+ * ```typescript
1254
+ * await asyncIter([1, 2, 3, 4, 1, 2]).dropWhile(async x => x < 3).toArray();
1255
+ * // [3, 4, 1, 2]
1256
+ * ```
1257
+ */
1258
+ dropWhile(predicate: (value: T) => boolean | Promise<boolean>): Asynciterflow<T>;
1259
+ /**
1260
+ * Splits elements into two arrays based on a predicate.
1261
+ * This is a terminal operation that consumes the async iterator.
1262
+ *
1263
+ * @param predicate - Async or sync function to test each element
1264
+ * @returns A promise of a tuple of two arrays
1265
+ * @example
1266
+ * ```typescript
1267
+ * await asyncIter([1, 2, 3, 4, 5]).partition(async x => x % 2 === 0);
1268
+ * // [[2, 4], [1, 3, 5]]
1269
+ * ```
1270
+ */
1271
+ partition(predicate: (value: T) => boolean | Promise<boolean>): Promise<[T[], T[]]>;
1272
+ /**
1273
+ * Groups elements by a key function into a Map.
1274
+ * This is a terminal operation that consumes the async iterator.
1275
+ *
1276
+ * @template K The type of the grouping key
1277
+ * @param keyFn - Async or sync function to extract the grouping key
1278
+ * @returns A promise of a Map where keys are the result of keyFn and values are arrays of elements
1279
+ * @example
1280
+ * ```typescript
1281
+ * await asyncIter(['alice', 'bob', 'charlie', 'dave'])
1282
+ * .groupBy(async name => name.length);
1283
+ * // Map { 3 => ['bob'], 5 => ['alice'], 7 => ['charlie'], 4 => ['dave'] }
1284
+ * ```
1285
+ */
1286
+ groupBy<K>(keyFn: (value: T) => K | Promise<K>): Promise<Map<K, T[]>>;
1287
+ /**
1288
+ * Reduces the async iterator to a single value using an accumulator function.
1289
+ * This is a terminal operation that consumes the async iterator.
1290
+ *
1291
+ * @template U The type of the accumulated value
1292
+ * @param fn - Async or sync function to combine the accumulator with each element
1293
+ * @param initial - The initial value for the accumulator
1294
+ * @returns A promise of the final accumulated value
1295
+ * @example
1296
+ * ```typescript
1297
+ * await asyncIter([1, 2, 3, 4]).reduce(async (acc, x) => acc + x, 0); // 10
1298
+ * ```
1299
+ */
1300
+ reduce<U>(fn: (accumulator: U, value: T) => U | Promise<U>, initial: U): Promise<U>;
1301
+ /**
1302
+ * Finds the first element that matches the predicate.
1303
+ * This is a terminal operation that may consume part of the async iterator.
1304
+ *
1305
+ * @param predicate - Async or sync function to test each element
1306
+ * @returns A promise of the first matching element, or undefined if none found
1307
+ * @example
1308
+ * ```typescript
1309
+ * await asyncIter([1, 2, 3, 4, 5]).find(async x => x > 3); // 4
1310
+ * ```
1311
+ */
1312
+ find(predicate: (value: T) => boolean | Promise<boolean>): Promise<T | undefined>;
1313
+ /**
1314
+ * Finds the index of the first element that matches the predicate.
1315
+ * This is a terminal operation that may consume part of the async iterator.
1316
+ *
1317
+ * @param predicate - Async or sync function to test each element
1318
+ * @returns A promise of the index of the first matching element, or -1 if none found
1319
+ * @example
1320
+ * ```typescript
1321
+ * await asyncIter([1, 2, 3, 4, 5]).findIndex(async x => x > 3); // 3
1322
+ * ```
1323
+ */
1324
+ findIndex(predicate: (value: T) => boolean | Promise<boolean>): Promise<number>;
1325
+ /**
1326
+ * Tests whether at least one element matches the predicate.
1327
+ * This is a terminal operation that may consume part of the async iterator.
1328
+ *
1329
+ * @param predicate - Async or sync function to test each element
1330
+ * @returns A promise of true if any element matches, false otherwise
1331
+ * @example
1332
+ * ```typescript
1333
+ * await asyncIter([1, 2, 3, 4, 5]).some(async x => x > 3); // true
1334
+ * ```
1335
+ */
1336
+ some(predicate: (value: T) => boolean | Promise<boolean>): Promise<boolean>;
1337
+ /**
1338
+ * Tests whether all elements match the predicate.
1339
+ * This is a terminal operation that may consume part or all of the async iterator.
1340
+ *
1341
+ * @param predicate - Async or sync function to test each element
1342
+ * @returns A promise of true if all elements match, false otherwise
1343
+ * @example
1344
+ * ```typescript
1345
+ * await asyncIter([2, 4, 6]).every(async x => x % 2 === 0); // true
1346
+ * ```
1347
+ */
1348
+ every(predicate: (value: T) => boolean | Promise<boolean>): Promise<boolean>;
1349
+ /**
1350
+ * Gets the first element from the async iterator.
1351
+ * This is a terminal operation that consumes the first element.
1352
+ *
1353
+ * @param defaultValue - Optional default value to return if iterator is empty
1354
+ * @returns A promise of the first element, the default value, or undefined if empty and no default
1355
+ * @example
1356
+ * ```typescript
1357
+ * await asyncIter([1, 2, 3]).first(); // 1
1358
+ * ```
1359
+ */
1360
+ first(defaultValue?: T): Promise<T | undefined>;
1361
+ /**
1362
+ * Gets the last element from the async iterator.
1363
+ * This is a terminal operation that consumes the entire async iterator.
1364
+ *
1365
+ * @param defaultValue - Optional default value to return if iterator is empty
1366
+ * @returns A promise of the last element, the default value, or undefined if empty and no default
1367
+ * @example
1368
+ * ```typescript
1369
+ * await asyncIter([1, 2, 3]).last(); // 3
1370
+ * ```
1371
+ */
1372
+ last(defaultValue?: T): Promise<T | undefined>;
1373
+ /**
1374
+ * Gets the element at the specified index.
1375
+ * This is a terminal operation that may consume part of the async iterator.
1376
+ *
1377
+ * @param index - Zero-based index of the element to retrieve
1378
+ * @returns A promise of the element at the index, or undefined if index is out of bounds
1379
+ * @example
1380
+ * ```typescript
1381
+ * await asyncIter([1, 2, 3, 4, 5]).nth(2); // 3
1382
+ * ```
1383
+ */
1384
+ nth(index: number): Promise<T | undefined>;
1385
+ /**
1386
+ * Checks if the async iterator is empty.
1387
+ * This is a terminal operation that may consume the first element.
1388
+ *
1389
+ * @returns A promise of true if the iterator has no elements, false otherwise
1390
+ * @example
1391
+ * ```typescript
1392
+ * await asyncIter([]).isEmpty(); // true
1393
+ * ```
1394
+ */
1395
+ isEmpty(): Promise<boolean>;
1396
+ /**
1397
+ * Checks if the async iterator includes a specific value.
1398
+ * This is a terminal operation that may consume part or all of the async iterator.
1399
+ *
1400
+ * @param searchValue - The value to search for
1401
+ * @returns A promise of true if the value is found, false otherwise
1402
+ * @example
1403
+ * ```typescript
1404
+ * await asyncIter([1, 2, 3, 4, 5]).includes(3); // true
1405
+ * ```
1406
+ */
1407
+ includes(searchValue: T): Promise<boolean>;
1408
+ /**
1409
+ * Maps elements in parallel with a concurrency limit.
1410
+ * Processes multiple elements simultaneously while respecting the concurrency limit.
1411
+ *
1412
+ * @template U The type of the transformed elements
1413
+ * @param fn - Async function to transform each element
1414
+ * @param concurrency - Maximum number of concurrent operations (default: 10)
1415
+ * @returns A new async iterflow with transformed elements
1416
+ * @example
1417
+ * ```typescript
1418
+ * await asyncIter([1, 2, 3, 4, 5])
1419
+ * .mapParallel(async x => {
1420
+ * await sleep(100);
1421
+ * return x * 2;
1422
+ * }, 3)
1423
+ * .toArray(); // Processes 3 items at a time
1424
+ * ```
1425
+ */
1426
+ mapParallel<U>(fn: (value: T) => Promise<U>, concurrency?: number): Asynciterflow<U>;
1427
+ /**
1428
+ * Filters elements in parallel with a concurrency limit.
1429
+ *
1430
+ * @param predicate - Async function to test each element
1431
+ * @param concurrency - Maximum number of concurrent operations (default: 10)
1432
+ * @returns A new async iterflow with only elements that pass the predicate
1433
+ * @example
1434
+ * ```typescript
1435
+ * await asyncIter([1, 2, 3, 4, 5])
1436
+ * .filterParallel(async x => {
1437
+ * await sleep(100);
1438
+ * return x % 2 === 0;
1439
+ * }, 3)
1440
+ * .toArray(); // [2, 4]
1441
+ * ```
1442
+ */
1443
+ filterParallel(predicate: (value: T) => Promise<boolean>, concurrency?: number): Asynciterflow<T>;
1444
+ /**
1445
+ * FlatMaps elements in parallel with a concurrency limit.
1446
+ *
1447
+ * @template U The type of elements in the resulting iterator
1448
+ * @param fn - Async function that maps each element to an async iterable
1449
+ * @param concurrency - Maximum number of concurrent operations (default: 10)
1450
+ * @returns A new async iterflow with all mapped iterables flattened
1451
+ * @example
1452
+ * ```typescript
1453
+ * await asyncIter([1, 2, 3])
1454
+ * .flatMapParallel(async x => [x, x * 2], 2)
1455
+ * .toArray(); // [1, 2, 2, 4, 3, 6]
1456
+ * ```
1457
+ */
1458
+ flatMapParallel<U>(fn: (value: T) => Promise<AsyncIterable<U> | Iterable<U>>, concurrency?: number): Asynciterflow<U>;
1459
+ /**
1460
+ * Buffers elements up to a specified size.
1461
+ *
1462
+ * @param size - Maximum buffer size
1463
+ * @returns A new async iterflow with buffered elements
1464
+ * @example
1465
+ * ```typescript
1466
+ * await asyncIter([1, 2, 3, 4, 5]).buffer(2).toArray();
1467
+ * // [[1, 2], [3, 4], [5]]
1468
+ * ```
1469
+ */
1470
+ buffer(size: number): Asynciterflow<T[]>;
1471
+ /**
1472
+ * Throttles the stream to emit at most one value per time interval.
1473
+ *
1474
+ * @param intervalMs - Minimum time between emissions in milliseconds
1475
+ * @returns A new async iterflow with throttled elements
1476
+ * @example
1477
+ * ```typescript
1478
+ * await asyncIter([1, 2, 3, 4, 5]).throttle(100).toArray();
1479
+ * // Emits one value every 100ms
1480
+ * ```
1481
+ */
1482
+ throttle(intervalMs: number): Asynciterflow<T>;
1483
+ /**
1484
+ * Debounces the stream, only emitting values after a period of silence.
1485
+ *
1486
+ * @param waitMs - Time to wait for silence in milliseconds
1487
+ * @returns A new async iterflow with debounced elements
1488
+ * @example
1489
+ * ```typescript
1490
+ * await asyncIter([1, 2, 3, 4, 5]).debounce(100).toArray();
1491
+ * // Only emits values after 100ms of no new values
1492
+ * ```
1493
+ */
1494
+ debounce(waitMs: number): Asynciterflow<T>;
1495
+ /**
1496
+ * Catches errors and continues with a fallback value or stream.
1497
+ *
1498
+ * @param handler - Function to handle errors and return a fallback value or async iterable
1499
+ * @returns A new async iterflow with error handling
1500
+ * @example
1501
+ * ```typescript
1502
+ * await asyncIter([1, 2, 3])
1503
+ * .map(async x => {
1504
+ * if (x === 2) throw new Error('Error!');
1505
+ * return x;
1506
+ * })
1507
+ * .catchError(async (error) => [-1])
1508
+ * .toArray(); // [1, -1, 3]
1509
+ * ```
1510
+ */
1511
+ catchError(handler: (error: unknown) => T | AsyncIterable<T> | Iterable<T> | Promise<T | AsyncIterable<T> | Iterable<T>>): Asynciterflow<T>;
1512
+ /**
1513
+ * Retries failed operations a specified number of times.
1514
+ *
1515
+ * @param maxRetries - Maximum number of retry attempts
1516
+ * @param delayMs - Optional delay between retries in milliseconds
1517
+ * @returns A new async iterflow with retry logic
1518
+ * @example
1519
+ * ```typescript
1520
+ * await asyncIter([1, 2, 3])
1521
+ * .map(async x => {
1522
+ * if (Math.random() > 0.5) throw new Error('Random error');
1523
+ * return x;
1524
+ * })
1525
+ * .retry(3, 100)
1526
+ * .toArray(); // Retries up to 3 times with 100ms delay
1527
+ * ```
1528
+ */
1529
+ retry(maxRetries: number, delayMs?: number): Asynciterflow<T>;
1530
+ /**
1531
+ * Handles errors for each element individually.
1532
+ *
1533
+ * @param handler - Async or sync function to handle errors for each element
1534
+ * @returns A new async iterflow with error handling
1535
+ * @example
1536
+ * ```typescript
1537
+ * await asyncIter([1, 2, 3])
1538
+ * .map(async x => {
1539
+ * if (x === 2) throw new Error('Error!');
1540
+ * return x;
1541
+ * })
1542
+ * .onError(async (error, value) => console.error('Error:', error))
1543
+ * .toArray(); // [1, 3] (2 is skipped)
1544
+ * ```
1545
+ */
1546
+ onError(handler: (error: unknown, value?: T) => void | Promise<void>): Asynciterflow<T>;
1547
+ }
1548
+ /**
1549
+ * Creates an async iterflow instance from an async iterable or iterable.
1550
+ * This is the main entry point for working with async iterables in a fluent API style.
1551
+ *
1552
+ * @template T The type of elements in the iterable
1553
+ * @param source - The async iterable or iterable to wrap
1554
+ * @returns A new async iterflow instance
1555
+ * @example
1556
+ * ```typescript
1557
+ * await asyncIter(asyncIterable)
1558
+ * .filter(async x => x % 2 === 0)
1559
+ * .map(async x => x * 2)
1560
+ * .toArray(); // [4, 8]
1561
+ * ```
1562
+ */
1563
+ declare function asyncIter<T>(source: AsyncIterable<T> | Iterable<T>): Asynciterflow<T>;
1564
+ declare namespace asyncIter {
1565
+ /**
1566
+ * Combines two async iterables into an async iterator of tuples.
1567
+ * Stops when the shorter iterable is exhausted.
1568
+ *
1569
+ * @template T The type of elements in the first iterable
1570
+ * @template U The type of elements in the second iterable
1571
+ * @param iter1 - The first async iterable
1572
+ * @param iter2 - The second async iterable
1573
+ * @returns A new async iterflow of tuples pairing elements from both iterables
1574
+ * @example
1575
+ * ```typescript
1576
+ * await asyncIter.zip(asyncIter1, asyncIter2).toArray();
1577
+ * // [[1, 'a'], [2, 'b'], [3, 'c']]
1578
+ * ```
1579
+ */
1580
+ function zip<T, U>(iter1: AsyncIterable<T> | Iterable<T>, iter2: AsyncIterable<U> | Iterable<U>): Asynciterflow<[T, U]>;
1581
+ /**
1582
+ * Combines two async iterables using a combining function.
1583
+ * Stops when the shorter iterable is exhausted.
1584
+ *
1585
+ * @template T The type of elements in the first iterable
1586
+ * @template U The type of elements in the second iterable
1587
+ * @template R The type of the result
1588
+ * @param iter1 - The first async iterable
1589
+ * @param iter2 - The second async iterable
1590
+ * @param fn - Async or sync function to combine elements
1591
+ * @returns A new async iterflow with combined results
1592
+ * @example
1593
+ * ```typescript
1594
+ * await asyncIter.zipWith(asyncIter1, asyncIter2, async (a, b) => a + b).toArray();
1595
+ * // [11, 22, 33]
1596
+ * ```
1597
+ */
1598
+ function zipWith<T, U, R>(iter1: AsyncIterable<T> | Iterable<T>, iter2: AsyncIterable<U> | Iterable<U>, fn: (a: T, b: U) => R | Promise<R>): Asynciterflow<R>;
1599
+ /**
1600
+ * Generates an async sequence of numbers.
1601
+ *
1602
+ * @param stop - The end value (exclusive)
1603
+ * @returns A new async iterflow of numbers
1604
+ * @example
1605
+ * ```typescript
1606
+ * await asyncIter.range(5).toArray(); // [0, 1, 2, 3, 4]
1607
+ * ```
1608
+ */
1609
+ function range(stop: number): Asynciterflow<number>;
1610
+ function range(start: number, stop: number): Asynciterflow<number>;
1611
+ function range(start: number, stop: number, step: number): Asynciterflow<number>;
1612
+ /**
1613
+ * Repeats a value a specified number of times, or infinitely.
1614
+ *
1615
+ * @template T The type of the value to repeat
1616
+ * @param value - The value to repeat
1617
+ * @param times - Optional number of times to repeat (infinite if omitted)
1618
+ * @returns A new async iterflow repeating the value
1619
+ * @example
1620
+ * ```typescript
1621
+ * await asyncIter.repeat('x', 3).toArray(); // ['x', 'x', 'x']
1622
+ * ```
1623
+ */
1624
+ function repeat<T>(value: T, times?: number): Asynciterflow<T>;
1625
+ /**
1626
+ * Alternates elements from multiple async iterables in a round-robin fashion.
1627
+ *
1628
+ * @template T The type of elements in all iterables
1629
+ * @param iterables - Variable number of async iterables to interleave
1630
+ * @returns A new async iterflow with elements from all iterables interleaved
1631
+ * @example
1632
+ * ```typescript
1633
+ * await asyncIter.interleave(asyncIter1, asyncIter2).toArray();
1634
+ * // [1, 4, 2, 5, 3, 6]
1635
+ * ```
1636
+ */
1637
+ function interleave<T>(...iterables: Array<AsyncIterable<T> | Iterable<T>>): Asynciterflow<T>;
1638
+ /**
1639
+ * Merges multiple sorted async iterables into a single sorted async iterator.
1640
+ *
1641
+ * @template T The type of elements in all iterables
1642
+ * @param iterables - Variable number of sorted async iterables to merge
1643
+ * @returns A new async iterflow with all elements merged in sorted order
1644
+ * @example
1645
+ * ```typescript
1646
+ * await asyncIter.merge(asyncIter1, asyncIter2).toArray();
1647
+ * // [1, 2, 3, 4, 5, 6]
1648
+ * ```
1649
+ */
1650
+ function merge<T>(...iterables: Array<AsyncIterable<T> | Iterable<T>>): Asynciterflow<T>;
1651
+ function merge<T>(compareFn: (a: T, b: T) => number, ...iterables: Array<AsyncIterable<T> | Iterable<T>>): Asynciterflow<T>;
1652
+ /**
1653
+ * Chains multiple async iterables sequentially, one after another.
1654
+ *
1655
+ * @template T The type of elements in all iterables
1656
+ * @param iterables - Variable number of async iterables to chain
1657
+ * @returns A new async iterflow with all elements chained sequentially
1658
+ * @example
1659
+ * ```typescript
1660
+ * await asyncIter.chain(asyncIter1, asyncIter2).toArray();
1661
+ * // [1, 2, 3, 4, 5, 6]
1662
+ * ```
1663
+ */
1664
+ function chain<T>(...iterables: Array<AsyncIterable<T> | Iterable<T>>): Asynciterflow<T>;
1665
+ /**
1666
+ * Creates an async iterator from a generator function.
1667
+ *
1668
+ * @template T The type of elements to generate
1669
+ * @param fn - Async generator function
1670
+ * @returns A new async iterflow
1671
+ * @example
1672
+ * ```typescript
1673
+ * const fibonacci = asyncIter.fromGenerator(async function* () {
1674
+ * let [a, b] = [0, 1];
1675
+ * while (true) {
1676
+ * yield a;
1677
+ * [a, b] = [b, a + b];
1678
+ * }
1679
+ * });
1680
+ * await fibonacci.take(10).toArray(); // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
1681
+ * ```
1682
+ */
1683
+ function fromGenerator<T>(fn: () => AsyncGenerator<T>): Asynciterflow<T>;
1684
+ /**
1685
+ * Creates an async iterator from a promise.
1686
+ *
1687
+ * @template T The type of the resolved value
1688
+ * @param promise - Promise to convert to async iterator
1689
+ * @returns A new async iterflow
1690
+ * @example
1691
+ * ```typescript
1692
+ * await asyncIter.fromPromise(fetch('/api/data').then(r => r.json())).toArray();
1693
+ * ```
1694
+ */
1695
+ function fromPromise<T>(promise: Promise<T>): Asynciterflow<T>;
1696
+ /**
1697
+ * Creates an async iterator from an array of promises, yielding results as they resolve.
1698
+ *
1699
+ * @template T The type of the resolved values
1700
+ * @param promises - Array of promises
1701
+ * @returns A new async iterflow
1702
+ * @example
1703
+ * ```typescript
1704
+ * const promises = [fetch('/api/1'), fetch('/api/2'), fetch('/api/3')];
1705
+ * await asyncIter.fromPromises(promises).map(r => r.json()).toArray();
1706
+ * ```
1707
+ */
1708
+ function fromPromises<T>(promises: Promise<T>[]): Asynciterflow<T>;
1709
+ }
1710
+
1711
+ /**
1712
+ * Error handling utilities and custom error classes for iterflow
1713
+ * @module errors
1714
+ */
1715
+ /**
1716
+ * Base error class for all iterflow errors
1717
+ */
1718
+ declare class iterflowError extends Error {
1719
+ readonly operation?: string;
1720
+ readonly context?: Record<string, unknown>;
1721
+ constructor(message: string, operation?: string, context?: Record<string, unknown>);
1722
+ /**
1723
+ * Returns a detailed error message with context
1724
+ */
1725
+ toDetailedString(): string;
1726
+ }
1727
+ /**
1728
+ * Error thrown when operation parameters are invalid
1729
+ */
1730
+ declare class ValidationError extends iterflowError {
1731
+ constructor(message: string, operation?: string, context?: Record<string, unknown>);
1732
+ }
1733
+ /**
1734
+ * Error thrown when an operation fails during execution
1735
+ */
1736
+ declare class OperationError extends iterflowError {
1737
+ readonly cause?: Error;
1738
+ constructor(message: string, operation?: string, cause?: Error, context?: Record<string, unknown>);
1739
+ toDetailedString(): string;
1740
+ }
1741
+ /**
1742
+ * Error thrown when an operation requires a non-empty sequence
1743
+ */
1744
+ declare class EmptySequenceError extends iterflowError {
1745
+ constructor(operation: string, message?: string);
1746
+ }
1747
+ /**
1748
+ * Error thrown when accessing an invalid index
1749
+ */
1750
+ declare class IndexOutOfBoundsError extends iterflowError {
1751
+ readonly index: number;
1752
+ readonly size?: number;
1753
+ constructor(index: number, size?: number, operation?: string);
1754
+ }
1755
+ /**
1756
+ * Error thrown when a type conversion or coercion fails
1757
+ */
1758
+ declare class TypeConversionError extends iterflowError {
1759
+ readonly value: unknown;
1760
+ readonly expectedType: string;
1761
+ constructor(value: unknown, expectedType: string, operation?: string);
1762
+ }
1763
+
1764
+ /**
1765
+ * Input validation utilities for iterflow operations
1766
+ * @module validation
1767
+ */
1768
+ /**
1769
+ * Validates that a value is a positive integer
1770
+ */
1771
+ declare function validatePositiveInteger(value: number, paramName: string, operation?: string): void;
1772
+ /**
1773
+ * Validates that a value is a non-negative integer
1774
+ */
1775
+ declare function validateNonNegativeInteger(value: number, paramName: string, operation?: string): void;
1776
+ /**
1777
+ * Validates that a value is within a specific range
1778
+ */
1779
+ declare function validateRange(value: number, min: number, max: number, paramName: string, operation?: string): void;
1780
+ /**
1781
+ * Validates that a value is a finite number (not NaN or Infinity)
1782
+ */
1783
+ declare function validateFiniteNumber(value: number, paramName: string, operation?: string): void;
1784
+ /**
1785
+ * Validates that a value is not zero
1786
+ */
1787
+ declare function validateNonZero(value: number, paramName: string, operation?: string): void;
1788
+ /**
1789
+ * Validates that a value is a function
1790
+ */
1791
+ declare function validateFunction(value: unknown, paramName: string, operation?: string): asserts value is Function;
1792
+ /**
1793
+ * Validates that a value is iterable
1794
+ */
1795
+ declare function validateIterable<T>(value: unknown, paramName: string, operation?: string): asserts value is Iterable<T>;
1796
+ /**
1797
+ * Validates that a value is a valid comparator function
1798
+ */
1799
+ declare function validateComparator<T>(fn: unknown, operation?: string): asserts fn is (a: T, b: T) => number;
1800
+ /**
1801
+ * Validates that an array is not empty
1802
+ */
1803
+ declare function validateNonEmpty<T>(arr: T[], operation?: string): void;
1804
+ /**
1805
+ * Safely converts a value to a number
1806
+ */
1807
+ declare function toNumber(value: unknown, operation?: string): number;
1808
+ /**
1809
+ * Safely converts a value to an integer
1810
+ */
1811
+ declare function toInteger(value: unknown, operation?: string): number;
1812
+ /**
1813
+ * Validates array index
1814
+ */
1815
+ declare function validateIndex(index: number, size: number, operation?: string): void;
1816
+
1817
+ /**
1818
+ * Debug mode and operation tracing utilities for iterflow
1819
+ * @module debug
1820
+ */
1821
+ /**
1822
+ * Trace entry representing a single operation execution
1823
+ */
1824
+ interface TraceEntry {
1825
+ operation: string;
1826
+ timestamp: number;
1827
+ input?: unknown;
1828
+ output?: unknown;
1829
+ error?: Error;
1830
+ duration?: number;
1831
+ metadata?: Record<string, unknown>;
1832
+ }
1833
+ /**
1834
+ * Debug configuration options
1835
+ */
1836
+ interface DebugConfig {
1837
+ enabled: boolean;
1838
+ traceOperations: boolean;
1839
+ traceInput: boolean;
1840
+ traceOutput: boolean;
1841
+ logToConsole: boolean;
1842
+ maxTraceEntries?: number;
1843
+ }
1844
+ /**
1845
+ * Enable debug mode
1846
+ */
1847
+ declare function enableDebug(config?: Partial<DebugConfig>): void;
1848
+ /**
1849
+ * Disable debug mode
1850
+ */
1851
+ declare function disableDebug(): void;
1852
+ /**
1853
+ * Check if debug mode is enabled
1854
+ */
1855
+ declare function isDebugEnabled(): boolean;
1856
+ /**
1857
+ * Get debug configuration
1858
+ */
1859
+ declare function getDebugConfig(): Readonly<DebugConfig>;
1860
+ /**
1861
+ * Add a trace entry
1862
+ */
1863
+ declare function addTrace(entry: TraceEntry): void;
1864
+ /**
1865
+ * Get all trace entries
1866
+ */
1867
+ declare function getTraces(): readonly TraceEntry[];
1868
+ /**
1869
+ * Clear all traces
1870
+ */
1871
+ declare function clearTraces(): void;
1872
+ /**
1873
+ * Get traces for a specific operation
1874
+ */
1875
+ declare function getTracesForOperation(operation: string): TraceEntry[];
1876
+ /**
1877
+ * Get trace summary statistics
1878
+ */
1879
+ declare function getTraceSummary(): Record<string, {
1880
+ count: number;
1881
+ avgDuration: number;
1882
+ errors: number;
1883
+ }>;
1884
+ /**
1885
+ * Wrapper function to trace operation execution
1886
+ */
1887
+ declare function traceOperation<T>(operation: string, fn: () => T, metadata?: Record<string, unknown>): T;
1888
+ /**
1889
+ * Async version of traceOperation
1890
+ */
1891
+ declare function traceOperationAsync<T>(operation: string, fn: () => Promise<T>, metadata?: Record<string, unknown>): Promise<T>;
1892
+
1893
+ /**
1894
+ * Error recovery utilities for iterflow
1895
+ * @module recovery
1896
+ */
1897
+ /**
1898
+ * Error handler function type
1899
+ */
1900
+ type ErrorHandler<T, R = T> = (error: Error, element?: T, index?: number) => R;
1901
+ /**
1902
+ * Options for retry behavior
1903
+ */
1904
+ interface RetryOptions {
1905
+ maxAttempts?: number;
1906
+ delay?: number;
1907
+ backoff?: boolean;
1908
+ onRetry?: (attempt: number, error: Error) => void;
1909
+ }
1910
+ /**
1911
+ * Wraps a function with error recovery
1912
+ */
1913
+ declare function withErrorRecovery<T, R>(fn: (value: T, index?: number) => R, errorHandler: ErrorHandler<T, R>): (value: T, index?: number) => R;
1914
+ /**
1915
+ * Wraps a function with retry logic
1916
+ */
1917
+ declare function withRetry<T extends any[], R>(fn: (...args: T) => R, options?: RetryOptions): (...args: T) => R;
1918
+ /**
1919
+ * Async version of withRetry
1920
+ */
1921
+ declare function withRetryAsync<T extends any[], R>(fn: (...args: T) => Promise<R>, options?: RetryOptions): (...args: T) => Promise<R>;
1922
+ /**
1923
+ * Returns a default value if an error occurs
1924
+ */
1925
+ declare function withDefault<T, R>(fn: (value: T) => R, defaultValue: R): (value: T) => R;
1926
+ /**
1927
+ * Returns undefined if an error occurs (swallows errors)
1928
+ */
1929
+ declare function tryOr<T, R>(fn: (value: T) => R, fallback: R): (value: T) => R;
1930
+ /**
1931
+ * Executes a function and returns [result, error] tuple
1932
+ */
1933
+ declare function tryCatch<T, R>(fn: (value: T) => R, value: T): [R | undefined, Error | undefined];
1934
+ /**
1935
+ * Async version of tryCatch
1936
+ */
1937
+ declare function tryCatchAsync<T, R>(fn: (value: T) => Promise<R>, value: T): Promise<[R | undefined, Error | undefined]>;
1938
+ /**
1939
+ * Result type for safe operations
1940
+ */
1941
+ type Result<T, E = Error> = {
1942
+ success: true;
1943
+ value: T;
1944
+ } | {
1945
+ success: false;
1946
+ error: E;
1947
+ };
1948
+ /**
1949
+ * Wraps a function to return a Result type
1950
+ */
1951
+ declare function toResult<T, R>(fn: (value: T) => R): (value: T) => Result<R>;
1952
+ /**
1953
+ * Async version of toResult
1954
+ */
1955
+ declare function toResultAsync<T, R>(fn: (value: T) => Promise<R>): (value: T) => Promise<Result<R>>;
1956
+ /**
1957
+ * Guards a predicate function to return false on error instead of throwing
1958
+ */
1959
+ declare function safePredicate<T>(predicate: (value: T, index?: number) => boolean, defaultValue?: boolean): (value: T, index?: number) => boolean;
1960
+ /**
1961
+ * Guards a comparator function to handle errors gracefully
1962
+ */
1963
+ declare function safeComparator<T>(comparator: (a: T, b: T) => number, defaultComparison?: number): (a: T, b: T) => number;
1964
+ /**
1965
+ * Creates an error boundary that catches and logs errors
1966
+ */
1967
+ declare function errorBoundary<T extends any[], R>(fn: (...args: T) => R, options?: {
1968
+ onError?: (error: Error, args: T) => void;
1969
+ rethrow?: boolean;
1970
+ defaultValue?: R;
1971
+ }): (...args: T) => R | undefined;
1972
+
1973
+ /**
1974
+ * Deprecation warnings system for iterflow
1975
+ *
1976
+ * This module provides utilities for marking APIs as deprecated and emitting
1977
+ * warnings to help users migrate away from deprecated functionality.
1978
+ *
1979
+ * @module deprecation
1980
+ */
1981
+ /**
1982
+ * Configuration options for deprecation warnings
1983
+ */
1984
+ interface DeprecationConfig {
1985
+ /** Whether to show deprecation warnings (default: true in development, false in production) */
1986
+ enabled: boolean;
1987
+ /** Whether to show stack traces with warnings (default: false) */
1988
+ showStackTrace: boolean;
1989
+ /** Custom handler for deprecation warnings */
1990
+ handler?: (warning: DeprecationWarning) => void;
1991
+ }
1992
+ /**
1993
+ * Information about a deprecated API
1994
+ */
1995
+ interface DeprecationWarning {
1996
+ /** The deprecated feature name */
1997
+ feature: string;
1998
+ /** Version when it was deprecated */
1999
+ since: string;
2000
+ /** Version when it will be removed (if known) */
2001
+ removeIn?: string;
2002
+ /** Alternative to use instead */
2003
+ alternative?: string;
2004
+ /** Additional message with migration guidance */
2005
+ message?: string;
2006
+ /** Stack trace (if enabled) */
2007
+ stack?: string;
2008
+ }
2009
+ /**
2010
+ * Configure the deprecation warning system
2011
+ *
2012
+ * @param options - Configuration options to update
2013
+ * @example
2014
+ * ```typescript
2015
+ * // Disable all deprecation warnings
2016
+ * configureDeprecation({ enabled: false });
2017
+ *
2018
+ * // Enable stack traces
2019
+ * configureDeprecation({ showStackTrace: true });
2020
+ *
2021
+ * // Use custom handler
2022
+ * configureDeprecation({
2023
+ * handler: (warning) => {
2024
+ * logger.warn(`Deprecated: ${warning.feature}`, warning);
2025
+ * }
2026
+ * });
2027
+ * ```
2028
+ */
2029
+ declare function configureDeprecation(options: Partial<DeprecationConfig>): void;
2030
+ /**
2031
+ * Get current deprecation configuration
2032
+ *
2033
+ * @returns Current deprecation configuration
2034
+ */
2035
+ declare function getDeprecationConfig(): Readonly<DeprecationConfig>;
2036
+ /**
2037
+ * Clear the set of warned features (mainly for testing)
2038
+ */
2039
+ declare function clearDeprecationWarnings(): void;
2040
+ /**
2041
+ * Mark a feature as deprecated and emit a warning when called
2042
+ *
2043
+ * @param options - Deprecation warning details
2044
+ * @example
2045
+ * ```typescript
2046
+ * // In your code
2047
+ * function oldMethod() {
2048
+ * deprecate({
2049
+ * feature: 'oldMethod()',
2050
+ * since: '0.9.0',
2051
+ * removeIn: '2.0.0',
2052
+ * alternative: 'newMethod()',
2053
+ * message: 'See migration guide: https://...'
2054
+ * });
2055
+ *
2056
+ * // ... implementation
2057
+ * }
2058
+ * ```
2059
+ */
2060
+ declare function deprecate(options: Omit<DeprecationWarning, "stack">): void;
2061
+ /**
2062
+ * Decorator to mark a method or function as deprecated
2063
+ *
2064
+ * @param options - Deprecation warning details
2065
+ * @returns Decorator function
2066
+ * @example
2067
+ * ```typescript
2068
+ * class MyClass {
2069
+ * @deprecated({
2070
+ * feature: 'MyClass.oldMethod',
2071
+ * since: '0.9.0',
2072
+ * alternative: 'MyClass.newMethod'
2073
+ * })
2074
+ * oldMethod() {
2075
+ * // implementation
2076
+ * }
2077
+ * }
2078
+ * ```
2079
+ */
2080
+ declare function deprecated(options: Omit<DeprecationWarning, "stack" | "feature">): <T extends Function>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
2081
+ /**
2082
+ * Create a wrapper function that marks the original function as deprecated
2083
+ *
2084
+ * @param fn - The function to wrap
2085
+ * @param options - Deprecation warning details
2086
+ * @returns Wrapped function that emits deprecation warning
2087
+ * @example
2088
+ * ```typescript
2089
+ * const oldFunction = deprecatedFunction(
2090
+ * (x: number) => x * 2,
2091
+ * {
2092
+ * feature: 'oldFunction',
2093
+ * since: '0.9.0',
2094
+ * alternative: 'newFunction'
2095
+ * }
2096
+ * );
2097
+ * ```
2098
+ */
2099
+ declare function deprecatedFunction<T extends (...args: any[]) => any>(fn: T, options: Omit<DeprecationWarning, "stack">): T;
2100
+ /**
2101
+ * Check if a feature has been marked as deprecated (for testing)
2102
+ *
2103
+ * @param feature - The feature name to check
2104
+ * @returns True if the feature has been warned about
2105
+ */
2106
+ declare function hasDeprecationWarning(feature: string): boolean;
2107
+
2108
+ /**
2109
+ * Creates an iterflow instance from an iterable.
2110
+ * This is the main entry point for working with iterables in a fluent API style.
2111
+ *
2112
+ * @template T The type of elements in the iterable
2113
+ * @param source - The iterable to wrap
2114
+ * @returns A new iterflow instance
2115
+ * @example
2116
+ * ```typescript
2117
+ * iter([1, 2, 3, 4, 5])
2118
+ * .filter(x => x % 2 === 0)
2119
+ * .map(x => x * 2)
2120
+ * .toArray(); // [4, 8]
2121
+ * ```
2122
+ */
2123
+ declare function iter<T>(source: Iterable<T>): iterflow<T>;
2124
+ declare namespace iter {
2125
+ /**
2126
+ * Combines two iterables into an iterator of tuples.
2127
+ * Stops when the shorter iterable is exhausted.
2128
+ *
2129
+ * @template T The type of elements in the first iterable
2130
+ * @template U The type of elements in the second iterable
2131
+ * @param iter1 - The first iterable
2132
+ * @param iter2 - The second iterable
2133
+ * @returns A new iterflow of tuples pairing elements from both iterables
2134
+ * @example
2135
+ * ```typescript
2136
+ * iter.zip([1, 2, 3], ['a', 'b', 'c']).toArray();
2137
+ * // [[1, 'a'], [2, 'b'], [3, 'c']]
2138
+ * ```
2139
+ */
2140
+ function zip<T, U>(iter1: Iterable<T>, iter2: Iterable<U>): iterflow<[T, U]>;
2141
+ /**
2142
+ * Combines two iterables using a combining function.
2143
+ * Stops when the shorter iterable is exhausted.
2144
+ *
2145
+ * @template T The type of elements in the first iterable
2146
+ * @template U The type of elements in the second iterable
2147
+ * @template R The type of the result
2148
+ * @param iter1 - The first iterable
2149
+ * @param iter2 - The second iterable
2150
+ * @param fn - Function to combine elements from both iterables
2151
+ * @returns A new iterflow with combined results
2152
+ * @example
2153
+ * ```typescript
2154
+ * iter.zipWith([1, 2, 3], [10, 20, 30], (a, b) => a + b).toArray();
2155
+ * // [11, 22, 33]
2156
+ * ```
2157
+ */
2158
+ function zipWith<T, U, R>(iter1: Iterable<T>, iter2: Iterable<U>, fn: (a: T, b: U) => R): iterflow<R>;
2159
+ /**
2160
+ * Generates a sequence of numbers.
2161
+ * Supports three call signatures:
2162
+ * - range(stop): generates [0, stop) with step 1
2163
+ * - range(start, stop): generates [start, stop) with step 1
2164
+ * - range(start, stop, step): generates [start, stop) with custom step
2165
+ *
2166
+ * @param stop - The end value (exclusive) when called with one argument
2167
+ * @returns A new iterflow of numbers
2168
+ * @throws {Error} If step is zero
2169
+ * @example
2170
+ * ```typescript
2171
+ * iter.range(5).toArray(); // [0, 1, 2, 3, 4]
2172
+ * iter.range(2, 5).toArray(); // [2, 3, 4]
2173
+ * iter.range(0, 10, 2).toArray(); // [0, 2, 4, 6, 8]
2174
+ * iter.range(5, 0, -1).toArray(); // [5, 4, 3, 2, 1]
2175
+ * ```
2176
+ */
2177
+ function range(stop: number): iterflow<number>;
2178
+ /**
2179
+ * Generates a sequence of numbers from start to stop (exclusive).
2180
+ *
2181
+ * @param start - The starting value (inclusive)
2182
+ * @param stop - The end value (exclusive)
2183
+ * @returns A new iterflow of numbers
2184
+ */
2185
+ function range(start: number, stop: number): iterflow<number>;
2186
+ /**
2187
+ * Generates a sequence of numbers from start to stop (exclusive) with a custom step.
2188
+ *
2189
+ * @param start - The starting value (inclusive)
2190
+ * @param stop - The end value (exclusive)
2191
+ * @param step - The increment between values
2192
+ * @returns A new iterflow of numbers
2193
+ */
2194
+ function range(start: number, stop: number, step: number): iterflow<number>;
2195
+ /**
2196
+ * Repeats a value a specified number of times, or infinitely.
2197
+ * If times is not specified, creates an infinite iterator.
2198
+ *
2199
+ * @template T The type of the value to repeat
2200
+ * @param value - The value to repeat
2201
+ * @param times - Optional number of times to repeat (infinite if omitted)
2202
+ * @returns A new iterflow repeating the value
2203
+ * @example
2204
+ * ```typescript
2205
+ * iter.repeat('x', 3).toArray(); // ['x', 'x', 'x']
2206
+ * iter.repeat(0, 5).toArray(); // [0, 0, 0, 0, 0]
2207
+ * iter.repeat(1).take(3).toArray(); // [1, 1, 1] (infinite, limited by take)
2208
+ * ```
2209
+ */
2210
+ function repeat<T>(value: T, times?: number): iterflow<T>;
2211
+ /**
2212
+ * Alternates elements from multiple iterables in a round-robin fashion.
2213
+ * Continues until all iterables are exhausted.
2214
+ *
2215
+ * @template T The type of elements in all iterables
2216
+ * @param iterables - Variable number of iterables to interleave
2217
+ * @returns A new iterflow with elements from all iterables interleaved
2218
+ * @example
2219
+ * ```typescript
2220
+ * iter.interleave([1, 2, 3], [4, 5, 6]).toArray();
2221
+ * // [1, 4, 2, 5, 3, 6]
2222
+ * iter.interleave([1, 2], [3, 4, 5], [6]).toArray();
2223
+ * // [1, 3, 6, 2, 4, 5]
2224
+ * ```
2225
+ */
2226
+ function interleave<T>(...iterables: Iterable<T>[]): iterflow<T>;
2227
+ /**
2228
+ * Merges multiple sorted iterables into a single sorted iterator.
2229
+ * Assumes input iterables are already sorted in ascending order.
2230
+ * Uses a custom comparator if provided, otherwise uses default < comparison.
2231
+ *
2232
+ * @template T The type of elements in all iterables
2233
+ * @param iterables - Variable number of sorted iterables to merge
2234
+ * @param compareFn - Optional comparison function (returns negative if a < b, positive if a > b, 0 if equal)
2235
+ * @returns A new iterflow with all elements merged in sorted order
2236
+ * @example
2237
+ * ```typescript
2238
+ * iter.merge([1, 3, 5], [2, 4, 6]).toArray();
2239
+ * // [1, 2, 3, 4, 5, 6]
2240
+ * iter.merge([1, 5, 9], [2, 6, 10], [3, 7, 11]).toArray();
2241
+ * // [1, 2, 3, 5, 6, 7, 9, 10, 11]
2242
+ * ```
2243
+ */
2244
+ function merge<T>(...iterables: Iterable<T>[]): iterflow<T>;
2245
+ function merge<T>(compareFn: (a: T, b: T) => number, ...iterables: Iterable<T>[]): iterflow<T>;
2246
+ /**
2247
+ * Chains multiple iterables sequentially, one after another.
2248
+ * Yields all elements from the first iterable, then all from the second, etc.
2249
+ *
2250
+ * @template T The type of elements in all iterables
2251
+ * @param iterables - Variable number of iterables to chain
2252
+ * @returns A new iterflow with all elements chained sequentially
2253
+ * @example
2254
+ * ```typescript
2255
+ * iter.chain([1, 2], [3, 4], [5, 6]).toArray();
2256
+ * // [1, 2, 3, 4, 5, 6]
2257
+ * iter.chain([1], [2, 3], [], [4, 5, 6]).toArray();
2258
+ * // [1, 2, 3, 4, 5, 6]
2259
+ * ```
2260
+ */
2261
+ function chain<T>(...iterables: Iterable<T>[]): iterflow<T>;
2262
+ }
2263
+
2264
+ export { Asynciterflow, type DebugConfig, type DeprecationConfig, type DeprecationWarning, EmptySequenceError, type ErrorHandler, IndexOutOfBoundsError, OperationError, type Result, type RetryOptions, type TraceEntry, TypeConversionError, ValidationError, addTrace, asyncIter, clearDeprecationWarnings, clearTraces, configureDeprecation, deprecate, deprecated, deprecatedFunction, disableDebug, enableDebug, errorBoundary, getDebugConfig, getDeprecationConfig, getTraceSummary, getTraces, getTracesForOperation, hasDeprecationWarning, isDebugEnabled, iter, iterflow, iterflowError, safeComparator, safePredicate, toInteger, toNumber, toResult, toResultAsync, traceOperation, traceOperationAsync, tryCatch, tryCatchAsync, tryOr, validateComparator, validateFiniteNumber, validateFunction, validateIndex, validateIterable, validateNonEmpty, validateNonNegativeInteger, validateNonZero, validatePositiveInteger, validateRange, withDefault, withErrorRecovery, withRetry, withRetryAsync };