import type { TransformRangeOptions } from './type.js'; export { UnicodeDigits, type UnicodeLangKeys } from './unicode-digits.js'; /** * Check the value is number or can convert to a number, for example string ' 123 ' can be converted to 123 * * @param {unknown} value - the value must check numberic. * @return {boolean} - is number status. */ export declare function isNumber(value: unknown): boolean; /** * Transform a number from one range to another. * * Example: * * ```ts * transformToRange(5, {in: [0, 10], out: [0, 100]}); // => 50 * ``` * * Make percentage of any value * * ```ts * transformToRange(2000, {in: [0, 5000], out: [0, 100]}); // => 40 * ``` * * Calculate progress-bar with * * ```ts * const progressOuterWith = 400; //px * const gap = 5; //px (the visual gap between progressBar and component outer). * const currentProgress = 30; //% * * const progressBarWith = transformToRange(currentProgress, { * in: [0, 100], * out: [componentPadding, progressOuterWith - componentPadding], * bound: true, * }); * * this.progressBar.style.width = `${progressBarWith}px`; * ``` */ export declare function transformToRange(x: number, options: TransformRangeOptions): number; export declare const random: { /** * Returns a float random number between 0 and 1 (1 Not included). * * Example: * * ```js * console.log(random.number); // 0.7124123 * ``` */ readonly number: number; /** * Generate a random integer number between min and max (max included). * * Example: * * ```js * console.log(random.integer(1, 10)); // somewhere between 1 and 10 * ``` */ readonly integer: (min: number, max: number) => number; /** * Generate a random float number between min and max (max not included). * * Example: * * ```js * console.log(random.float(1, 10)); // somewhere between 1 and 10 * ``` */ readonly float: (min: number, max: number) => number; /** * Generate a random string with random length. * The string will contain only characters from the characters list. * The length of the string will be between min and max (max included). * If max not specified, the length will be set to min. * * Example: * *```js * console.log(random.string(6)); // something like 'Aab1V2' * ``` */ readonly string: (min: number, max?: number) => string; /** * Generate a random integer between min and max with a step. * * Example: * * ```js * console.log(random.step(6, 10, 2)); // 6 or 8 or 10 * ``` */ readonly step: (min: number, max: number, step: number) => number; /** * Shuffle an array. * * Example: * * ```js * const array = [1, 2, 3, 4, 5]; * random.shuffle(array); * console.log(array); // [2, 4, 3, 1, 5] * ``` */ readonly shuffle: (array: T[]) => T[]; readonly getRandomValues: (array: T_1) => T_1; /** * Generate Random UUID. * * Example: * * ```ts * console.log(random.uuid); * ``` */ readonly uuid: `${string}-${string}-${string}-${string}-${string}`; }; export type DurationUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'M' | 'y'; export type DurationString = `${number}${DurationUnit}`; /** * Parse duration string to target unit. * * Example: * * ```js * parseDuration('10s'); // 10,000 * parseDuration('10m'); // 600,000 * parseDuration('10h'); // 36,000,000 * parseDuration('10d'); // 864,000,000 * parseDuration('10w'); // 6,048,000,000 * parseDuration('10M'); // 25,920,000,000 * parseDuration('10y'); // 315,360,000,000 * parseDuration('10d', 'h'); // 240 * ``` */ export declare const parseDuration: (duration: DurationString, toUnit?: DurationUnit | 'ms') => number; /** * Limit number in range (min, max). */ export declare const clamp: (val: number, min: number, max: number) => number; export declare const hex: (bytes: Uint8Array) => string; export declare const calcDiscount: (marketPrice: number, salePrice: number, decimal?: number, upSide?: boolean) => number; export declare const simpleHashNumber: (num: number) => string; //# sourceMappingURL=math.d.ts.map