array.d.ts 1019 B

12345678910111213141516171819202122
  1. /**
  2. * Calls a defined callback function on each key:value of a object,
  3. * and returns a object contains the result.
  4. */
  5. export declare function mapObject<T, U>(object: Record<string, T>, callbackfn: (value: T, key?: string, object?: Record<string, T>) => U): Record<string, U>;
  6. export declare function indexOf<T>(array: T[]): number[];
  7. /**
  8. * @example [[1, 2, 3], ['a', 'b', 'c']] => [[1, 'a'], [2, 'b'], [3, 'c']]
  9. */
  10. export declare function transpose<T>(matrix: T[][]): T[][];
  11. export declare function firstOf<T>(array: T[]): T;
  12. export declare function lastOf<T>(array: T[]): T;
  13. export declare function isFlatArray<T>(array: (T | T[])[]): array is T[];
  14. export declare function unique<T>(array: T[]): T[];
  15. export 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. */
  22. export declare function combine<T>(array: T[]): T[][];