interface Mapper { (x: T): U; } interface FlatMapper { (x: T): Iterable; } interface Predicate { (x: T): boolean; } interface Guard { (a: T): a is U; } interface Reducer { (acc: U, x: T): U; } interface Collector { from: (i: Iterable) => U; } /** * Useful operators for Iterables. * * The module exports the class `Seq` which creates a wrapper that exposes * a fluent interface for traversing and manipulating the underlying iterable * object using operators. * * The module also exports each operator as a function for use in isolation. * * All methods and functions return a new Iterable object. Iteration is lazy * and will only execute when a value is requested (toArray, reduce, etc). * The iteration will terminate as early as possible. * * For example, the following `Seq` code will only iterate 3 times: * * let array = []; * for (let i = 1; i <= 1000; i++) { * array.push(i); * } * * // 3 iterations * Seq.from(array) * .map(n => n * n) * .filter(n => n % 2 === 1) * .takeUntil(n => n > 30) * .toArray() // [ 1, 9, 25 ] * */ /** * Wraps `iterable` in an object with collection operations. */ export declare class Seq { private _iterable; private static readonly EMPTY; static empty(): Seq; static of(...values: T[]): Seq; static from(iterable: Iterable): Seq; static concat(...iterables: Iterable[]): Seq; private _iterator?; private readonly _cache; private constructor(); [Symbol.iterator](): Generator; concat(...iterables: Iterable[]): Seq; map(fn: Mapper): Seq; flatMap(fn: FlatMapper): Seq; uniq(): Seq; uniqBy(fn: Mapper): Seq; orderBy(fn: Mapper, reverse?: boolean): Seq; filter(fn: Guard): Seq; filter(fn: Predicate): Seq; take(n: number): Seq; takeLast(n: number): Seq; takeWhile(fn: Guard): Seq; takeWhile(fn: Predicate): Seq; drop(n: number): Seq; dropLast(n: number): Seq; dropWhile(fn: Guard): Seq; dropWhile(fn: Predicate): Seq; find(fn: Guard): U; find(fn: Predicate): T; findLast(fn: Guard): U; findLast(fn: Predicate): T; every(fn: Predicate): boolean; some(fn: Predicate): boolean; includes(item: T): boolean; reduce(fn: Reducer, value: U): U; join(separator: string): string; toArray(): T[]; into(Collector: Collector): U; first(): any; last(): any; rest(): Generator; isEmpty(): boolean; forEach(fn: (t: T) => void): this; groupBy(fn: (t: T) => S): Seq<[S, T[]]>; } export declare function concat(...iterables: Iterable[]): Generator; export declare function map(fn: Mapper, iterable: Iterable): Generator; export declare function flatMap(fn: FlatMapper, iterable: Iterable): Generator; export declare function uniq(iterable: Iterable): Generator; export declare function uniqBy(fn: Mapper, iterable: Iterable): Generator; export declare function filter(fn: Guard, iterable: Iterable): Iterable; export declare function filter(fn: Predicate, iterable: Iterable): Iterable; export declare function take(n: number, iterable: Iterable): Generator; /** * Take the last `n` elements of `iterable` */ export declare function takeLast(n: number, iterable: Iterable): Generator; /** * Keep items until test returns false. */ export declare function takeWhile(fn: Guard, iterable: Iterable): Iterable; export declare function takeWhile(fn: Predicate, iterable: Iterable): Iterable; export declare function drop(n: number, iterable: Iterable): Generator; export declare function dropLast(n: number, iterable: Iterable): Generator; /** * Ignore items until test returns false. */ export declare function dropWhile(fn: Guard, iterable: Iterable): Iterable; export declare function dropWhile(fn: Predicate, iterable: Iterable): Iterable; /** * Find the first item that test returns true for. */ export declare function find(test: Guard, iterable: Iterable): U; export declare function find(test: Predicate, iterable: Iterable): T; /** * Find the last item that the test returns true for. */ export declare function findLast(test: Guard, iterable: Iterable): U; export declare function findLast(test: Predicate, iterable: Iterable): T; export declare function first(iterable: Iterable): any; export declare function last(iterable: Iterable): void | T; export declare function rest(iterable: Iterable): Generator; export declare function includes(item: T, iterable: Iterable): boolean; export declare function every(test: Predicate, iterable: Iterable): boolean; export declare function some(test: Predicate, iterable: Iterable): boolean; /** * Reduce collection to a single value. */ export declare function reduce(fn: Reducer, seedValue: U, iterable: Iterable): U; export declare function join(separator: string, iterable: Iterable): string; export {}; //# sourceMappingURL=IterableUtils.d.ts.map