import { Lifted, Pipe } from './lift'; import { Wrapper } from './wrapper'; import { MapWrapper } from './map'; import { SetWrapper } from './set'; /** An Array wrapper providing extra functionalities and more chaining opportunities */ export declare class ArrayWrapper> { private _value; constructor(_value: T); private _isLiftWrapper; value(): T; private _clone; /** * Appends one item at the end of the Array. */ append(item: T[number]): ArrayWrapper; /** * Appends an Iterable of items at the end of the Array. */ appendAll(items: Iterable): ArrayWrapper; /** * Filters all the falsy elements out of this Array. * All occurences of false, null, undefined, 0, "" will be removed. */ compact(): ArrayWrapper>>; /** * Counts the items satisfying a predicate. */ count(predicate: (item: T[number], index: number) => boolean): number; /** * Maps this Array's items, unless void or undefined is returned, in which case the item is filtered. * This is effectively a `filter` + `map` combined in one. */ collect(iterator: (item: T[number], index: number) => B | undefined | void): ArrayWrapper>; /** * Creates an array without any duplicate item. * If a key function is passed, items will be compared based on the result of that function; * if not, they will be compared using strict equality. */ distinct(getKey?: (item: T[number], index: number) => string | number): ArrayWrapper; /** * Drops the first 'count' items from this Array. */ drop(count: number): ArrayWrapper; /** * Drops the last 'count' items from this Array. */ dropRight(count: number): ArrayWrapper; /** * Filters this array by aplying a predicate to all items and refine its type. */ filter(predicate: (item: T[number], index: number) => item is A): ArrayWrapper>; /** * Filters this array by aplying a predicate. */ filter(predicate: (item: T[number], index: number) => boolean): ArrayWrapper; /** * Returns the first element in this Array or undefined. */ first(): T[number] | undefined; /** * Maps this Array to an Array of Array | ArrayWrapper using a mapper function then flattens it. */ flatMap>(fun: (item: T[number], index: number) => B): ArrayWrapper; /** * Maps this Array to an Array of Array | ArrayWrapper using a mapper function then flattens it. */ flatMap>(fun: (item: T[number], index: number) => ArrayWrapper): ArrayWrapper; /** * Flattens this Array of Arrays. */ flatten(this: ArrayWrapper>>): ArrayWrapper>; flatten(this: ArrayWrapper): ArrayWrapper>; /** * Reduces this Array into a single value, using a starting value. */ reduce(startValue: V, func: (acc: V, value: T[number], index: number) => V): Lifted; /** * Returns the item found at the provided index or undefined. */ get(index: number): T[number] | undefined; /** * Creates a Map where keys are the results of running each element through a discriminator function. * The corresponding value of each key is an array of the elements responsible for generating the key. */ groupBy(discriminator: (item: T[number], index: number) => K): MapWrapper>; /** * Creates a new Array where each sub array contains at most 'bySize' elements. */ grouped(bySize: number): ArrayWrapper; /** * Inserts an item at a specified index. */ insert(index: number, item: T[number]): ArrayWrapper; /** * Returns the item found at the last index or undefined. */ last(): T[number] | undefined; /** * Maps this Array using a mapper function. */ map(fun: (item: T[number], index: number) => B): ArrayWrapper>; /** * Removes the item found at the specified index. */ removeAt(index: number): ArrayWrapper; /** * Reverses the Array. */ reverse(): ArrayWrapper; /** * Sorts the Array in ascending order, using one or more iterators specifying which field to compare. * For strings, localCompare is used. * The sort is stable if the browser uses a stable sort (all modern engines do) */ sort(...fields: Array>): ArrayWrapper; /** * Takes the first 'count' items from this Array. */ take(count: number): ArrayWrapper; /** * Takes the last 'count' items from this Array. */ takeRight(count: number): ArrayWrapper; /** * Converts this Array to a Set. */ toSet(): SetWrapper>; /** * Updates an item at the specified index. */ updateAt(index: number, updater: (item: T[number]) => Wrapper): ArrayWrapper; /** * Updates an item at the specified index. */ updateAt(index: number, updater: (item: T[number]) => T[number]): ArrayWrapper; /** * Pipes this Array with an arbitrary transformation function. */ pipe: typeof import("./lift").pipe; } export declare function setArrayPipe(_pipe: Pipe): void; export declare function range(start: number, stop?: number, step?: number): ArrayWrapper>; declare type SortOnField = ((field: T) => string | null | undefined) | ((field: T) => number | null | undefined); declare type Compacted = T extends null | undefined | 0 | false ? never : T; declare type SetFromArray> = T extends Array ? Set : T extends ReadonlyArray ? ReadonlySet : never; declare type ArrayOf, ITEM> = T extends Array ? Array : ReadonlyArray; declare type MapFromArray, K, V> = T extends Array ? Map : ReadonlyMap; export {};