/** * Some handy methods to create repeatable iterables. * ```js * // you can import _all_ of them: * import Enumerable from '@adamburgess/linq/enumerable' * // or just the one you want: * import { repeat } from '@adamburgess/linq/enumerable' * Array.from(repeat([1, 2], 3)) * // => [1, 2, 1, 2, 1, 2] * ``` * Best to import exactly what you need, as this can be tree-shooken. * @module */ /** Creates a repeatable iterable from a generator. */ export declare function createLazyGenerator(generator: () => Generator): Iterable; /** An empty iterable. */ export declare function empty(): Iterable; /** An iterable with _count_ numbers starting from _start_, counting up. */ export declare function range(start: number, count: number): Iterable; /** An iterable that repeats _input_ _count_ times. If _count_ is -1, repeat indefinitely. */ export declare function repeat(input: Iterable, count: number): Iterable; /** An iterable that reverses _input_. * * See {@link AnySequence.reverse} for examples. */ export declare function reverse(input: Iterable): Iterable; /** An iterable that maps each element of _input_ to another value with _convert_. * * See {@link AnySequence.map} for examples. */ export declare function map(input: Iterable, convert: (arg: T, index: number) => TOut): Iterable; /** An iterable that filters _input_ to only elements that are truthy in _predicate_. * * See {@link AnySequence.where} for examples. */ export declare function where(input: Iterable, predicate: (arg: T, index: number) => any): Iterable; /** Groups the input and returns a map. * * See {@link AnySequence.groupBy} for examples. */ export declare function groupByMap(input: Iterable, keySelector: (arg: T) => TKey): Map; export declare function groupByMap(input: Iterable, keySelector: (arg: T) => TKey, elementSelector: (arg: T) => TValue): Map; /** Groups the input into an iterable with the key and values. * * See {@link AnySequence.groupBy} for examples. */ export declare function groupBy(input: Iterable, keySelector: (arg: T) => TKey): Iterable<[TKey, T[]]>; export declare function groupBy(input: Iterable, keySelector: (arg: T) => TKey, elementSelector: (arg: T) => TValue): Iterable<[TKey, TValue[]]>; /** Takes X elements from input. * * See {@link AnySequence.take} for examples. */ export declare function take(input: Iterable, count: number): Iterable; /** Takes X elements from input while a predicate is true. * * See {@link AnySequence.takeWhile} for examples. */ export declare function takeWhile(input: Iterable, predicate: (arg: T) => boolean): Iterable; /** Skips X elements from input. * * See {@link AnySequence.skip} for examples. */ export declare function skip(input: Iterable, count: number): Iterable; /** Skips X elements from input while a predicate is true. * * See {@link AnySequence.skipWhile} for examples. */ export declare function skipWhile(input: Iterable, predicate: (arg: T) => boolean): Iterable; /** Concatenates two iterables together. * * See {@link AnySequence.append} and {@link AnySequence.prepend} for examples. */ export declare function concat(a: Iterable, b: Iterable): Iterable; /** Finds the distinct values in a sequence * * See {@link AnySequence.distinct} for examples. */ export declare function distinct(input: Iterable, keySelector?: (arg: T) => TKey): Iterable; /** Flattens a sequence. * * See {@link ArraySequence.flat} for examples. */ export declare function flat(input: Iterable>): Iterable; /** Finds the min of a number sequence * * See {@link NumberSequence.min} for examples. */ export declare function min(input: Iterable): number; /** Finds the max of a number sequence * * See {@link NumberSequence.max} for examples. */ export declare function max(input: Iterable): number; /** Finds the value of a sequence that is the min of a projected value. * * See {@link AnySequence.minBy} for more info. */ export declare function minBy(input: Iterable, selector: (arg: T) => number): T; /** Finds the value of a sequence that is the max of a projected value. * * See {@link AnySequence.maxBy} for more info. */ export declare function maxBy(input: Iterable, selector: (arg: T) => number): T; /** Finds the value of a sequence, or the value in the sequence, that is the min, or the max. * * Depending on the booleans at the end or if you pass a selector or not. */ export declare function byMin_byMax_min_max(input: Iterable, selector: ((arg: T) => number) | undefined, isMin: boolean, isBy: true): T; export declare function byMin_byMax_min_max(input: Iterable, selector: ((arg: T) => number) | undefined, isMin: boolean, isBy: false): number; declare const Enumerable: { empty: typeof empty; range: typeof range; repeat: typeof repeat; reverse: typeof reverse; map: typeof map; where: typeof where; groupBy: typeof groupBy; take: typeof take; takeWhile: typeof takeWhile; skip: typeof skip; skipWhile: typeof skipWhile; concat: typeof concat; distinct: typeof distinct; flat: typeof flat; min: typeof min; max: typeof max; minBy: typeof minBy; maxBy: typeof maxBy; byMin_byMax_min_max: typeof byMin_byMax_min_max; }; /** * @ignore */ export default Enumerable;