UNPKG

@cute-dw/core

Version:

This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need

48 lines (47 loc) 2.16 kB
/** * This class consists exclusively of the static methods that operate on or return numeric values */ export declare class Numbers { private static readonly ROUND_PRECISION; /** * Rounds a number to the specified number of decimal places * @param value The number you want to round * @param ndec The number of decimal places to which you want to round a `value`. Default is 0. * @returns The result of the roundation if it succeeds and _NaN_ if it fails or if any argument is _NaN_ * @example * Number.round(2.5724, 3); // 2.572 * Number.round(1.005, 2); // 1.01 * Number.round(12345, -2); // 12300 */ static round(value: number, ndec?: number): number; /** * Truncates a number to the specified number of decimal places * @param value The number you want to truncate * @param ndec The number of decimal places to which you want to truncate a `value`. Default is 0. * @returns The result of the truncation if it succeeds and _NaN_ if it fails or if any argument is _NaN_ */ static truncate(value: number, ndec?: number): number; /** * Gets the fraction part of the `value` * @param value Source value * @param roundTo Optional number of decimal places to round * @returns Fraction value */ static fraction(value: number, roundTo?: number): number; /** * Checks the specified value for `NaN` and returns this value if the result of testing is falsy or another value when else. * @param v1 Value to check * @param v2 Value to return if `v1` is `NaN` * @returns `v1` itself if `v1` is a finite number or `v2` if it is a `NaN` */ static ifNaN(v1: any, v2: any): any; /** * Return whether the provided value is in the range of the two specified values * * @param value The value to test. * @param lowBound Low boundary's value * @param uppBound Upper boundary's value * @returns Boolean value, or _null_ if error occurs */ static inRange(value: number, lowBound: number, uppBound: number): boolean | null; }