array.d.ts 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. export declare function firstExistingValue<A>(...values: A[]): A | null;
  2. /** @deprecated */
  3. export declare function anyExists(values: any[]): boolean;
  4. export declare function existsAndNotEmpty<T>(value?: T[]): boolean;
  5. export declare function last<T>(arr: T[]): T | undefined;
  6. export declare function areEqual<T>(a: T[], b: T[], comparator?: (a: T, b: T) => boolean): boolean;
  7. /** @deprecated */
  8. export declare function compareArrays(array1?: any[], array2?: any[]): boolean;
  9. /** @deprecated */
  10. export declare function shallowCompare(arr1: any[], arr2: any[]): boolean;
  11. export declare function sortNumerically(array: number[]): number[];
  12. export declare function removeRepeatsFromArray<T>(array: T[], object: T): void;
  13. export declare function removeFromArray<T>(array: T[], object: T): void;
  14. export declare function removeAllFromArray<T>(array: T[], toRemove: T[]): void;
  15. export declare function insertIntoArray<T>(array: T[], object: T, toIndex: number): void;
  16. export declare function insertArrayIntoArray<T>(dest: T[], src: T[], toIndex: number): void;
  17. export declare function moveInArray<T>(array: T[], objectsToMove: T[], toIndex: number): void;
  18. export declare function includes<T>(array: T[], value: T): boolean;
  19. export declare function flatten(arrayOfArrays: any[]): any[];
  20. export declare function pushAll<T>(target: T[], source: T[]): void;
  21. export declare function toStrings<T>(array: T[]): (string | null)[];
  22. export declare function findIndex<T>(collection: T[], predicate: (item: T, idx: number, collection: T[]) => boolean): number;
  23. /**
  24. * The implementation of Array.prototype.every in browsers is always slower than just using a simple for loop, so
  25. * use this for improved performance.
  26. * https://jsbench.me/bek91dtit8/
  27. */
  28. export declare function every<T>(list: T[], predicate: (value: T, index: number) => boolean): boolean;
  29. /**
  30. * The implementation of Array.prototype.some in browsers is always slower than just using a simple for loop, so
  31. * use this for improved performance.
  32. * https://jsbench.me/5dk91e4tmt/
  33. */
  34. export declare function some<T>(list: T[], predicate: (value: T, index: number) => boolean): boolean;
  35. /**
  36. * The implementation of Array.prototype.forEach in browsers is often slower than just using a simple for loop, so
  37. * use this for improved performance.
  38. * https://jsbench.me/apk91elt8a/
  39. */
  40. export declare function forEach<T>(list: T[], action: (value: T, index: number) => void): void;
  41. /**
  42. * The implementation of Array.prototype.map in browsers is generally the same as just using a simple for loop. However,
  43. * Firefox does exhibit some difference, and this performs no worse in other browsers, so use this if you want improved
  44. * performance.
  45. * https://jsbench.me/njk91ez8pc/
  46. */
  47. export declare function map<T, V>(list: T[], process: (value: T, index: number) => V): V[];
  48. /**
  49. * The implementation of Array.prototype.filter in browsers is always slower than just using a simple for loop, so
  50. * use this for improved performance.
  51. * https://jsbench.me/7bk91fk08c/
  52. */
  53. export declare function filter<T>(list: T[], predicate: (value: T, index: number) => boolean): T[];
  54. /**
  55. * The implementation of Array.prototype.reduce in browsers is generally the same as just using a simple for loop. However,
  56. * Chrome does exhibit some difference, and this performs no worse in other browsers, so use this if you want improved
  57. * performance.
  58. * https://jsbench.me/7vk92n6u1f/
  59. */
  60. export declare function reduce<T, V>(list: T[], step: (acc: V, value: T, index: number) => V, initial: V): V;
  61. /** @deprecated */
  62. export declare function forEachSnapshotFirst<T>(list: T[], callback: (item: T) => void): void;