import { IDisposable } from './disposable'; import { ISplice } from './sequence'; export declare function asStringArray(array: unknown, defaultValue: string[]): string[]; export declare function isNonEmptyArray(obj: ReadonlyArray | undefined | null): obj is Array; /** * 移除给定数组中的重复值 * keyFn函数支持指定校验逻辑 */ export declare function distinct(array: ReadonlyArray, keyFn?: (t: T) => string): T[]; /** * Diffs two *sorted* arrays and computes the splices which apply the diff. */ export declare function sortedDiff(before: ReadonlyArray, after: ReadonlyArray, compare: (a: T, b: T) => number): ISplice[]; export declare function equals(one: ReadonlyArray | undefined, other: ReadonlyArray | undefined, itemEquals?: (a: T, b: T) => boolean): boolean; export declare function asArray(x: T | T[]): T[]; export declare function asArray(x: T | readonly T[]): readonly T[]; /** * 获取非空数组 * @param array */ export declare function coalesce(array: ReadonlyArray): T[]; export declare function addElement(array: Array, element: T, unshift?: boolean): IDisposable; export declare function addMapElement(map: Map, key: K, element: T): IDisposable; type NonFunctional = T extends Function ? never : T; export declare function enumValueToArray(enumeration: T): NonFunctional[]; /** * @returns false if the provided object is an array and not empty. */ export declare function isFalsyOrEmpty(obj: any): boolean; export declare function flatten(arr: T[][]): T[]; export declare function range(to: number): number[]; export declare function fill(num: number, value: T, arr?: T[]): T[]; /** * Takes a sorted array and a function p. The array is sorted in such a way that all elements where p(x) is false * are located before all elements where p(x) is true. * @returns the least x for which p(x) is true or array.length if no element fullfills the given function. */ export declare function findFirstInSorted(array: ReadonlyArray, p: (x: T) => boolean): number; type Compare = (a: T, b: T) => number; /** * Like `Array#sort` but always stable. Usually runs a little slower `than Array#sort` * so only use this when actually needing stable sort. */ export declare function mergeSort(data: T[], compare: Compare): T[]; /** * Returns the first mapped value of the array which is not undefined. */ export declare function mapFind(array: Iterable, mapFn: (value: T) => R | undefined): R | undefined; export declare function groupBy(data: ReadonlyArray, compare: (a: T, b: T) => number): T[][]; export {}; //# sourceMappingURL=arrays.d.ts.map