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