UNPKG

dash-core

Version:

A foundational toolkit of types, collections, services, and architectural patterns designed to accelerate application development.

38 lines (37 loc) 2.15 kB
/** * The `Mathf` class provides static utility methods for common mathematical operations. */ export declare class Mathf { /** * Clamps a value within the specified range. * @param {number} value - The value to clamp. * @param {number} min - The minimum allowable value. * @param {number} max - The maximum allowable value. * @returns {number} The clamped value, which is within the specified range [min, max]. */ static clamp(value: number, min: number, max: number): number; /** * Linearly interpolates between two values based on the interpolation factor. * @param {number} a - The start value. * @param {number} b - The end value. * @param {number} t - The interpolation factor (should be between 0 and 1). * @returns {number} The interpolated value, calculated as a + (b - a) * t. */ static lerp(a: number, b: number, t: number): number; /** * Finds the maximum element in an iterable based on a selector function. * The selector function is used to extract the value that will be compared. * @param {Iterable<TType>} array - The iterable collection to search through. * @param {(item: TType) => number} selector - A function that extracts a numerical value from each item. * @returns {TType | undefined} The item with the highest value according to the selector function, or `undefined` if the iterable is empty. */ static max<TType>(array: Iterable<TType>, selector: (item: TType) => number): TType | undefined; /** * Finds the minimum element in an iterable based on a selector function. * The selector function is used to extract the value that will be compared. * @param {Iterable<TType>} array - The iterable collection to search through. * @param {(item: TType) => number} selector - A function that extracts a numerical value from each item. * @returns {TType | undefined} The item with the lowest value according to the selector function, or `undefined` if the iterable is empty. */ static min<TType>(array: Iterable<TType>, selector: (item: TType) => number): TType | undefined; }