import { AsyncIteratorOrIterable, IteratorSlot } from '../types'; export declare class HAsyncIterator implements AsyncIterator { [IteratorSlot]: AsyncIterator; constructor(iterator?: AsyncIterator); static from(iterator: AsyncIterator): HAsyncIterator; static from(iterator: AsyncIterable): HAsyncIterator; static from(iterator: AsyncIterator | AsyncIterable): HAsyncIterator; next(val?: TNext): Promise>; throw(val?: any): Promise>; return(val?: TReturn): Promise>; /** Map each value of iterator to another value via {callback}. */ map(callback: (value: T) => R | PromiseLike): HAsyncIterator; static map(this: AsyncIterator, callback: (value: T) => R | PromiseLike): AsyncGenerator; /** Each value is given through {callback}, return `true` if value is needed into returned iterator. */ filter(callback: (value: T) => boolean | PromiseLike): HAsyncIterator; static filter(this: AsyncIterator, callback: (value: T) => boolean | PromiseLike): AsyncGenerator; /** Find a specific value that returns `true` in {callback}, and return it. Returns `undefined` otherwise. */ find(callback: (value: T) => boolean | PromiseLike): Promise; /** Return `true` if each value of iterator validate {callback}. */ every(callback: (value: T) => boolean | PromiseLike): Promise; /** Return `true` if one value of iterator validate {callback}. */ some(callback: (value: T) => boolean | PromiseLike): Promise; /** Consume iterator and collapse values inside an array. */ toArray(max_count?: number): Promise; /** Create a new iterator that consume {limit} items, then stops. */ take(limit: number): HAsyncIterator; static take(this: AsyncIterator, limit: number): AsyncGenerator; /** Create a new iterator that skip {limit} items from source iterator, then yield all values. */ drop(limit: number): HAsyncIterator; static drop(this: AsyncIterator, limit: number): AsyncGenerator; /** Get a pair [index, value] for each remaining value of iterable. */ asIndexedPairs(): HAsyncIterator<[number, T], TReturn, TNext>; static asIndexedPairs(this: AsyncIterator): AsyncGenerator<(number | T)[], any, unknown>; /** Like map, but you can return a new iterator that will be flattened. */ flatMap(mapper: (value: T) => AsyncIterator | R | PromiseLike> | PromiseLike): HAsyncIterator; static flatMap(this: AsyncIterator, mapper: (value: T) => AsyncIterator | R | PromiseLike> | PromiseLike): AsyncGenerator; /** Accumulate each item inside **acc** for each value **value**. */ reduce(reducer: (acc: V, value: T) => V | PromiseLike, initial_value?: V): Promise; /** Iterate over each value of iterator by calling **callback** for each value. */ forEach(callback: (value: T) => any | PromiseLike): Promise; /** Join all the remaining elements of the iterator in a single string with glue {glue}. */ join(string: string): Promise; /** End the iterator and return the number of remaining items. */ count(): Promise; /** Iterate through current iterator, then through the given iterators in the correct order. */ chain(...iterables: AsyncIteratorOrIterable[]): HAsyncIterator; static chain(this: AsyncIterableIterator, ...iterables: AsyncIteratorOrIterable[]): AsyncGenerator; /** Iterate through multiple iterators together. */ zip(other: AsyncIteratorOrIterable): HAsyncIterator<[T, O][], TReturn, TNext>; zip(...others: AsyncIteratorOrIterable[]): HAsyncIterator<(T | O)[], TReturn, TNext>; static zip(this: AsyncIteratorOrIterable, ...others: AsyncIteratorOrIterable[]): AsyncIterator<(T | O)[]>; /** Continue iterator until {callback} return a falsy value. */ takeWhile(callback: (value: T) => boolean | PromiseLike): HAsyncIterator; static takeWhile(this: AsyncIterator, callback: (value: T) => boolean | PromiseLike): AsyncGenerator; /** Skip elements until {callback} return a truthy value. */ dropWhile(callback: (value: T) => boolean | PromiseLike): HAsyncIterator; static dropWhile(this: AsyncIterator, callback: (value: T) => boolean | PromiseLike): AsyncGenerator; /** Continue iterator until `null` or `undefined` is encountered. */ fuse(): HAsyncIterator; static fuse(this: AsyncIterator): AsyncGenerator; /** Partition {true} elements to first array, {false} elements to second one. */ partition(callback: (value: T) => boolean | PromiseLike): Promise; /** Group by objects by key according to returned key for each object. */ groupBy(callback: (value: T) => K | PromiseLike): Promise<{ [Key in K]: T[]; }>; /** Index this iterator objects in a {Map} with key obtained through {keyGetter}. */ toIndexedItems(keyGetter: (value: T) => K | PromiseLike): Promise>; /** * Iterate over items present in both current collection and {otherItems} iterable. * **Warning**: This is a O(n*m) operation and this will consume {otherItems} iterator/iterable! */ intersection(otherItems: AsyncIteratorOrIterable, isSameItemCallback?: (value: T, other: O) => boolean | PromiseLike): HAsyncIterator; static intersection(this: AsyncIterator, otherItems: AsyncIteratorOrIterable, isSameItemCallback?: (value: T, other: O) => boolean | PromiseLike): AsyncGenerator; /** * Iterate over items present only in current collection, not in {otherItems} iterable. * **Warning**: This is a O(n*m) operation and this will consume {otherItems} iterator/iterable! */ difference(otherItems: AsyncIteratorOrIterable, isSameItemCallback?: (value: T, other: O) => boolean | PromiseLike): HAsyncIterator; static difference(this: AsyncIterator, otherItems: AsyncIteratorOrIterable, isSameItemCallback?: (value: T, other: O) => boolean | PromiseLike): AsyncGenerator; /** * Iterate over items present only in current collection or only in {otherItems} iterable, but not in both. * **Warning**: This is a O(n*m) operation and this will consume {otherItems} iterator/iterable! */ symmetricDifference(otherItems: AsyncIteratorOrIterable, isSameItemCallback?: (value: T, other: O) => boolean | PromiseLike): HAsyncIterator; static symmetricDifference(this: AsyncIterator, otherItems: AsyncIteratorOrIterable, isSameItemCallback?: (value: T, other: O) => boolean | PromiseLike): AsyncGenerator; /** Find the iterator index of the first element that returns a truthy value, -1 otherwise. */ findIndex(callback: (value: T) => boolean | PromiseLike): Promise; /** Only works if it is a number iterator. Returns the maximum of iterator. */ max(): Promise; /** Only works if it is a number iterator. Returns the minimum of iterator. */ min(): Promise; /** When iterator ends, go back to the first item then loop. Indefinitively. */ cycle(): HAsyncIterator; static cycle(this: AsyncIterator): AsyncGenerator; [Symbol.asyncIterator](): this; }