@szilanor/stream
Version:
Typesafe API for processing iterable data in TypeScript and JavaScript
1,058 lines (988 loc) • 95.9 kB
text/typescript
interface AsyncStreamLike<T> extends AsyncIterable<T> {
[Symbol.asyncIterator]: () => AsyncIterator<T>;
collectAsync: <O>(collector: AsyncCollectorFunction<T, O>) => Promise<O>;
pipeAsync: <O>(operation: AsyncOperationFunction<T, O>) => AsyncStreamLike<O>;
}
interface StreamLike<T> extends AsyncStreamLike<T>, Iterable<T> {
[Symbol.iterator]: () => Iterator<T>;
collect: <O>(collector: CollectorFunction<T, O>) => O;
pipe: <O>(operation: OperationFunction<T, O>) => StreamLike<O>;
}
type OperationFunction<TInput, TOutput> = (iterable: Iterable<TInput>) => Iterable<TOutput>;
type AsyncOperationFunction<TInput, TOutput> = (iterable: AsyncIterable<TInput>) => AsyncIterable<TOutput>;
type CollectorFunction<TInput, TOutput> = (iterable: Iterable<TInput>) => TOutput;
type AsyncCollectorFunction<TInput, TOutput> = (iterable: AsyncIterable<TInput>) => Promise<TOutput>;
type EqualsFunction<T> = (a: T, b: T) => boolean;
type CompareFunction<T> = (a: T, b: T) => number;
type MaybeAsyncValue<T> = T | Promise<T>;
type ReduceFunction<T, O = T> = (previous: O, current: T, index: number) => O;
type AsyncReduceFunction<T, O = T> = (previous: O, current: T, index: number) => MaybeAsyncValue<O>;
type ValueOrFactory<T> = T | (() => T);
type PredicateFunction<T> = (item: T, index: number) => boolean;
type MaybeAsyncPredicateFunction<T> = (item: T, index: number) => boolean | Promise<boolean>;
type TypeGuardFunction<T, TOfType extends T> = (item: T, index: number) => item is TOfType;
type CallbackFunction<T> = (item: T, index: number) => void;
type MaybeAsyncCallbackFunction<T> = (item: T, index: number) => void | Promise<void>;
type MapperFunction<T, O> = (item: T, index: number) => O;
type AsyncMapperFunction<T, O> = (item: T, index: number) => Promise<O>;
/**
* Wrapper class to extend the functionality of an AsyncIterable
*/
declare class AsyncStream<T> implements AsyncStreamLike<T> {
private readonly asyncIterable;
[Symbol.asyncIterator](): AsyncIterator<T>;
constructor(asyncIterable?: AsyncIterable<T> | null);
/** Calls a collector function on the AsyncIterable */
collectAsync<O>(collector: AsyncCollectorFunction<T, O>): Promise<O>;
/** Calls an operation function on the AsyncIterable then returns the result as a AsyncStream
* allowing to chain it with more AsyncStream related methods. */
pipeAsync(): AsyncStream<T>;
pipeAsync<A>(op1: AsyncOperationFunction<T, A>): AsyncStream<A>;
pipeAsync<A, B>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>): AsyncStream<B>;
pipeAsync<A, B, C>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>): AsyncStream<C>;
pipeAsync<A, B, C, D>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>): AsyncStream<D>;
pipeAsync<A, B, C, D, E>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>): AsyncStream<E>;
pipeAsync<A, B, C, D, E, F>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>): AsyncStream<F>;
pipeAsync<A, B, C, D, E, F, G>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>, op7: AsyncOperationFunction<F, G>): AsyncStream<G>;
pipeAsync<A, B, C, D, E, F, G, H>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>, op7: AsyncOperationFunction<F, G>, op8: AsyncOperationFunction<G, H>): AsyncStream<H>;
pipeAsync<A, B, C, D, E, F, G, H, I>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>, op7: AsyncOperationFunction<F, G>, op8: AsyncOperationFunction<G, H>, op9: AsyncOperationFunction<H, I>): AsyncStream<H>;
pipeAsync<A, B, C, D, E, F, G, H, I>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>, op7: AsyncOperationFunction<F, G>, op8: AsyncOperationFunction<G, H>, op9: AsyncOperationFunction<H, I>): AsyncStream<I>;
pipeAsync(...ops: AsyncOperationFunction<T, T>[]): AsyncStream<T>;
}
/**
* Returns an AsyncStream that yields elements of all Iterable parameters in order.
* @param iterables Array of Iterables to concatenate.
* @typeParam T Type of items in the source.
* @returns AsyncStream that yields elements of all Iterable parameters in order.
*
* @example
* ```typescript
* const result = concatAsync<number>([1, 2, 3], [4, 5, 6]);
* console.log(result); // [1, 2, 3, 4, 5, 6]
* ```
*/
declare function concatAsync<T>(...iterables: Array<Iterable<T> | AsyncIterable<T>>): AsyncStream<T>;
declare const chainAsync: typeof concatAsync;
/**
* Returns an AsyncStream that yields elements of the Iterable returned by the factory function.
* @param factory Factory function that returns an Iterable.
* @typeParam T Type of items in the source.
* @returns AsyncStream that yields elements of the Iterable returned by the factory function.
*
* @example
* ```typescript
* const result = deferAsync<number>(() => [1, 2, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function deferAsync<T>(factory: () => AsyncIterable<T>): AsyncStream<T>;
/**
* Returns an AsyncStream from an iterable (Array, Set, Map, Stream...)
* @param iterable Iterable to convert to an AsyncStream.
* @typeParam T Type of items in the iterable.
* @returns AsyncStream that yields elements of the iterable.
*
* @example
* ```typescript
* const result = fromAsync<number>([1, 2, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function fromAsync<T>(iterable?: AsyncIterable<T>): AsyncStream<T>;
declare const streamAsync: typeof fromAsync;
/**
* Returns an AsyncStream that merges elements from both iterables by taking one
* element from each, passing them to the function, and yielding the result.
* @param a First iterable to zip.
* @param b Second iterable to zip.
* @param zipFunction Function to merge elements from both iterables.
* @typeParam A Type of items in the first iterable.
* @typeParam B Type of items in the second iterable.
* @typeParam O Type of items in the result.
* @returns AsyncStream that yields elements of the zipped iterables.
*
* @example
* ```typescript
* const result = zipAsync<number, number, number>([1, 2, 3], [4, 5, 6], (a, b) => a + b);
* console.log(result); // [5, 7, 9]
* ```
*/
declare function zipAsync<A, B, O>(a: AsyncIterable<A>, b: AsyncIterable<B>, zipFunction: (a: A, b: B) => O): AsyncStream<O>;
/**
* Wrapper class to extend the functionality of an Iterable
*/
declare class Stream<T> extends AsyncStream<T> implements StreamLike<T> {
private readonly iterable;
constructor(iterable?: Iterable<T> | null);
[Symbol.iterator](): Iterator<T>;
[Symbol.asyncIterator](): AsyncIterator<T>;
/** Calls a collector function on the Iterable */
collect<O>(collector: CollectorFunction<T, O>): O;
/** Calls an operation function on the Iterable then returns the result as a Stream
* allowing to chain it with more Stream related methods. */
pipe(): Stream<T>;
pipe<A>(op1: OperationFunction<T, A>): Stream<A>;
pipe<A, B>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>): Stream<B>;
pipe<A, B, C>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>): Stream<C>;
pipe<A, B, C, D>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>): Stream<D>;
pipe<A, B, C, D, E>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>): Stream<E>;
pipe<A, B, C, D, E, F>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>): Stream<F>;
pipe<A, B, C, D, E, F, G>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>, op7: OperationFunction<F, G>): Stream<G>;
pipe<A, B, C, D, E, F, G, H>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>, op7: OperationFunction<F, G>, op8: OperationFunction<G, H>): Stream<H>;
pipe<A, B, C, D, E, F, G, H, I>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>, op7: OperationFunction<F, G>, op8: OperationFunction<G, H>, op9: OperationFunction<H, I>): Stream<H>;
pipe<A, B, C, D, E, F, G, H, I>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>, op7: OperationFunction<F, G>, op8: OperationFunction<G, H>, op9: OperationFunction<H, I>): Stream<I>;
pipe(...ops: OperationFunction<T, T>[]): Stream<T>;
}
/**
* Returns a Stream that yields the permutations of the specified iterable.
* @typeParam T Type of items in the Stream.
* @param iterable Iterable to create the Stream from.
* @param r Number of items to yield.
* @returns Stream that yields the permutations of the specified iterable.
*
* @example
* ```typescript
* const result = permutations([1, 2, 3], 2);
* console.log([...result]); // [[1, 2], [1, 3], [2, 1], [2, 3], [3, 1], [3, 2]]
* ```
*/
declare function permutations<T>(iterable: Iterable<T>, r?: number): Stream<T[]>;
/**
* Returns a Stream that yields the combinations of the specified iterable.
* @typeParam T Type of items in the Stream.
* @param iterable Iterable to create the Stream from.
* @param r Number of items to yield.
* @returns Stream that yields the combinations of the specified iterable.
*
* @example
* ```typescript
* const result = combinations([1, 2, 3], 2);
* console.log([...result]); // [[1, 2], [1, 3], [2, 3]]
* ```
*/
declare function combinations<T>(iterable: Iterable<T>, r: number): Stream<T[]>;
/**
* Returns a Stream that yields the entries of the specified object.
* @typeParam T Type of items in the Stream.
* @param entry Object to create the Stream from.
* @returns Stream that yields the entries of the specified object.
*
* @example
* ```typescript
* const result = entries({ a: 1, b: 2 });
* console.log([...result]); // [["a", 1], ["b", 2]]
* ```
*/
declare function entries<T extends object>(entry: T): Stream<[keyof T, T[keyof T]]>;
/**
* Returns a Stream that yields the keys of the specified object.
* @typeParam T Type of items in the Stream.
* @param entry Object to create the Stream from.
* @returns Stream that yields the keys of the specified object.
*
* @example
* ```typescript
* const result = keys({ a: 1, b: 2 });
* console.log([...result]); // ["a", "b"]
* ```
*/
declare function keys<T extends object>(entry: T): Stream<keyof T>;
/**
* Returns a Stream that yields the values of the specified object.
* @typeParam T Type of items in the Stream.
* @param entry Object to create the Stream from.
* @returns Stream that yields the values of the specified object.
*
* @example
* ```typescript
* const result = values({ a: 1, b: 2 });
* console.log([...result]); // [1, 2]
* ```
*/
declare function values<T extends object>(entry: T): Stream<T[keyof T]>;
/**
* Returns a Stream that yields elements of all Iterable parameters in order.
* @param iterables Iterables to concatenate.
* @typeParam T Type of items in the Iterables.
* @returns Stream that yields elements of all Iterables in order.
*
* @example
* ```typescript
* const result = concat<number>([1, 2, 3], [4, 5, 6]);
* console.log(result); // [1, 2, 3, 4, 5, 6]
* ```
*/
declare function concat<T>(...iterables: Array<Iterable<T>>): Stream<T>;
declare const chain: typeof concat;
/**
* Returns a Stream that infinitely yields elements of the Iterable parameter.
* @param iterable Iterable to cycle.
* @typeParam T Type of items in the iterable.
* @returns Stream that yields elements of the iterable infinitely.
*
* @example
* ```typescript
* const result = cycle<number>([1, 2, 3]);
* console.log(result); // [1, 2, 3, 1, 2, 3, ...]
* ```
*/
declare function cycle<T>(iterable: Iterable<T>): Stream<T>;
/**
* Returns a Stream that defers the creation of the Iterable until the Stream is iterated.
* @param factory Factory function that returns an Iterable.
* @typeParam T Type of items in the Iterable.
* @returns Stream that defers the creation of the Iterable.
*
* @example
* ```typescript
* const result = defer(() => 'ABCD');
* console.log([...result]); // ['A', 'B', 'C', 'D']
* ```
*/
declare function defer<T>(factory: () => Iterable<T>): Stream<T>;
/**
* Returns a Stream that is empty.
* @typeParam T Type of items in the Stream.
* @returns Stream that is empty.
*
* @example
* ```typescript
* const result = empty();
* console.log([...result]); // []
* ```
*/
declare function empty<T>(): Stream<T>;
/**
* Returns a Stream that yields the elements of the Iterable parameter.
* @typeParam T Type of items in the Stream.
* @param iterable Iterable to create the Stream from.
* @returns Stream that yields the elements of the Iterable.
*
* @example
* ```typescript
* const result = from('ABCD');
* console.log([...result]); // ['A', 'B', 'C', 'D']
* ```
*/
declare function from<T>(iterable?: Iterable<T>): Stream<T>;
declare const stream: typeof from;
/**
* Returns a Stream that yields the specified entries.
* @typeParam T Type of items in the Stream.
* @param entries Entries to create the Stream from.
* @returns Stream that yields the specified entries.
*
* @example
* ```typescript
* const result = of(1, 2, 3);
* console.log([...result]); // [1, 2, 3]
* ```
*/
declare function of<T>(...entries: T[]): Stream<T>;
declare const streamOf: typeof of;
/**
* Returns a Stream that merges elements from both iterables by taking one
* element from each, passing them to the function, and yielding the result.
* @param a The first iterable to merge.
* @param b The second iterable to merge.
* @param productFunction The function that merges the elements.
* @typeParam A Type of items in the first iterable.
* @typeParam B Type of items in the second iterable.
* @typeParam O Type of items in the result.
* @returns A Stream that merges elements from both iterables.
*
* @example
* ```typescript
* const result = product('ABCD', 'xy', (a, b) => `${a}${b}`);
* console.log([...result]); // ['Ax', 'Ay', 'Bx', 'By', 'Cx', 'Cy', 'Dx', 'Dy']
* ```
*/
declare function product<A, B, O>(a: Iterable<A>, b: Iterable<B>, productFunction: (a: A, b: B) => O): Stream<O>;
/**
* Returns a Stream that yields numbers starting from 'start' up to 'start + count - 1'.
* @param start The first number in the range.
* @param count The number of elements in the range.
* @param by The step between elements.
* @returns A Stream that yields numbers in the range.
*
* @example
* ```typescript
* const result = range(1, 5, 2);
* console.log([...result]); // [1, 3, 5]
* ```
*/
declare function range(start: number, count: number, by?: number): Stream<number>;
/**
* Returns a Stream that yields the same value 'times' number of times.
* @param value Value to repeat.
* @param times Number of times to repeat the value.
* @typeParam T Type of the value.
* @returns A Stream that yields the value 'times' number of times.
*
* @example
* ```typescript
* const result = repeat('A', 3);
* console.log([...result]); // ['A', 'A', 'A']
* ```
*/
declare function repeat<T>(value: ValueOrFactory<T>, times?: number): Stream<T>;
/**
* Returns a Stream that merges elements from both iterables by taking one
* element from each, passing them to the function, and yielding the result.
* @param a The first iterable to merge.
* @param b The second iterable to merge.
* @param zipFunction The function that merges the elements.
* @typeParam A Type of items in the first iterable.
* @typeParam B Type of items in the second iterable.
* @typeParam O Type of items in the result.
* @returns A Stream that merges elements from both iterables.
*
* @example
* ```typescript
* const result = zip('ABCD', 'xy', (a, b) => `${a}${b}`);
* console.log([...result]); // ['Ax', 'By']
* ```
*/
declare function zip<A, B, O>(a: Iterable<A>, b: Iterable<B>, zipFunction: (a: A, b: B) => O): Stream<O>;
/**
* Returns a Stream that merges elements from both iterables by taking one
* element from each, passing them to the function, and yielding the result.
* @param a The first iterable to merge.
* @param b The second iterable to merge.
* @param fillValue The value or factory to use when one iterable is done.
* @param zipFunction The function that merges the elements.
* @returns A Stream that merges elements from both iterables.
*
* @example
* ```typescript
* const result = zipLongest('ABCD', 'xy', ' ', (a, b) => `${a}${b}`);
* console.log([...result]); // ['Ax', 'By', 'C ', 'D ']
* ```
*/
declare function zipLongest<A, B, F, O>(a: Iterable<A>, b: Iterable<B>, fillValue: ValueOrFactory<F>, zipFunction: (a: A | F, b: B | F) => O): Stream<O>;
/**
* Returns a Stream that shuffles the items of the specified array.
* @typeParam T Type of items in the Stream.
* @param array Array to shuffle.
* @returns Stream that yields the shuffled items of the specified array.
*
* @example
* ```typescript
* const result = shuffle([1, 2, 3]);
* console.log([...result]); // [3, 1, 2]
* ```
*/
declare function shuffle<T>(array: T[]): Stream<T>;
/**
* Appends the specified iterables to the source iterable.
* @param iterables The iterables to append.
* @typeParam T The type of the elements in the iterables.
* @returns An AsyncOperationFunction that appends the specified iterables to the source iterable.
*
* @example
* ```typescript
* const result = appendWithAsync<number>([1, 2, 3], [4, 5, 6]);
* console.log(result); // [1, 2, 3, 4, 5, 6]
* ```
*/
declare function appendWithAsync<T>(...iterables: Iterable<T>[]): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields array of entries of the source Iterable with the given length.
* @param size The length of the array to yield.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields array of entries of the source Iterable with the given length.
*
* @example
* ```typescript
* const result = bufferAsync<number>([1, 2, 3], 2);
* console.log(result); // [[1, 2], [3]]
* ```
*/
declare function bufferAsync<T>(size: number): AsyncOperationFunction<T, T[]>;
/** Type-safe helper operation that concatenates multiple operations in order. */
declare function compoundAsync<T>(): AsyncOperationFunction<T, T>;
declare function compoundAsync<T, A>(op1: AsyncOperationFunction<T, A>): AsyncOperationFunction<T, A>;
declare function compoundAsync<T, A, B>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>): AsyncOperationFunction<T, B>;
declare function compoundAsync<T, A, B, C>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>): AsyncOperationFunction<T, C>;
declare function compoundAsync<T, A, B, C, D>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>): AsyncOperationFunction<T, D>;
declare function compoundAsync<T, A, B, C, D, E>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>): AsyncOperationFunction<T, E>;
declare function compoundAsync<T, A, B, C, D, E, F>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>): AsyncOperationFunction<T, F>;
declare function compoundAsync<T, A, B, C, D, E, F, G>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>, op7: AsyncOperationFunction<F, G>): AsyncOperationFunction<T, G>;
declare function compoundAsync<T, A, B, C, D, E, F, G, H>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>, op7: AsyncOperationFunction<F, G>, op8: AsyncOperationFunction<G, H>): AsyncOperationFunction<T, H>;
declare function compoundAsync<T, A, B, C, D, E, F, G, H, I>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>, op7: AsyncOperationFunction<F, G>, op8: AsyncOperationFunction<G, H>, op9: AsyncOperationFunction<H, I>): AsyncOperationFunction<T, I>;
declare function compoundAsync<T, A, B, C, D, E, F, G, H, I, J>(op1: AsyncOperationFunction<T, A>, op2: AsyncOperationFunction<A, B>, op3: AsyncOperationFunction<B, C>, op4: AsyncOperationFunction<C, D>, op5: AsyncOperationFunction<D, E>, op6: AsyncOperationFunction<E, F>, op7: AsyncOperationFunction<F, G>, op8: AsyncOperationFunction<G, H>, op9: AsyncOperationFunction<H, I>, op10: AsyncOperationFunction<I, J>): AsyncOperationFunction<T, unknown>;
declare const pipeAsync: typeof compoundAsync;
/**
* Concatenates the Iterable with other Iterables in order.
* @param iterables The iterables to concatenate.
* @typeParam T The type of the elements in the iterables.
* @returns An AsyncOperationFunction that concatenates the specified iterables to the source iterable.
*
* @example
* ```typescript
* const result = concatWithAsync<number>([1, 2, 3], [4, 5, 6]);
* console.log(result); // [1, 2, 3, 4, 5, 6]
* ```
*/
declare function concatWithAsync<T>(...iterables: Array<AsyncIterable<T> | Iterable<T>>): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields the defaultValue parameter if the source Iterable is empty.
* @param defaultValue The value or factory to use when the source Iterable is empty.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields the defaultValue parameter if the source Iterable is empty.
*
* @example
* ```typescript
* const result = defaultIfEmptyAsync<number>([], 0);
* console.log(result); // [0]
* ```
*/
declare function defaultIfEmptyAsync<T>(defaultValue: ValueOrFactory<T>): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields only entries of the source Iterable without duplicates.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only entries of the source Iterable without duplicates.
*
* @example
* ```typescript
* const result = distinctAsync<number>([1, 2, 2, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function distinctAsync<T>(): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields only entries of the source Iterable without duplicates.
* @param equalsFunction The function to use to compare the elements.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only entries of the source Iterable without duplicates.
*
* @example
* ```typescript
* const result = distinctByAsync<number>([1, 2, 2, 3], (a, b) => a === b);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function distinctByAsync<T>(equalsFunction?: EqualsFunction<T>): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields only entries of the source Iterable without duplicates.
* @param equalsFunction The function to use to compare the elements.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only entries of the source Iterable without duplicates.
*
* @example
* ```typescript
* const result = distinctUntilChangedAsync<number>([1, 2, 2, 3], (a, b) => a === b);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function distinctUntilChangedAsync<T>(equalsFunction?: EqualsFunction<T>): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields only entries of the source Iterable without duplicates.
* @param key The key to use to compare the elements.
* @param equalsFunction The function to use to compare the elements.
* @typeParam T The type of the elements in the source Iterable.
* @typeParam K The type of the key to use to compare the elements.
* @returns An AsyncOperationFunction that yields only entries of the source Iterable without duplicates.
*
* @example
* ```typescript
* const result = distinctUntilKeyChangedAsync<number>([1, 2, 2, 3], (a, b) => a === b);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function distinctUntilKeyChangedAsync<T, K extends keyof T>(key: K, equalsFunction?: EqualsFunction<T[K]>): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields the entries of the source Iterable then the parameter value.
* @param values The values to append to the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields the entries of the source Iterable then the parameter value.
*
* @example
* ```typescript
* const result = endWithAsync<number>([1, 2, 3], 4, 5, 6);
* console.log(result); // [1, 2, 3, 4, 5, 6]
* ```
*/
declare function endWithAsync<T>(...values: T[]): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields only entries of the source Iterable with falsy value.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only entries of the source Iterable with falsy value.
*
* @example
* ```typescript
* const result = falsyAsync<number>([1, 2, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function falsyAsync<T>(): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields only entries of the source Iterable that satisfy the function.
* @param predicate The function to use to filter the entries.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only entries of the source Iterable that satisfy the function.
*
* @example
* ```typescript
* const result = filterAsync<number>([1, 2, 3], (value) => value > 1);
* console.log(result); // [2, 3]
* ```
*/
declare function filterAsync<T, TOfType extends T = T>(predicate: PredicateFunction<T> | TypeGuardFunction<T, TOfType>): AsyncOperationFunction<T, TOfType>;
/**
* Returns an AsyncOperationFunction that yields the inner entries of array entries of the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields the inner entries of array entries of the source Iterable.
*
* @example
* ```typescript
* const result = flatAsync<number>([[1, 2], [3, 4]]);
* console.log(result); // [1, 2, 3, 4]
* ```
*/
declare function flatAsync<T>(): AsyncOperationFunction<Iterable<T>, T>;
declare const flattenAsync: typeof flatAsync;
/**
* Returns an AsyncOperationFunction that yields the inner entries of the
* result produced by the function.
* @param mapper The function to use to map the entries.
* @typeParam T The type of the elements in the source Iterable.
* @typeParam O The type of the elements in the result Iterable.
* @returns An AsyncOperationFunction that yields the inner entries of the
* result produced by the function.
*
* @example
* ```typescript
* const result = flatMapAsync<number, number>([1, 2, 3], (value) => [value, value * 2]);
* console.log(result); // [1, 2, 2, 4, 3, 6]
* ```
*/
declare function flatMapAsync<T, O>(mapper: (value: T, index: number) => Iterable<O>): AsyncOperationFunction<T, O>;
/**
* Returns an AsyncOperationFunction that yields entries of the source Iterable transformed using the function.
* @param mapper The function to use to map the entries.
* @typeParam T The type of the elements in the source Iterable.
* @typeParam O The type of the elements in the result Iterable.
* @returns An AsyncOperationFunction that yields entries of the source Iterable transformed using the function.
*
* @example
* ```typescript
* const result = mapAsync<number, number>([1, 2, 3], (value) => value * 2);
* console.log(result); // [2, 4, 6]
* ```
*/
declare function mapAsync<T, O>(mapper: MapperFunction<T, O> | AsyncMapperFunction<T, O>): AsyncOperationFunction<T, O>;
/**
* Simply returns every entry from the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that simply returns every entry from the source Iterable.
*
* @example
* ```typescript
* const result = noopAsync<number>([1, 2, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function noopAsync<T>(): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields only the non-null / non-undefined entries of the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only the non-null / non-undefined entries of the source Iterable.
*
* @example
* ```typescript
* const result = notNullAsync<number>([1, 2, null, undefined, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function notNullAsync<T>(): AsyncOperationFunction<T | undefined | null, NonNullable<T>>;
/**
* Returns an AsyncOperationFunction that yields only the non-null / non-undefined / non-empty entries of the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only the non-null / non-undefined / non-empty entries of the source Iterable.
*
* @example
* ```typescript
* const result = notNullOrEmptyAsync<number>([1, 2, null, undefined, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function notNullOrEmptyAsync<T extends {
length: number;
}>(): AsyncOperationFunction<T | undefined | null, NonNullable<T>>;
/**
* Returns an AsyncOperationFunction that yields only the non-null / non-undefined / non-empty entries of the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only the non-null / non-undefined / non-empty entries of the source Iterable.
*
* @example
* ```typescript
* const result = notNullOrWhitespaceAsync<number>([1, 2, null, undefined, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function notNullOrWhitespaceAsync(): AsyncOperationFunction<string | null | undefined, NonNullable<string>>;
/**
* Returns an AsyncOperationFunction that yields and casts only entries of the source Iterable that satisfy the given type-guard function.
* @param predicate The type-guard function to use to filter the entries.
* @typeParam T The type of the elements in the source Iterable.
* @typeParam TOfType The type of the elements in the result Iterable.
* @returns An AsyncOperationFunction that yields and casts only entries of the source Iterable that satisfy the given type-guard function.
*
* @example
* ```typescript
* const result = ofTypeAsync<number, number>([1, 2, null, undefined, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function ofTypeAsync<T, TOfType extends T = T>(predicate: TypeGuardFunction<T, TOfType>): AsyncOperationFunction<T, TOfType>;
/**
* Returns an AsyncOperationFunction that yields the current and the previous entry of the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields the current and the previous entry of the source Iterable.
*
* @example
* ```typescript
* const result = pairwiseAsync<number>([1, 2, 3]);
* console.log(result); // [[1, 2], [2, 3]]
* ```
*/
declare function pairwiseAsync<T>(): AsyncOperationFunction<T, [T, T]>;
/**
* Returns an AsyncOperationFunction that skips the given amount of entries of the source Iterable.
* @param count The amount of entries to skip.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that skips the given amount of entries of the source Iterable.
*
* @example
* ```typescript
* const result = skipAsync<number>([1, 2, 3], 2);
* console.log(result); // [3]
* ```
*/
declare function skipAsync<T>(count: number): AsyncOperationFunction<T, T>;
declare const dropAsync: typeof skipAsync;
/**
* Returns an AsyncOperationFunction that skips entries of the source Iterable while the parameter function returns true.
* @param predicate The function to use to filter the entries.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that skips entries of the source Iterable while the parameter function returns true.
*
* @example
* ```typescript
* const result = skipWhileAsync<number>([1, 2, 3], (value) => value < 2);
* console.log(result); // [2, 3]
* ```
*/
declare function skipWhileAsync<T>(predicate: PredicateFunction<T>): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields the value parameter then the entries of the source Iterable.
* @param values The values to yield before the entries of the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields the value parameter then the entries of the source Iterable.
*
* @example
* ```typescript
* const result = startWithAsync<number>([1, 2, 3], 2);
* console.log(result); // [2, 1, 2, 3]
* ```
*/
declare function startWithAsync<T>(...values: T[]): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that takes the given amount of entries of the source Iterable.
* @param count The amount of entries to take.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that takes the given amount of entries of the source Iterable.
*
* @example
* ```typescript
* const result = takeAsync<number>([1, 2, 3], 2);
* console.log(result); // [1, 2]
* ```
*/
declare function takeAsync<T>(count: number): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that takes entries of the source Iterable while the parameter function returns true.
* @param predicate The function to use to filter the entries.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that takes entries of the source Iterable while the parameter function returns true.
*
* @example
* ```typescript
* const result = takeWhileAsync<number>([1, 2, 3], (value) => value < 2);
* console.log(result); // [1]
* ```
*/
declare function takeWhileAsync<T>(predicate: PredicateFunction<T>): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that calls a callback function on each entry.
* @param callback The callback function to call on each entry.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that calls a callback function on each entry.
*
* @example
* ```typescript
* const result = tapAsync<number>([1, 2, 3], (value) => console.log(value));
* console.log(result); // [1, 2, 3]
* ```
*/
declare function tapAsync<T>(callback: CallbackFunction<T>): AsyncOperationFunction<T, T>;
/**
* Returns an AsyncOperationFunction that yields only entries of the source Iterable with truthy value.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields only entries of the source Iterable with truthy value.
*
* @example
* ```typescript
* const result = truthyAsync<number>([1, 2, null, undefined, 3]);
* console.log(result); // [1, 2, 3]
* ```
*/
declare function truthyAsync<T>(): AsyncOperationFunction<T, T>;
declare class IndexedAsyncIterator<T> implements AsyncIterator<[T, number]> {
private iterator;
private index;
constructor(iterator: AsyncIterator<T>);
next(): Promise<IteratorResult<[T, number]>>;
}
/**
* Returns an AsyncOperationFunction that yields the current and the index of the entry of the source Iterable.
* @typeParam T The type of the elements in the source Iterable.
* @returns An AsyncOperationFunction that yields the current and the index of the entry of the source Iterable.
*
* @example
* ```typescript
* const result = withIndexAsync<number>([1, 2, 3]);
* console.log(result); // [[1, 0], [2, 1], [3, 2]]
* ```
*/
declare function withIndexAsync<T>(): AsyncOperationFunction<T, [T, number]>;
/**
* Returns a Stream that yields the result of applying the reducer function to each element of the source.
* @typeParam T Type of items in the source.
* @typeParam O Type of items to yield.
* @param reducerFunction A function that reduces the source to a single value.
* @param initialValue Initial value or factory function to use as the first argument to the reducer function.
* @returns Operation that yields the result of applying the reducer function to each element of the source.
*
* @example
* ```typescript
* const result = scan<number, number>((prev, curr) => prev + curr, 0)([1, 2, 3]);
* console.log([...result]); // [1, 3, 6]
* ```
*/
declare function scanAsync<T, O>(reducerFunction: AsyncReduceFunction<T, O>, initialValue: ValueOrFactory<O>): AsyncOperationFunction<T, O>;
/**
* Returns an OperationFunction that appends the given Iterables to the end of the source Iterable.
* @param iterables Iterables to append.
* @typeParam T Type of items in the Iterables.
* @returns Returns an OperationFunction that appends the given Iterables to the end of the source Iterable.
*
* @example
* ```typescript
* const result = appendWith([4, 5, 6], [7, 8, 9])([1, 2, 3]);
* console.log([...result]); // [1, 2, 3, 4, 5, 6, 7, 8, 9]
* ```
*/
declare function appendWith<T>(...iterables: Iterable<T>[]): OperationFunction<T, T>;
/**
* Returns an OperationFunction that yields only array entries of the source Iterable that satisfy the function.
* @param predicate The function to use to filter the entries.
* @typeParam T The type of the elements in the source Iterable.
* @returns An OperationFunction that yields only array entries of the source Iterable that satisfy the function.
*
* @example
* ```typescript
* const result = arrayFilter<number>([1, 2, 3], (value) => value < 2);
* console.log(result); // [1]
* ```
*/
declare function arrayFilter<T>(predicate: (entry: T, index: number) => boolean): OperationFunction<T[], T[]>;
/**
* Returns an OperationFunction that yields array entries of the source Iterable transformed using the function.
* @param mapper The function to use to transform the entries.
* @typeParam T The type of the elements in the source Iterable.
* @typeParam O The type of the elements in the transformed Iterable.
* @returns An OperationFunction that yields array entries of the source Iterable transformed using the function.
*
* @example
* ```typescript
* const result = arrayMap<number, string>([1, 2, 3], (value) => value.toString());
* console.log(result); // ["1", "2", "3"]
* ```
*/
declare function arrayMap<T, O>(mapper: (entry: T, index: number) => O): OperationFunction<T[], O[]>;
/**
* Returns an OperationFunction that buffers the source elements into arrays of 'size' elements.
* @param size The number of elements in each buffer.
* @typeParam T Type of the elements.
* @returns An OperationFunction that buffers the source elements into arrays of 'size' elements.
*
* @example
* ```typescript
* const result = buffer(3)([1, 2, 3, 4, 5, 6]);
* console.log([...result]); // [[1, 2, 3], [4, 5, 6]]
* ```
*/
declare function buffer<T>(size: number): OperationFunction<T, T[]>;
/** Type-safe helper operation that concatenates multiple operations in order. */
declare function compound<T>(): OperationFunction<T, T>;
declare function compound<T, A>(op1: OperationFunction<T, A>): OperationFunction<T, A>;
declare function compound<T, A, B>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>): OperationFunction<T, B>;
declare function compound<T, A, B, C>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>): OperationFunction<T, C>;
declare function compound<T, A, B, C, D>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>): OperationFunction<T, D>;
declare function compound<T, A, B, C, D, E>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>): OperationFunction<T, E>;
declare function compound<T, A, B, C, D, E, F>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>): OperationFunction<T, F>;
declare function compound<T, A, B, C, D, E, F, G>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>, op7: OperationFunction<F, G>): OperationFunction<T, G>;
declare function compound<T, A, B, C, D, E, F, G, H>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>, op7: OperationFunction<F, G>, op8: OperationFunction<G, H>): OperationFunction<T, H>;
declare function compound<T, A, B, C, D, E, F, G, H, I>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>, op7: OperationFunction<F, G>, op8: OperationFunction<G, H>, op9: OperationFunction<H, I>): OperationFunction<T, I>;
declare function compound<T, A, B, C, D, E, F, G, H, I, J>(op1: OperationFunction<T, A>, op2: OperationFunction<A, B>, op3: OperationFunction<B, C>, op4: OperationFunction<C, D>, op5: OperationFunction<D, E>, op6: OperationFunction<E, F>, op7: OperationFunction<F, G>, op8: OperationFunction<G, H>, op9: OperationFunction<H, I>, op10: OperationFunction<I, J>): OperationFunction<T, J>;
declare const pipe: typeof compound;
/**
* Returns an OperationFunction that concatenates the given Iterables to the end of the source Iterable.
* @param iterables Iterables to concatenate.
* @typeParam T Type of items in the Iterables.
* @returns An OperationFunction that concatenates the given Iterables to the end of the source Iterable.
*
* @example
* ```typescript
* const result = concatWith([4, 5, 6], [7, 8, 9])([1, 2, 3]);
* console.log([...result]); // [1, 2, 3, 4, 5, 6, 7, 8, 9]
* ```
*/
declare function concatWith<T>(...iterables: Iterable<T>[]): OperationFunction<T, T>;
/**
* Returns an OperationFunction that emits a default value if the source is empty.
* @param defaultValue Value to emit if the source is empty.
* @typeParam T Type of items emitted by the source.
* @returns An OperationFunction that emits a default value if the source is empty.
*
* @example
* ```typescript
* const result = defaultIfEmpty('A')([]);
* console.log([...result]); // ['A']
* ```
*/
declare function defaultIfEmpty<T>(defaultValue: ValueOrFactory<T>): OperationFunction<T, T>;
/**
* Returns an OperationFunction that yields distinct elements from the source.
* @typeParam T Type of items in the source.
* @returns An OperationFunction that yields distinct elements from the source.
*
* @example
* ```typescript
* const result = distinct()([1, 2, 1, 3, 2, 4]);
* console.log([...result]); // [1, 2, 3, 4]
* ```
*/
declare function distinct<T>(): OperationFunction<T, T>;
/**
* Returns an OperationFunction that yields distinct elements from the source based on the equals function.
* @param equalsFunction Function to compare elements.
* @typeParam T Type of items in the source.
* @returns An OperationFunction that yields distinct elements from the source based on the equals function.
*
* @example
* ```typescript
* const result = distinctBy<number>((a, b) => a % 2 === b % 2)([1, 2, 1, 3, 2, 4]);
* console.log([...result]); // [1, 2]
* ```
*/
declare function distinctBy<T>(equalsFunction?: EqualsFunction<T>): OperationFunction<T, T>;
/**
* Returns an OperationFunction that yields elements from the source that are distinct from the previous element.
* @param equalsFunction Function to compare elements.
* @typeParam T Type of items in the source.
* @returns An OperationFunction that yields elements from the source that are distinct from the previous element.
*
* @example
* ```typescript
* const result = distinctUntilChanged<number>()([1, 1, 2, 2, 3, 3]);
* console.log([...result]); // [1, 2, 3]
* ```
*/
declare function distinctUntilChanged<T>(equalsFunction?: EqualsFunction<T>): OperationFunction<T, T>;
/**
* Returns an OperationFunction that yields elements from the source that are distinct from the previous element based on the key.
* @param key Key to compare elements.
* @param equalsFunction Function to compare elements.
* @typeParam T Type of items in the source.
* @returns An OperationFunction that yields elements from the source that are distinct from the previous element based on the key.
*
* @example
* ```typescript
* const result = distinctUntilKeyChanged('a')([{ a: 1 }, { a: 1 }, { a: 2 }, { a: 2 }, { a: 3 }, { a: 3 }]);
* console.log([...result]); // [{ a: 1 }, { a: 2 }, { a: 3 }]
* ```
*/
declare function distinctUntilKeyChanged<T, K extends keyof T>(key: K, equalsFunction?: EqualsFunction<T[K]>): OperationFunction<T, T>;
/**
* Returns an OperationFunction that concatenates the given values to the end of the source Iterable.
* @param values Values to concatenate.
* @typeParam T Type of items in the Iterables.
* @returns An OperationFunction that concatenates the given values to the end of the source Iterable.
*
* @example
* ```typescript
* const result = endWith(4, 5, 6)([1, 2, 3]);
* console.log([...result]); // [1, 2, 3, 4, 5, 6]
* ```
*/
declare function endWith<T>(...values: T[]): OperationFunction<T, T>;
/**
* Returns an OperationFunction that yields elements that are falsy.
* @typeParam T Type of items in the source.
* @returns An OperationFunction that yields elements that are falsy.
*
* @example
* ```typescript
* const result = falsy<number>()([0, 1, 2, 3, 4]);
* console.log([...result]); // [0]
* ```
*/
declare function falsy<T>(): OperationFunction<T, T>;
/**
* Returns an OperationFunction that yields elements from the source that satisfy the predicate.
* @param predicate Predicate to filter elements.
* @typeParam T Type of items in the source.
* @returns An OperationFunction that yields elements from the source that satisfy the predicate.
*
* @example
* ```typescript
* const result = filter((x) => x % 2 === 0)([1, 2, 3, 4, 5]);
* console.log([...result]); // [2, 4]
* ```
*/
declare function filter<T, TOfType extends T = T>(predicate: PredicateFunction<T> | TypeGuardFunction<T, TOfType>): OperationFunction<T, TOfType>;
/**
* Returns an OperationFunction that yields elements from the source that are Iterable and flattens them.
* @typeParam T Type of items in the source.
* @returns An OperationFunction that yields elements from the source that are Iterable and flattens them.
*
* @example
* ```typescript
* const result = flat<number>()([[1, 2], [3, 4]]);
* console.log([...result]); // [1, 2, 3, 4]
* ```
*/
declare function flat<T>(): OperationFunction<Iterable<T>, T>;
declare const flatten: typeof flat;
/**
* Returns an OperationFunction that maps each element to an Iterable and flattens the result.
* @param mapper Mapping function.
* @typeParam T Type of items in the source.
* @typeParam O Type of items in the resulting Iterable.
* @returns An OperationFunction that maps each element to an Iterable and flattens the result.
*
* @example
* ```typescript
* const result = flatMap<number, number>((value) => [value, value + 1])([1, 2, 3]);
* console.log([...result]); // [1, 2, 2, 3, 3, 4]
* ```
*/
declare function flatMap<T, O>(mapper: (value: T, index: number) => Iterable<O>): OperationFunction<T, O>;
/**
* Returns an OperationFunction that yields elements from the source transformed by the mapper.
* @param mapper Function to transform elements.
* @typeParam T Type of items in the source.
* @typeParam O Type of items