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,1187 @@
1
+ /**
2
+ * Type representing a function that transforms an iterable.
3
+ * Used for composing transformations in a type-safe way.
4
+ *
5
+ * @template T The input element type
6
+ * @template U The output element type
7
+ */
8
+ type IterableTransformer<T, U> = (iterable: Iterable<T>) => IterableIterator<U>;
9
+ /**
10
+ * Type representing a terminal operation that produces a final result.
11
+ *
12
+ * @template T The input element type
13
+ * @template R The result type
14
+ */
15
+ type TerminalOperation<T, R> = (iterable: Iterable<T>) => R;
16
+ /**
17
+ * Composes functions from left to right (Unix pipe style).
18
+ * Each function takes an iterable and returns an iterable, except the last
19
+ * function which can return any type.
20
+ *
21
+ * The pipe flows data from left to right:
22
+ * pipe(f, g, h)(x) === h(g(f(x)))
23
+ *
24
+ * @param fns - Functions to compose from left to right
25
+ * @returns A function that applies all transformations in sequence
26
+ * @example
27
+ * ```typescript
28
+ * import { pipe, map, filter, toArray } from 'iterflow/fn';
29
+ *
30
+ * const process = pipe(
31
+ * map((x: number) => x * 2),
32
+ * filter((x: number) => x > 5),
33
+ * toArray
34
+ * );
35
+ *
36
+ * process([1, 2, 3, 4, 5]); // [6, 8, 10]
37
+ * ```
38
+ */
39
+ declare function pipe<A, B>(fn1: (input: A) => B): (input: A) => B;
40
+ declare function pipe<A, B, C>(fn1: (input: A) => B, fn2: (input: B) => C): (input: A) => C;
41
+ declare function pipe<A, B, C, D>(fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D): (input: A) => D;
42
+ declare function pipe<A, B, C, D, E>(fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E): (input: A) => E;
43
+ declare function pipe<A, B, C, D, E, F>(fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F): (input: A) => F;
44
+ declare function pipe<A, B, C, D, E, F, G>(fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G): (input: A) => G;
45
+ declare function pipe<A, B, C, D, E, F, G, H>(fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H): (input: A) => H;
46
+ declare function pipe<A, B, C, D, E, F, G, H, I>(fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I): (input: A) => I;
47
+ declare function pipe<A, B, C, D, E, F, G, H, I, J>(fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J): (input: A) => J;
48
+ declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(fn1: (input: A) => B, fn2: (input: B) => C, fn3: (input: C) => D, fn4: (input: D) => E, fn5: (input: E) => F, fn6: (input: F) => G, fn7: (input: G) => H, fn8: (input: H) => I, fn9: (input: I) => J, fn10: (input: J) => K): (input: A) => K;
49
+ /**
50
+ * Composes functions from right to left (traditional mathematical composition).
51
+ * Each function takes an iterable and returns an iterable, except the last
52
+ * function which can return any type.
53
+ *
54
+ * The composition flows from right to left:
55
+ * compose(h, g, f)(x) === h(g(f(x)))
56
+ *
57
+ * @param fns - Functions to compose from right to left
58
+ * @returns A function that applies all transformations in sequence
59
+ * @example
60
+ * ```typescript
61
+ * import { compose, map, filter, toArray } from 'iterflow/fn';
62
+ *
63
+ * const process = compose(
64
+ * toArray,
65
+ * filter((x: number) => x > 5),
66
+ * map((x: number) => x * 2)
67
+ * );
68
+ *
69
+ * process([1, 2, 3, 4, 5]); // [6, 8, 10]
70
+ * ```
71
+ */
72
+ declare function compose<A, B>(fn1: (input: A) => B): (input: A) => B;
73
+ declare function compose<A, B, C>(fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => C;
74
+ declare function compose<A, B, C, D>(fn3: (input: C) => D, fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => D;
75
+ declare function compose<A, B, C, D, E>(fn4: (input: D) => E, fn3: (input: C) => D, fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => E;
76
+ declare function compose<A, B, C, D, E, F>(fn5: (input: E) => F, fn4: (input: D) => E, fn3: (input: C) => D, fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => F;
77
+ declare function compose<A, B, C, D, E, F, G>(fn6: (input: F) => G, fn5: (input: E) => F, fn4: (input: D) => E, fn3: (input: C) => D, fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => G;
78
+ declare function compose<A, B, C, D, E, F, G, H>(fn7: (input: G) => H, fn6: (input: F) => G, fn5: (input: E) => F, fn4: (input: D) => E, fn3: (input: C) => D, fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => H;
79
+ declare function compose<A, B, C, D, E, F, G, H, I>(fn8: (input: H) => I, fn7: (input: G) => H, fn6: (input: F) => G, fn5: (input: E) => F, fn4: (input: D) => E, fn3: (input: C) => D, fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => I;
80
+ declare function compose<A, B, C, D, E, F, G, H, I, J>(fn9: (input: I) => J, fn8: (input: H) => I, fn7: (input: G) => H, fn6: (input: F) => G, fn5: (input: E) => F, fn4: (input: D) => E, fn3: (input: C) => D, fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => J;
81
+ declare function compose<A, B, C, D, E, F, G, H, I, J, K>(fn10: (input: J) => K, fn9: (input: I) => J, fn8: (input: H) => I, fn7: (input: G) => H, fn6: (input: F) => G, fn5: (input: E) => F, fn4: (input: D) => E, fn3: (input: C) => D, fn2: (input: B) => C, fn1: (input: A) => B): (input: A) => K;
82
+ /**
83
+ * Helper function to create custom iterable operations that follow the
84
+ * iterflow functional API pattern.
85
+ *
86
+ * Creates a curried function that takes configuration parameters and returns
87
+ * a function that transforms an iterable. The transformation uses a generator
88
+ * function for lazy evaluation.
89
+ *
90
+ * @template TConfig The type of configuration parameters
91
+ * @template TInput The type of input elements
92
+ * @template TOutput The type of output elements
93
+ * @param name - Name of the operation (for debugging)
94
+ * @param generator - Generator function that performs the transformation
95
+ * @returns A curried function following the iterflow pattern
96
+ * @example
97
+ * ```typescript
98
+ * import { createOperation } from 'iterflow/fn';
99
+ *
100
+ * // Create a custom operation that multiplies by a factor
101
+ * const multiplyBy = createOperation(
102
+ * 'multiplyBy',
103
+ * function* (iterable: Iterable<number>, factor: number) {
104
+ * for (const value of iterable) {
105
+ * yield value * factor;
106
+ * }
107
+ * }
108
+ * );
109
+ *
110
+ * // Use it in a pipeline
111
+ * const double = multiplyBy(2);
112
+ * Array.from(double([1, 2, 3])); // [2, 4, 6]
113
+ *
114
+ * // Create a custom filtering operation
115
+ * const between = createOperation(
116
+ * 'between',
117
+ * function* (iterable: Iterable<number>, min: number, max: number) {
118
+ * for (const value of iterable) {
119
+ * if (value >= min && value <= max) {
120
+ * yield value;
121
+ * }
122
+ * }
123
+ * }
124
+ * );
125
+ *
126
+ * const between5And10 = between(5, 10);
127
+ * Array.from(between5And10([1, 6, 3, 8, 12, 4])); // [6, 8]
128
+ * ```
129
+ */
130
+ declare function createOperation<TInput, TOutput>(name: string, generator: (iterable: Iterable<TInput>) => Generator<TOutput>): (iterable: Iterable<TInput>) => IterableIterator<TOutput>;
131
+ declare function createOperation<TConfig, TInput, TOutput>(name: string, generator: (iterable: Iterable<TInput>, config: TConfig) => Generator<TOutput>): (config: TConfig) => (iterable: Iterable<TInput>) => IterableIterator<TOutput>;
132
+ declare function createOperation<TConfig1, TConfig2, TInput, TOutput>(name: string, generator: (iterable: Iterable<TInput>, config1: TConfig1, config2: TConfig2) => Generator<TOutput>): (config1: TConfig1, config2: TConfig2) => (iterable: Iterable<TInput>) => IterableIterator<TOutput>;
133
+ declare function createOperation<TConfig1, TConfig2, TConfig3, TInput, TOutput>(name: string, generator: (iterable: Iterable<TInput>, config1: TConfig1, config2: TConfig2, config3: TConfig3) => Generator<TOutput>): (config1: TConfig1, config2: TConfig2, config3: TConfig3) => (iterable: Iterable<TInput>) => IterableIterator<TOutput>;
134
+ declare function createOperation<TInput, TOutput>(name: string, generator: (iterable: Iterable<TInput>, ...configs: any[]) => Generator<TOutput>): any;
135
+ /**
136
+ * Type representing a transducer - a composable algorithmic transformation.
137
+ * Transducers are independent of the context of their input and output sources.
138
+ *
139
+ * @template TInput The input element type
140
+ * @template TOutput The output element type
141
+ */
142
+ type Transducer<TInput, TOutput> = <TResult>(reducer: Reducer<TOutput, TResult>) => Reducer<TInput, TResult>;
143
+ /**
144
+ * Type representing a reducer function that combines values into an accumulator.
145
+ *
146
+ * @template T The type of values being reduced
147
+ * @template TResult The type of the accumulator
148
+ */
149
+ type Reducer<T, TResult> = (accumulator: TResult, value: T) => TResult;
150
+ /**
151
+ * Creates a transducer from a map function.
152
+ * Transducers enable efficient composition of transformations without
153
+ * creating intermediate iterables.
154
+ *
155
+ * @template TInput The input element type
156
+ * @template TOutput The output element type
157
+ * @param fn - Function to transform each element
158
+ * @returns A transducer that applies the transformation
159
+ * @example
160
+ * ```typescript
161
+ * import { mapTransducer, transduce } from 'iterflow/fn';
162
+ *
163
+ * const xf = mapTransducer((x: number) => x * 2);
164
+ * const result = transduce(
165
+ * xf,
166
+ * (acc: number[], x: number) => [...acc, x],
167
+ * [],
168
+ * [1, 2, 3]
169
+ * );
170
+ * // [2, 4, 6]
171
+ * ```
172
+ */
173
+ declare function mapTransducer<TInput, TOutput>(fn: (value: TInput) => TOutput): Transducer<TInput, TOutput>;
174
+ /**
175
+ * Creates a transducer from a filter predicate.
176
+ * Transducers enable efficient composition of transformations without
177
+ * creating intermediate iterables.
178
+ *
179
+ * @template T The element type
180
+ * @param predicate - Function to test each element
181
+ * @returns A transducer that filters elements
182
+ * @example
183
+ * ```typescript
184
+ * import { filterTransducer, transduce } from 'iterflow/fn';
185
+ *
186
+ * const xf = filterTransducer((x: number) => x % 2 === 0);
187
+ * const result = transduce(
188
+ * xf,
189
+ * (acc: number[], x: number) => [...acc, x],
190
+ * [],
191
+ * [1, 2, 3, 4, 5]
192
+ * );
193
+ * // [2, 4]
194
+ * ```
195
+ */
196
+ declare function filterTransducer<T>(predicate: (value: T) => boolean): Transducer<T, T>;
197
+ /**
198
+ * Creates a transducer from a take operation.
199
+ * Transducers enable efficient composition of transformations without
200
+ * creating intermediate iterables.
201
+ *
202
+ * Note: This transducer requires special handling in transduce() to support
203
+ * early termination. Use the '@@transducer/reduced' protocol.
204
+ *
205
+ * @template T The element type
206
+ * @param n - Number of elements to take
207
+ * @returns A transducer that takes the first n elements
208
+ * @example
209
+ * ```typescript
210
+ * import { takeTransducer, transduce } from 'iterflow/fn';
211
+ *
212
+ * const xf = takeTransducer(3);
213
+ * const result = transduce(
214
+ * xf,
215
+ * (acc: number[], x: number) => [...acc, x],
216
+ * [],
217
+ * [1, 2, 3, 4, 5]
218
+ * );
219
+ * // [1, 2, 3]
220
+ * ```
221
+ */
222
+ declare function takeTransducer<T>(n: number): Transducer<T, T>;
223
+ /**
224
+ * Composes multiple transducers into a single transducer.
225
+ * Composition happens from right to left (like compose).
226
+ *
227
+ * @param transducers - Transducers to compose
228
+ * @returns A composed transducer
229
+ * @example
230
+ * ```typescript
231
+ * import { composeTransducers, mapTransducer, filterTransducer, transduce } from 'iterflow/fn';
232
+ *
233
+ * const xf = composeTransducers(
234
+ * filterTransducer((x: number) => x > 2),
235
+ * mapTransducer((x: number) => x * 2)
236
+ * );
237
+ *
238
+ * const result = transduce(
239
+ * xf,
240
+ * (acc: number[], x: number) => [...acc, x],
241
+ * [],
242
+ * [1, 2, 3, 4, 5]
243
+ * );
244
+ * // [6, 8, 10]
245
+ * ```
246
+ */
247
+ declare function composeTransducers<A, B>(xf1: Transducer<A, B>): Transducer<A, B>;
248
+ declare function composeTransducers<A, B, C>(xf2: Transducer<B, C>, xf1: Transducer<A, B>): Transducer<A, C>;
249
+ declare function composeTransducers<A, B, C, D>(xf3: Transducer<C, D>, xf2: Transducer<B, C>, xf1: Transducer<A, B>): Transducer<A, D>;
250
+ declare function composeTransducers<A, B, C, D, E>(xf4: Transducer<D, E>, xf3: Transducer<C, D>, xf2: Transducer<B, C>, xf1: Transducer<A, B>): Transducer<A, E>;
251
+ /**
252
+ * Symbol used to mark a reduced value (for early termination in transducers).
253
+ */
254
+ declare const REDUCED: unique symbol;
255
+ /**
256
+ * Interface for a reduced value (supports early termination).
257
+ */
258
+ interface Reduced<T> {
259
+ [REDUCED]: true;
260
+ value: T;
261
+ }
262
+ /**
263
+ * Marks a value as reduced (for early termination in transducers).
264
+ *
265
+ * @template T The value type
266
+ * @param value - The value to mark as reduced
267
+ * @returns A reduced value
268
+ */
269
+ declare function reduced<T>(value: T): Reduced<T>;
270
+ /**
271
+ * Checks if a value is reduced.
272
+ *
273
+ * @template T The value type
274
+ * @param value - The value to check
275
+ * @returns true if the value is reduced
276
+ */
277
+ declare function isReduced<T>(value: any): value is Reduced<T>;
278
+ /**
279
+ * Applies a transducer to an iterable and reduces it to a final value.
280
+ * This is the main entry point for using transducers.
281
+ *
282
+ * @template TInput The input element type
283
+ * @template TOutput The output element type (after transducer transformation)
284
+ * @template TResult The final result type
285
+ * @param transducer - The transducer to apply
286
+ * @param reducer - The reducer function to combine values
287
+ * @param initial - The initial accumulator value
288
+ * @param iterable - The iterable to process
289
+ * @returns The final reduced value
290
+ * @example
291
+ * ```typescript
292
+ * import { transduce, composeTransducers, mapTransducer, filterTransducer } from 'iterflow/fn';
293
+ *
294
+ * const xf = composeTransducers(
295
+ * filterTransducer((x: number) => x % 2 === 0),
296
+ * mapTransducer((x: number) => x * 2)
297
+ * );
298
+ *
299
+ * const sum = transduce(
300
+ * xf,
301
+ * (acc: number, x: number) => acc + x,
302
+ * 0,
303
+ * [1, 2, 3, 4, 5]
304
+ * );
305
+ * // 12 (2*2 + 4*2)
306
+ *
307
+ * const toArray = transduce(
308
+ * xf,
309
+ * (acc: number[], x: number) => [...acc, x],
310
+ * [],
311
+ * [1, 2, 3, 4, 5]
312
+ * );
313
+ * // [4, 8]
314
+ * ```
315
+ */
316
+ declare function transduce<TInput, TOutput, TResult>(transducer: Transducer<TInput, TOutput>, reducer: Reducer<TOutput, TResult>, initial: TResult, iterable: Iterable<TInput>): TResult;
317
+ /**
318
+ * Converts a transducer into an iterable transformer.
319
+ * This allows transducers to be used in pipe() and compose() with other
320
+ * iterable operations.
321
+ *
322
+ * @template TInput The input element type
323
+ * @template TOutput The output element type
324
+ * @param transducer - The transducer to convert
325
+ * @returns An iterable transformer function
326
+ * @example
327
+ * ```typescript
328
+ * import { pipe, transducerToIterator, mapTransducer, filterTransducer, toArray } from 'iterflow/fn';
329
+ *
330
+ * const xf = composeTransducers(
331
+ * filterTransducer((x: number) => x % 2 === 0),
332
+ * mapTransducer((x: number) => x * 2)
333
+ * );
334
+ *
335
+ * const process = pipe(
336
+ * transducerToIterator(xf),
337
+ * toArray
338
+ * );
339
+ *
340
+ * process([1, 2, 3, 4, 5]); // [4, 8]
341
+ * ```
342
+ */
343
+ declare function transducerToIterator<TInput, TOutput>(transducer: Transducer<TInput, TOutput>): (iterable: Iterable<TInput>) => IterableIterator<TOutput>;
344
+
345
+ /**
346
+ * Calculates the sum of all numeric elements in an iterable.
347
+ *
348
+ * @param iterable - The iterable of numbers to sum
349
+ * @returns The sum of all elements
350
+ * @example
351
+ * ```typescript
352
+ * sum([1, 2, 3, 4, 5]); // 15
353
+ * ```
354
+ */
355
+ declare function sum(iterable: Iterable<number>): number;
356
+ /**
357
+ * Calculates the arithmetic mean (average) of all numeric elements.
358
+ *
359
+ * @param iterable - The iterable of numbers
360
+ * @returns The mean value, or undefined if the iterable is empty
361
+ * @example
362
+ * ```typescript
363
+ * mean([1, 2, 3, 4, 5]); // 3
364
+ * mean([]); // undefined
365
+ * ```
366
+ */
367
+ declare function mean(iterable: Iterable<number>): number | undefined;
368
+ /**
369
+ * Finds the minimum value among all numeric elements.
370
+ *
371
+ * @param iterable - The iterable of numbers
372
+ * @returns The minimum value, or undefined if the iterable is empty
373
+ * @example
374
+ * ```typescript
375
+ * min([3, 1, 4, 1, 5]); // 1
376
+ * min([]); // undefined
377
+ * ```
378
+ */
379
+ declare function min(iterable: Iterable<number>): number | undefined;
380
+ /**
381
+ * Finds the maximum value among all numeric elements.
382
+ *
383
+ * @param iterable - The iterable of numbers
384
+ * @returns The maximum value, or undefined if the iterable is empty
385
+ * @example
386
+ * ```typescript
387
+ * max([3, 1, 4, 1, 5]); // 5
388
+ * max([]); // undefined
389
+ * ```
390
+ */
391
+ declare function max(iterable: Iterable<number>): number | undefined;
392
+ /**
393
+ * Counts the total number of elements in an iterable.
394
+ *
395
+ * @template T The type of elements in the iterable
396
+ * @param iterable - The iterable to count
397
+ * @returns The total count of elements
398
+ * @example
399
+ * ```typescript
400
+ * count([1, 2, 3, 4, 5]); // 5
401
+ * count([]); // 0
402
+ * ```
403
+ */
404
+ declare function count<T>(iterable: Iterable<T>): number;
405
+ /**
406
+ * Calculates the median value of all numeric elements.
407
+ * The median is the middle value when elements are sorted.
408
+ *
409
+ * @param iterable - The iterable of numbers
410
+ * @returns The median value, or undefined if the iterable is empty
411
+ * @example
412
+ * ```typescript
413
+ * median([1, 2, 3, 4, 5]); // 3
414
+ * median([1, 2, 3, 4]); // 2.5
415
+ * median([]); // undefined
416
+ * ```
417
+ */
418
+ declare function median(iterable: Iterable<number>): number | undefined;
419
+ /**
420
+ * Calculates the variance of all numeric elements.
421
+ * Variance measures how far each number in the set is from the mean.
422
+ *
423
+ * @param iterable - The iterable of numbers
424
+ * @returns The variance, or undefined if the iterable is empty
425
+ * @example
426
+ * ```typescript
427
+ * variance([1, 2, 3, 4, 5]); // 2
428
+ * variance([]); // undefined
429
+ * ```
430
+ */
431
+ declare function variance(iterable: Iterable<number>): number | undefined;
432
+ /**
433
+ * Calculates the standard deviation of all numeric elements.
434
+ * Standard deviation is the square root of variance and measures dispersion.
435
+ *
436
+ * @param iterable - The iterable of numbers
437
+ * @returns The standard deviation, or undefined if the iterable is empty
438
+ * @example
439
+ * ```typescript
440
+ * stdDev([2, 4, 4, 4, 5, 5, 7, 9]); // ~2
441
+ * stdDev([]); // undefined
442
+ * ```
443
+ */
444
+ declare function stdDev(iterable: Iterable<number>): number | undefined;
445
+ /**
446
+ * Calculates the specified percentile of all numeric elements.
447
+ * Uses linear interpolation between closest ranks.
448
+ *
449
+ * @param iterable - The iterable of numbers
450
+ * @param p - The percentile to calculate (0-100)
451
+ * @returns The percentile value, or undefined if the iterable is empty
452
+ * @throws {Error} If p is not between 0 and 100
453
+ * @example
454
+ * ```typescript
455
+ * percentile([1, 2, 3, 4, 5], 50); // 3 (median)
456
+ * percentile([1, 2, 3, 4, 5], 75); // 4
457
+ * percentile([], 50); // undefined
458
+ * ```
459
+ */
460
+ declare function percentile(iterable: Iterable<number>, p: number): number | undefined;
461
+ /**
462
+ * Finds the most frequent value(s) in the dataset.
463
+ * Returns an array of all values that appear most frequently.
464
+ *
465
+ * @param iterable - The iterable of numbers
466
+ * @returns An array of the most frequent value(s), or undefined if the iterable is empty
467
+ * @example
468
+ * ```typescript
469
+ * mode([1, 2, 2, 3, 3, 3]); // [3]
470
+ * mode([1, 1, 2, 2, 3]); // [1, 2] (bimodal)
471
+ * mode([]); // undefined
472
+ * ```
473
+ */
474
+ declare function mode(iterable: Iterable<number>): number[] | undefined;
475
+ /**
476
+ * Calculates the quartiles (Q1, Q2, Q3) of all numeric elements.
477
+ * Q1 is the 25th percentile, Q2 is the median (50th percentile), Q3 is the 75th percentile.
478
+ *
479
+ * @param iterable - The iterable of numbers
480
+ * @returns An object with Q1, Q2, and Q3 values, or undefined if the iterable is empty
481
+ * @example
482
+ * ```typescript
483
+ * quartiles([1, 2, 3, 4, 5, 6, 7, 8, 9]);
484
+ * // { Q1: 3, Q2: 5, Q3: 7 }
485
+ * quartiles([]); // undefined
486
+ * ```
487
+ */
488
+ declare function quartiles(iterable: Iterable<number>): {
489
+ Q1: number;
490
+ Q2: number;
491
+ Q3: number;
492
+ } | undefined;
493
+ /**
494
+ * Calculates the span (range from minimum to maximum value) of all numeric elements.
495
+ *
496
+ * @param iterable - The iterable of numbers
497
+ * @returns The span (max - min), or undefined if the iterable is empty
498
+ * @example
499
+ * ```typescript
500
+ * span([1, 2, 3, 4, 5]); // 4
501
+ * span([10]); // 0
502
+ * span([]); // undefined
503
+ * ```
504
+ */
505
+ declare function span(iterable: Iterable<number>): number | undefined;
506
+ /**
507
+ * Calculates the product of all numeric elements.
508
+ *
509
+ * @param iterable - The iterable of numbers
510
+ * @returns The product of all elements, or 1 if the iterable is empty
511
+ * @example
512
+ * ```typescript
513
+ * product([1, 2, 3, 4, 5]); // 120
514
+ * product([2, 3, 4]); // 24
515
+ * product([]); // 1
516
+ * ```
517
+ */
518
+ declare function product(iterable: Iterable<number>): number;
519
+ /**
520
+ * Calculates the covariance between two numeric sequences.
521
+ * Covariance measures the joint variability of two random variables.
522
+ *
523
+ * @param iter1 - The first iterable of numbers
524
+ * @param iter2 - The second iterable of numbers
525
+ * @returns The covariance, or undefined if either sequence is empty or sequences have different lengths
526
+ * @example
527
+ * ```typescript
528
+ * covariance([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]); // 4
529
+ * covariance([], [1, 2, 3]); // undefined
530
+ * ```
531
+ */
532
+ declare function covariance(iter1: Iterable<number>, iter2: Iterable<number>): number | undefined;
533
+ /**
534
+ * Calculates the Pearson correlation coefficient between two numeric sequences.
535
+ * Correlation measures the strength and direction of the linear relationship between two variables.
536
+ * Values range from -1 (perfect negative correlation) to 1 (perfect positive correlation).
537
+ *
538
+ * @param iter1 - The first iterable of numbers
539
+ * @param iter2 - The second iterable of numbers
540
+ * @returns The correlation coefficient, or undefined if either sequence is empty or sequences have different lengths
541
+ * @example
542
+ * ```typescript
543
+ * correlation([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]); // 1 (perfect positive correlation)
544
+ * correlation([1, 2, 3], [3, 2, 1]); // -1 (perfect negative correlation)
545
+ * correlation([], [1, 2, 3]); // undefined
546
+ * ```
547
+ */
548
+ declare function correlation(iter1: Iterable<number>, iter2: Iterable<number>): number | undefined;
549
+ /**
550
+ * Creates a curried function that transforms each element using the provided function.
551
+ * Returns a function that takes an iterable and returns an iterable iterator.
552
+ *
553
+ * @template T The type of input elements
554
+ * @template U The type of output elements
555
+ * @param fn - Function to transform each element
556
+ * @returns A function that transforms an iterable
557
+ * @example
558
+ * ```typescript
559
+ * const double = map((x: number) => x * 2);
560
+ * Array.from(double([1, 2, 3])); // [2, 4, 6]
561
+ * ```
562
+ */
563
+ declare function map<T, U>(fn: (value: T) => U): (iterable: Iterable<T>) => IterableIterator<U>;
564
+ /**
565
+ * Creates a curried function that filters elements based on a predicate.
566
+ * Returns a function that takes an iterable and returns an iterable iterator.
567
+ *
568
+ * @template T The type of elements
569
+ * @param predicate - Function to test each element
570
+ * @returns A function that filters an iterable
571
+ * @example
572
+ * ```typescript
573
+ * const evens = filter((x: number) => x % 2 === 0);
574
+ * Array.from(evens([1, 2, 3, 4])); // [2, 4]
575
+ * ```
576
+ */
577
+ declare function filter<T>(predicate: (value: T) => boolean): (iterable: Iterable<T>) => IterableIterator<T>;
578
+ /**
579
+ * Creates a curried function that takes only the first `limit` elements.
580
+ * Returns a function that takes an iterable and returns an iterable iterator.
581
+ *
582
+ * @template T The type of elements
583
+ * @param limit - Maximum number of elements to take
584
+ * @returns A function that takes elements from an iterable
585
+ * @example
586
+ * ```typescript
587
+ * const takeThree = take(3);
588
+ * Array.from(takeThree([1, 2, 3, 4, 5])); // [1, 2, 3]
589
+ * ```
590
+ */
591
+ declare function take<T>(limit: number): (iterable: Iterable<T>) => IterableIterator<T>;
592
+ /**
593
+ * Creates a curried function that skips the first `count` elements.
594
+ * Returns a function that takes an iterable and returns an iterable iterator.
595
+ *
596
+ * @template T The type of elements
597
+ * @param count - Number of elements to skip
598
+ * @returns A function that drops elements from an iterable
599
+ * @example
600
+ * ```typescript
601
+ * const dropTwo = drop(2);
602
+ * Array.from(dropTwo([1, 2, 3, 4, 5])); // [3, 4, 5]
603
+ * ```
604
+ */
605
+ declare function drop<T>(count: number): (iterable: Iterable<T>) => IterableIterator<T>;
606
+ /**
607
+ * Creates a curried function that maps each element to an iterable and flattens the results.
608
+ * Returns a function that takes an iterable and returns an iterable iterator.
609
+ *
610
+ * @template T The type of input elements
611
+ * @template U The type of output elements
612
+ * @param fn - Function that maps each element to an iterable
613
+ * @returns A function that flat maps an iterable
614
+ * @example
615
+ * ```typescript
616
+ * const duplicateEach = flatMap((x: number) => [x, x * 2]);
617
+ * Array.from(duplicateEach([1, 2, 3])); // [1, 2, 2, 4, 3, 6]
618
+ * ```
619
+ */
620
+ declare function flatMap<T, U>(fn: (value: T) => Iterable<U>): (iterable: Iterable<T>) => IterableIterator<U>;
621
+ /**
622
+ * Creates a curried function that concatenates multiple iterables sequentially.
623
+ * Returns a function that takes any number of iterables and yields all elements in order.
624
+ *
625
+ * @template T The type of elements
626
+ * @returns A function that concatenates iterables
627
+ * @example
628
+ * ```typescript
629
+ * const concatAll = concat<number>();
630
+ * Array.from(concatAll([1, 2], [3, 4], [5, 6]));
631
+ * // [1, 2, 3, 4, 5, 6]
632
+ * ```
633
+ */
634
+ declare function concat<T>(): (...iterables: Iterable<T>[]) => IterableIterator<T>;
635
+ /**
636
+ * Creates a curried function that inserts a separator element between each item.
637
+ * Returns a function that takes an iterable and returns an iterable iterator.
638
+ *
639
+ * @template T The type of elements
640
+ * @param separator - The element to insert between items
641
+ * @returns A function that intersperses an iterable
642
+ * @example
643
+ * ```typescript
644
+ * const addCommas = intersperse(',');
645
+ * Array.from(addCommas(['a', 'b', 'c']));
646
+ * // ['a', ',', 'b', ',', 'c']
647
+ * ```
648
+ */
649
+ declare function intersperse<T>(separator: T): (iterable: Iterable<T>) => IterableIterator<T>;
650
+ /**
651
+ * Creates a curried function that emits all intermediate accumulator values.
652
+ * Like reduce but yields each intermediate result.
653
+ *
654
+ * @template T The type of elements in the iterable
655
+ * @template U The type of the accumulated value
656
+ * @param fn - Function to combine the accumulator with each element
657
+ * @param initial - The initial value for the accumulator
658
+ * @returns A function that scans an iterable
659
+ * @example
660
+ * ```typescript
661
+ * const runningSum = scan((acc: number, x: number) => acc + x, 0);
662
+ * Array.from(runningSum([1, 2, 3, 4]));
663
+ * // [0, 1, 3, 6, 10]
664
+ * ```
665
+ */
666
+ declare function scan<T, U>(fn: (accumulator: U, value: T) => U, initial: U): (iterable: Iterable<T>) => IterableIterator<U>;
667
+ /**
668
+ * Creates a curried function that adds index as tuple with each element [index, value].
669
+ * Returns a function that creates tuples pairing each element with its zero-based index.
670
+ *
671
+ * @template T The type of elements
672
+ * @returns A function that enumerates an iterable
673
+ * @example
674
+ * ```typescript
675
+ * const enumerateItems = enumerate<string>();
676
+ * Array.from(enumerateItems(['a', 'b', 'c']));
677
+ * // [[0, 'a'], [1, 'b'], [2, 'c']]
678
+ * ```
679
+ */
680
+ declare function enumerate<T>(): (iterable: Iterable<T>) => IterableIterator<[number, T]>;
681
+ /**
682
+ * Creates a curried function that reverses the iterator order.
683
+ * Returns a function that takes an iterable and returns an iterable iterator.
684
+ * Warning: This operation buffers all elements in memory and may cause
685
+ * performance issues with large iterables.
686
+ *
687
+ * @template T The type of elements
688
+ * @returns A function that reverses an iterable
689
+ * @example
690
+ * ```typescript
691
+ * const reverseItems = reverse<number>();
692
+ * Array.from(reverseItems([1, 2, 3, 4, 5]));
693
+ * // [5, 4, 3, 2, 1]
694
+ * ```
695
+ */
696
+ declare function reverse<T>(): (iterable: Iterable<T>) => IterableIterator<T>;
697
+ /**
698
+ * Sorts elements using default comparison.
699
+ * Numbers are sorted numerically, strings lexicographically.
700
+ * Note: This operation requires buffering all elements in memory.
701
+ *
702
+ * @param iterable - The iterable to sort
703
+ * @returns An iterable iterator with elements sorted
704
+ * @example
705
+ * ```typescript
706
+ * Array.from(sort([3, 1, 4, 1, 5]));
707
+ * // [1, 1, 3, 4, 5]
708
+ * Array.from(sort(['c', 'a', 'b']));
709
+ * // ['a', 'b', 'c']
710
+ * ```
711
+ */
712
+ declare function sort(iterable: Iterable<number | string>): IterableIterator<number | string>;
713
+ /**
714
+ * Creates a curried function that sorts elements using a custom comparison function.
715
+ * Returns a function that takes an iterable and returns an iterable iterator.
716
+ * Note: This operation requires buffering all elements in memory.
717
+ *
718
+ * @template T The type of elements
719
+ * @param compareFn - Function that compares two elements
720
+ * @returns A function that sorts an iterable
721
+ * @example
722
+ * ```typescript
723
+ * const sortAsc = sortBy((a: number, b: number) => a - b);
724
+ * Array.from(sortAsc([3, 1, 4, 1, 5]));
725
+ * // [1, 1, 3, 4, 5]
726
+ * const sortDesc = sortBy((a: number, b: number) => b - a);
727
+ * Array.from(sortDesc([3, 1, 4, 1, 5]));
728
+ * // [5, 4, 3, 1, 1]
729
+ * ```
730
+ */
731
+ declare function sortBy<T>(compareFn: (a: T, b: T) => number): (iterable: Iterable<T>) => IterableIterator<T>;
732
+ /**
733
+ * Creates a curried function that creates a sliding window of the specified size.
734
+ * Returns a function that takes an iterable and returns an iterable iterator.
735
+ *
736
+ * @template T The type of elements
737
+ * @param size - The size of each window (must be at least 1)
738
+ * @returns A function that creates windows from an iterable
739
+ * @throws {Error} If size is less than 1
740
+ * @example
741
+ * ```typescript
742
+ * const windowThree = window(3);
743
+ * Array.from(windowThree([1, 2, 3, 4, 5]));
744
+ * // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
745
+ * ```
746
+ */
747
+ declare function window<T>(size: number): (iterable: Iterable<T>) => IterableIterator<T[]>;
748
+ /**
749
+ * Creates a curried function that splits elements into chunks of the specified size.
750
+ * Returns a function that takes an iterable and returns an iterable iterator.
751
+ *
752
+ * @template T The type of elements
753
+ * @param size - The size of each chunk (must be at least 1)
754
+ * @returns A function that creates chunks from an iterable
755
+ * @throws {Error} If size is less than 1
756
+ * @example
757
+ * ```typescript
758
+ * const chunkTwo = chunk(2);
759
+ * Array.from(chunkTwo([1, 2, 3, 4, 5]));
760
+ * // [[1, 2], [3, 4], [5]]
761
+ * ```
762
+ */
763
+ declare function chunk<T>(size: number): (iterable: Iterable<T>) => IterableIterator<T[]>;
764
+ /**
765
+ * Creates pairs of consecutive elements from an iterable.
766
+ * Returns an iterable iterator of tuples.
767
+ *
768
+ * @template T The type of elements
769
+ * @param iterable - The iterable to create pairs from
770
+ * @returns An iterable iterator of tuples containing consecutive elements
771
+ * @example
772
+ * ```typescript
773
+ * Array.from(pairwise([1, 2, 3, 4]));
774
+ * // [[1, 2], [2, 3], [3, 4]]
775
+ * ```
776
+ */
777
+ declare function pairwise<T>(iterable: Iterable<T>): IterableIterator<[T, T]>;
778
+ /**
779
+ * Creates a curried function that splits elements into two arrays based on a predicate.
780
+ * Returns a function that takes an iterable and returns a tuple of arrays.
781
+ *
782
+ * @template T The type of elements
783
+ * @param predicate - Function to test each element
784
+ * @returns A function that partitions an iterable
785
+ * @example
786
+ * ```typescript
787
+ * const partitionEvens = partition((x: number) => x % 2 === 0);
788
+ * partitionEvens([1, 2, 3, 4, 5]);
789
+ * // [[2, 4], [1, 3, 5]]
790
+ * ```
791
+ */
792
+ declare function partition<T>(predicate: (value: T) => boolean): (iterable: Iterable<T>) => [T[], T[]];
793
+ /**
794
+ * Creates a curried function that groups elements by a key function into a Map.
795
+ * Returns a function that takes an iterable and returns a Map.
796
+ *
797
+ * @template T The type of elements
798
+ * @template K The type of the grouping key
799
+ * @param keyFn - Function to extract the grouping key from each element
800
+ * @returns A function that groups an iterable
801
+ * @example
802
+ * ```typescript
803
+ * const groupByLength = groupBy((s: string) => s.length);
804
+ * groupByLength(['alice', 'bob', 'charlie', 'dave']);
805
+ * // Map { 3 => ['bob'], 5 => ['alice'], 7 => ['charlie'], 4 => ['dave'] }
806
+ * ```
807
+ */
808
+ declare function groupBy<T, K>(keyFn: (value: T) => K): (iterable: Iterable<T>) => Map<K, T[]>;
809
+ /**
810
+ * Removes duplicate elements from an iterable, keeping only the first occurrence of each.
811
+ * Uses strict equality (===) to compare elements.
812
+ *
813
+ * @template T The type of elements
814
+ * @param iterable - The iterable to deduplicate
815
+ * @returns An iterable iterator with duplicate elements removed
816
+ * @example
817
+ * ```typescript
818
+ * Array.from(distinct([1, 2, 2, 3, 1, 4]));
819
+ * // [1, 2, 3, 4]
820
+ * ```
821
+ */
822
+ declare function distinct<T>(iterable: Iterable<T>): IterableIterator<T>;
823
+ /**
824
+ * Creates a curried function that removes duplicate elements based on a key function.
825
+ * Returns a function that takes an iterable and returns an iterable iterator.
826
+ *
827
+ * @template T The type of elements
828
+ * @template K The type of the key used for comparison
829
+ * @param keyFn - Function to extract the comparison key from each element
830
+ * @returns A function that deduplicates an iterable by key
831
+ * @example
832
+ * ```typescript
833
+ * const users = [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 1, name: 'Charlie'}];
834
+ * const distinctById = distinctBy((u: typeof users[0]) => u.id);
835
+ * Array.from(distinctById(users));
836
+ * // [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}]
837
+ * ```
838
+ */
839
+ declare function distinctBy<T, K>(keyFn: (value: T) => K): (iterable: Iterable<T>) => IterableIterator<T>;
840
+ /**
841
+ * Creates a curried function that executes a side-effect function on each element.
842
+ * Returns a function that takes an iterable and returns an iterable iterator.
843
+ *
844
+ * @template T The type of elements
845
+ * @param fn - Function to execute for each element
846
+ * @returns A function that taps an iterable
847
+ * @example
848
+ * ```typescript
849
+ * const log = tap((x: number) => console.log('Processing:', x));
850
+ * Array.from(log([1, 2, 3])); // logs each value, returns [1, 2, 3]
851
+ * ```
852
+ */
853
+ declare function tap<T>(fn: (value: T) => void): (iterable: Iterable<T>) => IterableIterator<T>;
854
+ /**
855
+ * Creates a curried function that takes elements while the predicate returns true.
856
+ * Returns a function that takes an iterable and returns an iterable iterator.
857
+ *
858
+ * @template T The type of elements
859
+ * @param predicate - Function to test each element
860
+ * @returns A function that takes elements while predicate is true
861
+ * @example
862
+ * ```typescript
863
+ * const takeLessThanFour = takeWhile((x: number) => x < 4);
864
+ * Array.from(takeLessThanFour([1, 2, 3, 4, 1, 2]));
865
+ * // [1, 2, 3]
866
+ * ```
867
+ */
868
+ declare function takeWhile<T>(predicate: (value: T) => boolean): (iterable: Iterable<T>) => IterableIterator<T>;
869
+ /**
870
+ * Creates a curried function that skips elements while the predicate returns true.
871
+ * Returns a function that takes an iterable and returns an iterable iterator.
872
+ *
873
+ * @template T The type of elements
874
+ * @param predicate - Function to test each element
875
+ * @returns A function that drops elements while predicate is true
876
+ * @example
877
+ * ```typescript
878
+ * const dropLessThanThree = dropWhile((x: number) => x < 3);
879
+ * Array.from(dropLessThanThree([1, 2, 3, 4, 1, 2]));
880
+ * // [3, 4, 1, 2]
881
+ * ```
882
+ */
883
+ declare function dropWhile<T>(predicate: (value: T) => boolean): (iterable: Iterable<T>) => IterableIterator<T>;
884
+ /**
885
+ * Collects all elements from an iterable into an array.
886
+ *
887
+ * @template T The type of elements
888
+ * @param iterable - The iterable to convert to an array
889
+ * @returns An array containing all elements
890
+ * @example
891
+ * ```typescript
892
+ * toArray([1, 2, 3]); // [1, 2, 3]
893
+ * ```
894
+ */
895
+ declare function toArray<T>(iterable: Iterable<T>): T[];
896
+ /**
897
+ * Creates a curried function that reduces an iterable to a single value.
898
+ * Returns a function that takes an iterable and returns the reduced value.
899
+ *
900
+ * @template T The type of elements in the iterable
901
+ * @template U The type of the accumulated value
902
+ * @param fn - Function to combine the accumulator with each element
903
+ * @param initial - The initial value for the accumulator
904
+ * @returns A function that reduces an iterable
905
+ * @example
906
+ * ```typescript
907
+ * const sumAll = reduce((acc: number, x: number) => acc + x, 0);
908
+ * sumAll([1, 2, 3, 4]); // 10
909
+ * const concat = reduce((acc: string, x: string) => acc + x, '');
910
+ * concat(['a', 'b', 'c']); // 'abc'
911
+ * ```
912
+ */
913
+ declare function reduce<T, U>(fn: (accumulator: U, value: T) => U, initial: U): (iterable: Iterable<T>) => U;
914
+ /**
915
+ * Creates a curried function that finds the first element matching a predicate.
916
+ * Returns a function that takes an iterable and returns the first matching element or undefined.
917
+ *
918
+ * @template T The type of elements
919
+ * @param predicate - Function to test each element
920
+ * @returns A function that finds an element in an iterable
921
+ * @example
922
+ * ```typescript
923
+ * const findGreaterThanThree = find((x: number) => x > 3);
924
+ * findGreaterThanThree([1, 2, 3, 4, 5]); // 4
925
+ * findGreaterThanThree([1, 2, 3]); // undefined
926
+ * ```
927
+ */
928
+ declare function find<T>(predicate: (value: T) => boolean): (iterable: Iterable<T>) => T | undefined;
929
+ /**
930
+ * Creates a curried function that finds the index of the first element matching a predicate.
931
+ * Returns a function that takes an iterable and returns the index or -1.
932
+ *
933
+ * @template T The type of elements
934
+ * @param predicate - Function to test each element
935
+ * @returns A function that finds an index in an iterable
936
+ * @example
937
+ * ```typescript
938
+ * const findIndexGreaterThanThree = findIndex((x: number) => x > 3);
939
+ * findIndexGreaterThanThree([1, 2, 3, 4, 5]); // 3
940
+ * findIndexGreaterThanThree([1, 2, 3]); // -1
941
+ * ```
942
+ */
943
+ declare function findIndex<T>(predicate: (value: T) => boolean): (iterable: Iterable<T>) => number;
944
+ /**
945
+ * Creates a curried function that tests if any element matches a predicate.
946
+ * Returns a function that takes an iterable and returns a boolean.
947
+ *
948
+ * @template T The type of elements
949
+ * @param predicate - Function to test each element
950
+ * @returns A function that tests an iterable
951
+ * @example
952
+ * ```typescript
953
+ * const hasGreaterThanThree = some((x: number) => x > 3);
954
+ * hasGreaterThanThree([1, 2, 3, 4, 5]); // true
955
+ * hasGreaterThanThree([1, 2, 3]); // false
956
+ * ```
957
+ */
958
+ declare function some<T>(predicate: (value: T) => boolean): (iterable: Iterable<T>) => boolean;
959
+ /**
960
+ * Creates a curried function that tests if all elements match a predicate.
961
+ * Returns a function that takes an iterable and returns a boolean.
962
+ *
963
+ * @template T The type of elements
964
+ * @param predicate - Function to test each element
965
+ * @returns A function that tests an iterable
966
+ * @example
967
+ * ```typescript
968
+ * const allEven = every((x: number) => x % 2 === 0);
969
+ * allEven([2, 4, 6]); // true
970
+ * allEven([1, 2, 3]); // false
971
+ * ```
972
+ */
973
+ declare function every<T>(predicate: (value: T) => boolean): (iterable: Iterable<T>) => boolean;
974
+ /**
975
+ * Gets the first element from an iterable.
976
+ *
977
+ * @template T The type of elements
978
+ * @param iterable - The iterable to get the first element from
979
+ * @param defaultValue - Optional default value to return if iterable is empty
980
+ * @returns The first element, the default value, or undefined if empty and no default
981
+ * @example
982
+ * ```typescript
983
+ * first([1, 2, 3]); // 1
984
+ * first([]); // undefined
985
+ * first([], 0); // 0
986
+ * ```
987
+ */
988
+ declare function first<T>(iterable: Iterable<T>, defaultValue?: T): T | undefined;
989
+ /**
990
+ * Gets the last element from an iterable.
991
+ *
992
+ * @template T The type of elements
993
+ * @param iterable - The iterable to get the last element from
994
+ * @param defaultValue - Optional default value to return if iterable is empty
995
+ * @returns The last element, the default value, or undefined if empty and no default
996
+ * @example
997
+ * ```typescript
998
+ * last([1, 2, 3]); // 3
999
+ * last([]); // undefined
1000
+ * last([], 0); // 0
1001
+ * ```
1002
+ */
1003
+ declare function last<T>(iterable: Iterable<T>, defaultValue?: T): T | undefined;
1004
+ /**
1005
+ * Creates a curried function that gets the element at a specified index.
1006
+ * Returns a function that takes an iterable and returns the element or undefined.
1007
+ *
1008
+ * @template T The type of elements
1009
+ * @param index - Zero-based index of the element to retrieve
1010
+ * @returns A function that gets an element from an iterable
1011
+ * @example
1012
+ * ```typescript
1013
+ * const getSecond = nth(2);
1014
+ * getSecond([1, 2, 3, 4, 5]); // 3
1015
+ * getSecond([1, 2]); // undefined
1016
+ * nth(-1)([1, 2, 3]); // undefined
1017
+ * ```
1018
+ */
1019
+ declare function nth<T>(index: number): (iterable: Iterable<T>) => T | undefined;
1020
+ /**
1021
+ * Checks if an iterable is empty.
1022
+ *
1023
+ * @template T The type of elements
1024
+ * @param iterable - The iterable to check
1025
+ * @returns true if the iterable has no elements, false otherwise
1026
+ * @example
1027
+ * ```typescript
1028
+ * isEmpty([]); // true
1029
+ * isEmpty([1, 2, 3]); // false
1030
+ * ```
1031
+ */
1032
+ declare function isEmpty<T>(iterable: Iterable<T>): boolean;
1033
+ /**
1034
+ * Creates a curried function that checks if an iterable includes a specific value.
1035
+ * Uses strict equality (===) for comparison.
1036
+ * Returns a function that takes an iterable and returns a boolean.
1037
+ *
1038
+ * @template T The type of elements
1039
+ * @param searchValue - The value to search for
1040
+ * @returns A function that checks if an iterable includes the value
1041
+ * @example
1042
+ * ```typescript
1043
+ * const includesThree = includes(3);
1044
+ * includesThree([1, 2, 3, 4, 5]); // true
1045
+ * includesThree([1, 2, 4]); // false
1046
+ * includes('b')(['a', 'b', 'c']); // true
1047
+ * ```
1048
+ */
1049
+ declare function includes<T>(searchValue: T): (iterable: Iterable<T>) => boolean;
1050
+ /**
1051
+ * Combines two iterables into an iterator of tuples.
1052
+ * Stops when the shorter iterable is exhausted.
1053
+ *
1054
+ * @template T The type of elements in the first iterable
1055
+ * @template U The type of elements in the second iterable
1056
+ * @param iter1 - The first iterable
1057
+ * @param iter2 - The second iterable
1058
+ * @returns An iterable iterator of tuples pairing elements from both iterables
1059
+ * @example
1060
+ * ```typescript
1061
+ * Array.from(zip([1, 2, 3], ['a', 'b', 'c']));
1062
+ * // [[1, 'a'], [2, 'b'], [3, 'c']]
1063
+ * ```
1064
+ */
1065
+ declare function zip<T, U>(iter1: Iterable<T>, iter2: Iterable<U>): IterableIterator<[T, U]>;
1066
+ /**
1067
+ * Combines two iterables using a combining function.
1068
+ * Stops when the shorter iterable is exhausted.
1069
+ *
1070
+ * @template T The type of elements in the first iterable
1071
+ * @template U The type of elements in the second iterable
1072
+ * @template R The type of the result
1073
+ * @param iter1 - The first iterable
1074
+ * @param iter2 - The second iterable
1075
+ * @param fn - Function to combine elements from both iterables
1076
+ * @returns An iterable iterator with combined results
1077
+ * @example
1078
+ * ```typescript
1079
+ * Array.from(zipWith([1, 2, 3], [10, 20, 30], (a, b) => a + b));
1080
+ * // [11, 22, 33]
1081
+ * ```
1082
+ */
1083
+ declare function zipWith<T, U, R>(iter1: Iterable<T>, iter2: Iterable<U>, fn: (a: T, b: U) => R): IterableIterator<R>;
1084
+ /**
1085
+ * Generates a sequence of numbers.
1086
+ * Supports three call signatures:
1087
+ * - range(stop): generates [0, stop) with step 1
1088
+ * - range(start, stop): generates [start, stop) with step 1
1089
+ * - range(start, stop, step): generates [start, stop) with custom step
1090
+ *
1091
+ * @param stop - The end value (exclusive) when called with one argument
1092
+ * @returns An iterable iterator of numbers
1093
+ * @throws {Error} If step is zero
1094
+ * @example
1095
+ * ```typescript
1096
+ * Array.from(range(5)); // [0, 1, 2, 3, 4]
1097
+ * Array.from(range(2, 5)); // [2, 3, 4]
1098
+ * Array.from(range(0, 10, 2)); // [0, 2, 4, 6, 8]
1099
+ * Array.from(range(5, 0, -1)); // [5, 4, 3, 2, 1]
1100
+ * ```
1101
+ */
1102
+ declare function range(stop: number): IterableIterator<number>;
1103
+ /**
1104
+ * Generates a sequence of numbers from start to stop (exclusive).
1105
+ *
1106
+ * @param start - The starting value (inclusive)
1107
+ * @param stop - The end value (exclusive)
1108
+ * @returns An iterable iterator of numbers
1109
+ */
1110
+ declare function range(start: number, stop: number): IterableIterator<number>;
1111
+ /**
1112
+ * Generates a sequence of numbers from start to stop (exclusive) with a custom step.
1113
+ *
1114
+ * @param start - The starting value (inclusive)
1115
+ * @param stop - The end value (exclusive)
1116
+ * @param step - The increment between values
1117
+ * @returns An iterable iterator of numbers
1118
+ */
1119
+ declare function range(start: number, stop: number, step: number): IterableIterator<number>;
1120
+ /**
1121
+ * Repeats a value a specified number of times, or infinitely.
1122
+ * If times is not specified, creates an infinite iterator.
1123
+ *
1124
+ * @template T The type of the value to repeat
1125
+ * @param value - The value to repeat
1126
+ * @param times - Optional number of times to repeat (infinite if omitted)
1127
+ * @returns An iterable iterator repeating the value
1128
+ * @example
1129
+ * ```typescript
1130
+ * Array.from(repeat('x', 3)); // ['x', 'x', 'x']
1131
+ * Array.from(repeat(0, 5)); // [0, 0, 0, 0, 0]
1132
+ * Array.from(take(3)(repeat(1))); // [1, 1, 1] (infinite, limited by take)
1133
+ * ```
1134
+ */
1135
+ declare function repeat<T>(value: T, times?: number): IterableIterator<T>;
1136
+ /**
1137
+ * Alternates elements from multiple iterables in a round-robin fashion.
1138
+ * Continues until all iterables are exhausted.
1139
+ *
1140
+ * @template T The type of elements in all iterables
1141
+ * @param iterables - Variable number of iterables to interleave
1142
+ * @returns An iterable iterator with elements from all iterables interleaved
1143
+ * @example
1144
+ * ```typescript
1145
+ * Array.from(interleave([1, 2, 3], [4, 5, 6]));
1146
+ * // [1, 4, 2, 5, 3, 6]
1147
+ * Array.from(interleave([1, 2], [3, 4, 5], [6]));
1148
+ * // [1, 3, 6, 2, 4, 5]
1149
+ * ```
1150
+ */
1151
+ declare function interleave<T>(...iterables: Iterable<T>[]): IterableIterator<T>;
1152
+ /**
1153
+ * Merges multiple sorted iterables into a single sorted iterator.
1154
+ * Assumes input iterables are already sorted in ascending order.
1155
+ * Uses a custom comparator if provided, otherwise uses default < comparison.
1156
+ *
1157
+ * @template T The type of elements in all iterables
1158
+ * @param iterables - Variable number of sorted iterables to merge
1159
+ * @returns An iterable iterator with all elements merged in sorted order
1160
+ * @example
1161
+ * ```typescript
1162
+ * Array.from(merge([1, 3, 5], [2, 4, 6]));
1163
+ * // [1, 2, 3, 4, 5, 6]
1164
+ * Array.from(merge([1, 5, 9], [2, 6, 10], [3, 7, 11]));
1165
+ * // [1, 2, 3, 5, 6, 7, 9, 10, 11]
1166
+ * ```
1167
+ */
1168
+ declare function merge<T>(...iterables: Iterable<T>[]): IterableIterator<T>;
1169
+ declare function merge<T>(compareFn: (a: T, b: T) => number, ...iterables: Iterable<T>[]): IterableIterator<T>;
1170
+ /**
1171
+ * Chains multiple iterables sequentially, one after another.
1172
+ * Yields all elements from the first iterable, then all from the second, etc.
1173
+ *
1174
+ * @template T The type of elements in all iterables
1175
+ * @param iterables - Variable number of iterables to chain
1176
+ * @returns An iterable iterator with all elements chained sequentially
1177
+ * @example
1178
+ * ```typescript
1179
+ * Array.from(chain([1, 2], [3, 4], [5, 6]));
1180
+ * // [1, 2, 3, 4, 5, 6]
1181
+ * Array.from(chain([1], [2, 3], [], [4, 5, 6]));
1182
+ * // [1, 2, 3, 4, 5, 6]
1183
+ * ```
1184
+ */
1185
+ declare function chain<T>(...iterables: Iterable<T>[]): IterableIterator<T>;
1186
+
1187
+ export { type IterableTransformer, type Reducer, type TerminalOperation, type Transducer, chain, chunk, compose, composeTransducers, concat, correlation, count, covariance, createOperation, distinct, distinctBy, drop, dropWhile, enumerate, every, filter, filterTransducer, find, findIndex, first, flatMap, groupBy, includes, interleave, intersperse, isEmpty, isReduced, last, map, mapTransducer, max, mean, median, merge, min, mode, nth, pairwise, partition, percentile, pipe, product, quartiles, range, reduce, reduced, repeat, reverse, scan, some, sort, sortBy, span, stdDev, sum, take, takeTransducer, takeWhile, tap, toArray, transduce, transducerToIterator, variance, window, zip, zipWith };