UNPKG

arx-level-generator

Version:
46 lines (45 loc) 2.07 kB
export declare const times: <T>(fn: (index: number) => T, repetitions: number) => T[]; export declare const repeat: <T>(value: T, repetitions: number) => T[]; export declare const min: (arr: number[]) => number; export declare const max: (arr: number[]) => number; export declare const sum: (numbers: number[]) => number; export declare const clone: <T>(data: T) => T; /** * @see https://stackoverflow.com/a/14438954/1806628 */ export declare const uniq: <T>(values: T[]) => T[]; export declare const last: <T>(values: T[]) => T | undefined; /** * The average of all given values by summing values then divide by the amount of values * * mean([2, 2, 3, 5, 5, 7, 8]) === 4.57 * because (2 + 2 + 3 + 5 + 5 + 7 + 8) / 7 === 4.57 */ export declare const mean: (values: number[]) => number; /** * Finds the middle number of a list. If the list has an even number of elements, * then it takes the middle 2 and averages them. * * median([2, 2, 3, 5, 5, 7, 8]) === 5 */ export declare const median: (values: number[]) => number; export declare const complement: (fn: (...args: any[]) => boolean) => (...args: any[]) => boolean; export declare const partition: <T>(fn: (arg: T) => boolean, values: T[]) => [T[], T[]]; export declare const countBy: <T>(fn: (value: T) => string, values: T[]) => Record<string, number>; /** * Groups the values of a given array of numbers into infos about the sequences inside * * @input [1, 2, 3, 5, 6, 7, 10] * @output [[1, 3], [5, 3], [10, 1]] * * This function is similar to ramda's groupWith((a, b) => a + 1 === b, numbers) * but instead of having the result as `[[1, 2, 3], [5, 6, 7], [10]]` * the function gives back pairs of the first number and the size of each sequence * * The function does not perform any sorting on the numbers: * `[20, 19, 1, 2, 18, 3]` will become `[[19, 2], [1, 2], [18, 1], [3, 1]]` * * The first number in each pair holds the smallest number of the sequence * The second number is the size of the sequence */ export declare const groupSequences: (numbers: number[]) => [number, number][];