/** * Number-focused utility helpers. * * @module bquery/core/utils/number */ /** * Generates a random integer between min and max (inclusive). * * @param min - Minimum value * @param max - Maximum value * @returns A random integer in the range [min, max] * * @example * ```ts * const roll = randomInt(1, 6); // Random dice roll * ``` */ export declare function randomInt(min: number, max: number): number; /** * Clamps a number between a minimum and maximum value. * * @param value - The value to clamp * @param min - Minimum value * @param max - Maximum value * @returns The clamped value * * @example * ```ts * clamp(150, 0, 100); // 100 * clamp(-10, 0, 100); // 0 * clamp(50, 0, 100); // 50 * ``` */ export declare function clamp(value: number, min: number, max: number): number; /** * Checks if a number is within a range. * * @param value - The value to check * @param min - Minimum value * @param max - Maximum value * @param inclusive - Whether the range is inclusive (default: true) * @returns True if the value is within the range * * @example * ```ts * inRange(5, 1, 10); // true * inRange(10, 1, 10, false); // false * ``` */ export declare function inRange(value: number, min: number, max: number, inclusive?: boolean): boolean; /** * Converts a value to a number with a fallback on NaN. * * @param value - The value to convert * @param fallback - The fallback value if conversion fails (default: 0) * @returns The parsed number or the fallback * * @example * ```ts * toNumber('42'); // 42 * toNumber('nope', 10); // 10 * ``` */ export declare function toNumber(value: unknown, fallback?: number): number; /** * Rounds `value` to `precision` decimal places (default: 0). * * @example * ```ts * round(1.2345, 2); // 1.23 * round(1234.5); // 1235 * ``` */ export declare function round(value: number, precision?: number): number; /** * Rounds `value` to the nearest multiple of `step`. * * @example * ```ts * roundTo(13, 5); // 15 * roundTo(0.27, 0.05); // 0.25 * ``` */ export declare function roundTo(value: number, step: number): number; /** * Linear interpolation between `a` and `b` by `t` (typically in `[0, 1]`). */ export declare function lerp(a: number, b: number, t: number): number; /** * Inverse of {@link lerp}: returns `t` such that `lerp(a, b, t) === value`. * Returns `0` when `a === b`. */ export declare function inverseLerp(a: number, b: number, value: number): number; /** * Re-maps `value` from the range `[inMin, inMax]` to `[outMin, outMax]`. */ export declare function mapRange(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number; /** Options for {@link formatBytes}. */ export interface FormatBytesOptions { /** Number of decimal places (default: 2). */ decimals?: number; /** Use binary base (1024) instead of decimal (1000). Default: false. */ binary?: boolean; /** Optional locale used for the numeric portion. */ locale?: string | string[]; } /** * Formats a byte count as a human-readable string. * * @example * ```ts * formatBytes(1500); // '1.50 KB' * formatBytes(1024, { binary: true }); // '1.00 KiB' * ``` */ export declare function formatBytes(bytes: number, opts?: FormatBytesOptions): string; /** * Returns a random floating-point number in the half-open interval * `[min, max)`. Uses `Math.random()` — not cryptographically secure. */ export declare function randomFloat(min: number, max: number): number; /** Returns the arithmetic sum of an array of numbers. */ export declare function sum(items: readonly number[]): number; /** * Returns the arithmetic mean of an array. Returns `0` for empty arrays. */ export declare function average(items: readonly number[]): number; /** * Returns the median of an array. Returns `0` for empty arrays. For * even-length arrays the median is the average of the two central values. */ export declare function median(items: readonly number[]): number; /** Converts an angle in degrees to radians. */ export declare function degToRad(degrees: number): number; /** Converts an angle in radians to degrees. */ export declare function radToDeg(radians: number): number; //# sourceMappingURL=number.d.ts.map