itertools-ts
Version:
Extended itertools port for TypeScript and JavaScript. Provides a huge set of functions for working with iterable collections (including async ones)
120 lines (119 loc) • 4.59 kB
TypeScript
import { Comparable, ZipTuple } from "./index";
/**
* Iterate only the distinct elements.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param data
* @param compareBy
*/
export declare function distinct<T>(data: Iterable<T> | Iterator<T>, compareBy?: (datum: T) => Comparable): Iterable<T>;
/**
* Iterate only the distinct elements from async collection.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param data
* @param compareBy
*/
export declare function distinctAsync<T>(data: AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>, compareBy?: (datum: T) => Comparable): AsyncIterable<T>;
/**
* Iterates the intersection of iterables using type coercion.
*
* If input iterables produce duplicate items, then multiset intersection rules apply.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param iterables
*/
export declare function intersection<T>(...iterables: Array<Iterable<T> | Iterator<T>>): Iterable<T>;
/**
* Iterates the intersection of async iterables using type coercion.
*
* If input iterables produce duplicate items, then multiset intersection rules apply.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param iterables
*/
export declare function intersectionAsync<T>(...iterables: Array<AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>>): AsyncIterable<T>;
/**
* Iterates partial intersection of iterables.
*
* If input iterables produce duplicate items, then multiset intersection rules apply.
* If `minIntersectionCount` is 1, then multiset union rules apply.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param minIntersectionCount
* @param iterables
*/
export declare function partialIntersection<T>(minIntersectionCount: number, ...iterables: Array<Iterable<T> | Iterator<T>>): Iterable<T>;
/**
* Iterates partial intersection of async iterables.
*
* If input iterables produce duplicate items, then multiset intersection rules apply.
* If `minIntersectionCount` is 1, then multiset union rules apply.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param minIntersectionCount
* @param iterables
*/
export declare function partialIntersectionAsync<T>(minIntersectionCount: number, ...iterables: Array<AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>>): AsyncIterable<T>;
/**
* Iterates the symmetric difference of iterables.
*
* If input iterables produce duplicate items, then multiset difference rules apply.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param iterables
*/
export declare function symmetricDifference<T>(...iterables: Array<Iterable<T> | Iterator<T>>): Iterable<T>;
/**
* Iterates the symmetric difference of async iterables.
*
* If input iterables produce duplicate items, then multiset difference rules apply.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param iterables
*/
export declare function symmetricDifferenceAsync<T>(...iterables: Array<AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>>): AsyncIterable<T>;
/**
* Iterates union of given iterables.
*
* If input iterables produce duplicate items, then multiset intersection rules apply.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param iterables
*/
export declare function union<T>(...iterables: Array<Iterable<T> | Iterator<T>>): Iterable<T>;
/**
* Iterates union of given async iterables.
*
* If input iterables produce duplicate items, then multiset intersection rules apply.
*
* Always treats different instances of objects and arrays as unequal.
*
* @param iterables
*/
export declare function unionAsync<T>(...iterables: Array<AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>>): AsyncIterable<T>;
/**
* Iterates cartesian product of given iterables.
*
* @param iterables
*
* @deprecated Use `combinatorics.cartesianProduct()` instead.
*/
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
*
* @deprecated Use `combinatorics.cartesianProductAsync()` instead.
*/
export declare function cartesianProductAsync<T extends Array<AsyncIterable<unknown> | AsyncIterator<unknown> | Iterable<unknown> | Iterator<unknown>>>(...iterables: T): AsyncIterable<ZipTuple<T, never>>;