UNPKG

@irysius/grid-math

Version:

Tools to assist with grid math and algorithms

31 lines 1.88 kB
declare module "@irysius/grid-math/helpers/Iterable" { export interface ISlidingWindowOptions { prevCapacity: number; nextCapacity: number; } export interface ISlidingWindow<T> { next(): { value: T; done: boolean; }; [Symbol.iterator](): this; readonly prevValues: T[]; readonly currValue: T; readonly nextValues: T[]; readonly done: boolean; } export function SlidingWindow<T>(collection: IterableIterator<T>, options: ISlidingWindowOptions): ISlidingWindow<T>; export function isIterator<T = any>(value: any): value is IterableIterator<T>; export type Mapper<T, U> = (item?: T, collection?: IterableIterator<T>) => U; export function map<T, U>(mapper: Mapper<T, U>): (collection: IterableIterator<T>) => IterableIterator<U>; export function flatten(): <T>(collection: IterableIterator<T | IterableIterator<T>>) => IterableIterator<T>; export type Filterer<T> = (item?: T, collection?: IterableIterator<T>) => boolean; export function filter<T>(filterer: Filterer<T>): (collection: IterableIterator<T>) => IterableIterator<T>; export function zip<A, B>(collectionA: IterableIterator<A>, collectionB: IterableIterator<B>): IterableIterator<[A, B]>; export type IteratorPipe = (x: IterableIterator<any>) => IterableIterator<any>; export function flow<A = any, Z = any>(...pipes: IteratorPipe[]): (collection: IterableIterator<A>) => IterableIterator<Z>; export function skip(count: number): <T>(collection: IterableIterator<T>) => void; export function take(count: number): <T>(collection: IterableIterator<T>) => T[]; export function skipTake(_skip: number, _take: number): <T>(collection: IterableIterator<T>) => T[]; export function fromArray<T>(items: T[]): IterableIterator<T>; }