UNPKG

1.02 kBTypeScriptView Raw
1/**
2 * Calls a defined callback function on each key:value of a object,
3 * and returns a object contains the result.
4 */
5export declare function mapObject<T, U>(object: Record<string, T>, callbackfn: (value: T, key?: string, object?: Record<string, T>) => U): Record<string, U>;
6export declare function indexOf<T>(array: T[]): number[];
7/**
8 * @example [[1, 2, 3], ['a', 'b', 'c']] => [[1, 'a'], [2, 'b'], [3, 'c']]
9 */
10export declare function transpose<T>(matrix: T[][]): T[][];
11export declare function firstOf<T>(array: T[]): T;
12export declare function lastOf<T>(array: T[]): T;
13export declare function isFlatArray<T>(array: (T | T[])[]): array is T[];
14export declare function unique<T>(array: T[]): T[];
15export declare function divide<T>(array: T[], callbackfn: (item: T) => boolean): [T[], T[]];
16/**
17 * get all combinations of two elements in an array
18 * @example [1, 2, 3] => [[1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]
19 * @param array
20 * @returns
21 */
22export declare function combine<T>(array: T[]): T[][];