/** * Wrapper around `IterableIterator` interface * offering a set of helpers to deal with iterations in a simple way * * @public */ export declare class Stream implements IterableIterator { private readonly g; /** * Create an empty stream of T */ static nil(): Stream; /** * Create a Stream based on `g` * @param g - Underlying data of the Stream */ constructor(g: IterableIterator); next(): IteratorResult; [Symbol.iterator](): IterableIterator; /** * Map all elements of the Stream using `f` * * WARNING: It closes the current stream * * @param f - Mapper function */ map(f: (v: T) => U): Stream; /** * Flat map all elements of the Stream using `f` * * WARNING: It closes the current stream * * @param f - Mapper function */ flatMap(f: (v: T) => IterableIterator): Stream; /** * Drop elements from the Stream while `f(element) === true` * * WARNING: It closes the current stream * * @param f - Drop condition */ dropWhile(f: (v: T) => boolean): Stream; /** * Drop `n` first elements of the Stream * * WARNING: It closes the current stream * * @param n - Number of elements to drop */ drop(n: number): Stream; /** * Take elements from the Stream while `f(element) === true` * * WARNING: It closes the current stream * * @param f - Take condition */ takeWhile(f: (v: T) => boolean): Stream; /** * Take `n` first elements of the Stream * * WARNING: It closes the current stream * * @param n - Number of elements to take */ take(n: number): Stream; /** * Filter elements of the Stream * * WARNING: It closes the current stream * * @param f - Elements to keep */ filter(f: (v: T) => v is U): Stream; /** * Filter elements of the Stream * * WARNING: It closes the current stream * * @param f - Elements to keep */ filter(f: (v: T) => boolean): Stream; /** * Check whether all elements of the Stream are successful for `f` * * WARNING: It closes the current stream * * @param f - Condition to check */ every(f: (v: T) => boolean): boolean; /** * Check whether one of the elements of the Stream is successful for `f` * * WARNING: It closes the current stream * * @param f - Condition to check */ has(f: (v: T) => boolean): [boolean, T | null]; /** * Join `others` Stream to the current Stream * * WARNING: It closes the current stream and the other ones (as soon as it iterates over them) * * @param others - Streams to join to the current Stream */ join(...others: IterableIterator[]): Stream; /** * Take the `nth` element of the Stream of the last (if it does not exist) * * WARNING: It closes the current stream * * @param nth - Position of the element to extract */ getNthOrLast(nth: number): T | null; } /** * Create a Stream based on `g` * * @param g - Underlying data of the Stream * * @public */ export declare function stream(g: IterableIterator): Stream;