UNPKG

@handy-common-utils/misc-utils

Version:
67 lines 2.65 kB
export declare class NumberUtils { /** * Constrains a number within specified bounds. * @param num The number to clamp * @param min The minimum value (inclusive) * @param max The maximum value (inclusive) * @returns The clamped value */ static clamp(num: number, min: number, max: number): number; /** * Checks if a number is within a specified range (inclusive). * @param num The number to check * @param min The minimum value * @param max The maximum value * @returns True if the number is within range */ static isInRange(num: number, min: number, max: number): boolean; /** * Rounds a number to a specified number of decimal places. * @param num The number to round * @param precision The number of decimal places (default: 0) * @returns Rounded number */ static roundTo(num: number, precision?: number): number; /** * Calculates the intersection between two ranges. * @param min1 Minimum value of the first range * @param max1 Maximum value of the first range * @param min2 Minimum value of the second range * @param max2 Maximum value of the second range * @returns The intersection as a tuple [min, max], or undefined if there is no intersection. */ static rangeIntersection(min1: number, max1: number, min2: number, max2: number): [number, number] | undefined; } /** * Constrains a number within specified bounds. * @param num The number to clamp * @param min The minimum value * @param max The maximum value * @returns The clamped value */ export declare const clamp: typeof NumberUtils.clamp; /** * Checks if a number is within a specified range (inclusive). * @param num The number to check * @param min The minimum value * @param max The maximum value * @returns True if the number is within range */ export declare const isInRange: typeof NumberUtils.isInRange; /** * Rounds a number to a specified number of decimal places. * @param num The number to round * @param precision The number of decimal places (default: 0) * @returns Rounded number */ export declare const roundTo: typeof NumberUtils.roundTo; /** * Calculates the intersection between two ranges. * @param min1 Minimum value of the first range * @param max1 Maximum value of the first range * @param min2 Minimum value of the second range * @param max2 Maximum value of the second range * @returns The intersection as a tuple [min, max], or undefined if there is no intersection. */ export declare const rangeIntersection: typeof NumberUtils.rangeIntersection; //# sourceMappingURL=number.d.ts.map