/** * Create a empty array. */ export declare const emptyArray: () => T[]; /** * Generate a array for specified length. * @param length The length of the array. * @param createItem The callback for generating each item via index. */ export declare const createArray: (length: number, createItem: (index: number) => T) => T[]; /** * Get the first item of the array. */ export declare const firstItem: (array: ArrayLike) => T | undefined; /** * Get the last item of the array. */ export declare const lastItem: (array: ArrayLike) => T | undefined; /** * Determine if two array are equal via determining whether each elements is equal * one by one through the strict equal `===`. * If there are non-primitive elements in the array, use `createArrayEqual` instead. */ export declare const arrayEqual: (arrayA: T[], arrayB: T[]) => boolean; /** * Create a check function to determine if two array ore equal in all elements. * @param equal The callback to determine whether two elements are equal or not. */ export declare function createArrayEqual(equal: (a: T, b: T) => boolean): (arrayA: T[], arrayB: T[]) => boolean; /** * De-duplicates the elements of the array and returns a new array. * If there are non-primitive elements in the array, use `createDeDupe` instead. */ export declare const deDupe: (array: T[]) => T[]; /** * Create a de-duplication function. The function de-duplicate the elements of the array * via the passing in callback `equal` to determine if the elements are equal, and then * a new array is returned. * @param equal The callback to determine whether two elements are equal or not. */ export declare function createDeDupe(equal: (a: T, b: T) => boolean): (array: T[]) => T[]; /** * De-duplicates the sub arrays of the 2D array via `arrayEqual` and returns a new array. * If there are non-primitive elements in the sub arrays, use `createDeDupe` instead. */ export declare const deDupe2D: (array: T[][]) => T[][]; /** * Determine if an array is the start part of another. * @returns If `arrayA` is the start part of `arrayB`, returns true, otherwise returns false. */ export declare const arrayMatch: (arrayA: T[], arrayB: T[]) => boolean; export declare const isArray2D: (value: unknown) => value is any[][]; /** * If pass in an array, return the array directly. * If pass in a single item, wrap it within a new array. * Ensure that a value that may be an array or a single item is always an array. * @param value An array or a single item. */ export declare const ensureArray: (value: T | T[]) => T[]; /** * Ensure that the value is always a 2D array, if not, wrap it within a new array. * @param value The array that may be 1D or 2D. */ export declare const ensureArray2D: (value: T[] | T[][]) => T[][]; declare enum Condition { Smaller = -1, Unlimited = 0, Bigger = 1 } /** * Find the nearest value of a number in an unordered array * @param arr The source array to find * @param num Target number * @param condition Search conditions, bigger, smaller, or unlimited * @returns The number of closest target in the array */ export declare const closestItem: (arr: number[], num: number, condition?: Condition) => number; export {}; //# sourceMappingURL=helpers.d.ts.map