UNPKG

itertools-ts

Version:

Extended itertools port for TypeScript and JavaScript. Provides a huge set of functions for working with iterable collections (including async ones)

42 lines (41 loc) 1.47 kB
import { ZipTuple } from "./types"; /** * Iterates cartesian product of given iterables. * * @param iterables */ export declare function cartesianProduct<T extends Array<Iterable<unknown> | Iterator<unknown>>>(...iterables: T): Iterable<ZipTuple<T, never>>; /** * Iterates cartesian product of given async iterables. * * @param iterables */ export declare function cartesianProductAsync<T extends Array<AsyncIterable<unknown> | AsyncIterator<unknown> | Iterable<unknown> | Iterator<unknown>>>(...iterables: T): AsyncIterable<ZipTuple<T, never>>; /** * Iterates all permutations of given iterable. * * @param data * @param length */ export declare function permutations<T>(data: Iterable<T> | Iterator<T>, length: number): Iterable<Array<T>>; /** * Iterates all permutations of given async iterable. * * @param data * @param length */ export declare function permutationsAsync<T>(data: AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>, length: number): AsyncIterable<Array<T>>; /** * Iterates all combinations of given iterable. * * @param data * @param length */ export declare function combinations<T>(data: Iterable<T> | Iterator<T>, length: number): Iterable<Array<T>>; /** * Iterates all combinations of given async iterable. * * @param data * @param length */ export declare function combinationsAsync<T>(data: AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>, length: number): AsyncIterable<Array<T>>;