export type PlainObject = { [key: string]: AnyValue; }; export type AnyValue = unknown; export type Constructor = { new (...args: ReadonlyArray): T; }; export declare function flatMap(arr: ReadonlyArray, f: (t: TIn) => ReadonlyArray): ReadonlyArray; /** * Maps an array and returns the first defined result. Undefined elements in array will be ignored. * @param {ReadonlyArray} array. * @param {(t: TIn) => TOut} fn * @returns TOut|undefined */ export declare function mapFirstDefined(array: ReadonlyArray, fn: (t: TIn) => TOut): NonNullable | undefined; export declare function flatten(arr: ReadonlyArray>): ReadonlyArray; /** * Check if {array} starts with {start} * @param {ReadonlyArray} array * @param {ReadonlyArray} start * @returns {boolean} */ export declare function arrayStartsWith(array: ReadonlyArray, start: ReadonlyArray): boolean; export declare function capitalize(string: string): string; export declare function decapitalize(string: string): string; /** * Groups items in an array by common keys * @param items the input items * @param keyFn a function that computes the key value of an item * @returns {Map>} a map from key values to the list of items that have that key */ export declare function groupArray(items: ReadonlyArray, keyFn: (item: TItem) => TKey): Map>; export declare const INDENTATION = " "; /** * Indents each line of a string with a given indentation * @param input the string to indent * @param indentation the prefix to put in front of each line * @returns the indented string */ export declare function indent(input: string, indentation?: string | number): string; /** * Creates an array of the form [0, 1, 2, ..., count-1] * * @param count the number of items for the array * @returns the array */ export declare function range(count: number): ReadonlyArray; /** * Takes a random sample of an array * @param arr the source population * @returns the sampled item, or undefined if the input array is empty */ export declare function takeRandomSample(arr: ReadonlyArray): T | undefined; export declare function arrayToObject(array: ReadonlyArray, keyFn: (item: TValue, index: number) => string): { [name: string]: TValue; }; export declare function compact(arr: ReadonlyArray): ReadonlyArray; export declare function objectValues(obj: { [name: string]: T; }): ReadonlyArray; export declare function objectEntries(obj: { [name: string]: T; }): [string, T][]; export declare function mapValues(obj: { [key: string]: TIn; }, fn: (value: TIn, key: string) => TOut): { [key: string]: TOut; }; export declare function mapValues(map: Map, fn: (value: TIn, key: TKey) => TOut): Map; export declare function sleep(ms: number): Promise; /** * Gets a promise that resolves with `true` after a specified time, except when a cancellation promise fires first, then * it resolves with `false`. * * If the cancellation token is rejected, the sleep continues as normal. * * @param ms the sleep time in milliseconds * @param cancellationToken a promise that should be resolved to cancel the timeout */ export declare function sleepInterruptible(ms: number, cancellationToken: Promise | undefined): Promise; export declare let escapeRegExp: (input: string) => string; export declare function isPromise(value: any): value is Promise; export declare function joinWithAnd(items: ReadonlyArray): string; /** * Checks if a value is an array using Array.isArray() * * The runtime behavior is identical to Array.is.Array(), but it fixes a shortcoming of TypeScript if the * passed value is a union of a readonly array and something else. Array.isArray() would narrow the value * to Array instead of ReadonlyArray (see https://github.com/microsoft/TypeScript/issues/17002). */ export declare function isReadonlyArray(obj: unknown | ReadonlyArray): obj is ReadonlyArray;