/** * Abbreviates large numbers with appropriate suffixes (K, M, B, T, etc.). * * Converts numbers to abbreviated format using standard suffixes: * - K for thousands (1,000+) * - M for millions (1,000,000+) * - B for billions (1,000,000,000+) * - T for trillions (1,000,000,000,000+) * * @param num - The number to abbreviate * @returns The abbreviated number string with appropriate suffix * * @example * ```typescript * abbreviate(1000) // "1K" * abbreviate(1500) // "1.5K" * abbreviate(1000000) // "1M" * abbreviate(2500000) // "2.5M" * abbreviate(999) // "999" * ``` */ declare function abbreviate(num: number): string; /** * Clamps a number between minimum and maximum values. * * Ensures that the input number falls within the specified range. * If the number is below the minimum, returns the minimum. * If the number is above the maximum, returns the maximum. * Otherwise, returns the original number. * * @param num - The number to clamp * @param min - The minimum allowed value * @param max - The maximum allowed value * @returns The clamped number within the specified range * * @example * ```typescript * clamp(5, 1, 10) // 5 * clamp(-5, 1, 10) // 1 * clamp(15, 1, 10) // 10 * clamp(7.5, 0, 5) // 5 * ``` */ declare function clamp(num: number, min: number, max: number): number; /** * Formats a number as currency with proper locale formatting. * * Converts a numeric value to a formatted currency string using * the browser's Intl.NumberFormat API. Supports different currencies * and uses appropriate locale-specific formatting. * * @param num - The number to format as currency * @param currency - The currency code (ISO 4217) to use for formatting * @returns The formatted currency string * * @example * ```typescript * currencyFormat(1234.56) // "$1,234.56" (in USD) * currencyFormat(1234.56, 'EUR') // "€1,234.56" (in EUR) * currencyFormat(1000, 'GBP') // "£1,000.00" (in GBP) * currencyFormat(0) // "$0.00" * ``` */ declare function currencyFormat(num: number, currency?: string): string; /** * Formats a number of bytes into a human-readable file size string. * * Converts byte values to appropriate units (B, KB, MB, GB, TB, PB, EB, ZB, YB) * with proper decimal formatting. Uses binary (1024) units for conversion. * * @param num - The number of bytes to format * @returns The formatted file size string with appropriate unit * * @example * ```typescript * fileSize(1024) // "1 KB" * fileSize(1536) // "1.5 KB" * fileSize(1048576) // "1 MB" * fileSize(500) // "500 B" * fileSize(0) // "0 B" * ``` */ declare function fileSize(num: number): string; /** * Formats a number with specified decimal places and thousands separators. * * Converts a number to a string with the specified number of decimal places * and includes thousands separators for better readability. * * @param num - The number to format * @param decimalPlaces - The number of decimal places to show (default: 2) * @returns The formatted number string with separators * * @example * ```typescript * format(1234.5678) // "1,234.57" * format(1234.5678, 1) // "1,234.6" * format(1000000) // "1,000,000.00" * format(42, 0) // "42" * ``` */ declare function format(num: number, decimalPlaces?: number): string; /** * Converts a number to its ordinal string representation. * * Adds the appropriate ordinal suffix (st, nd, rd, th) to a number * based on English ordinal number rules. * * @param num - The number to convert to ordinal form * @returns The ordinal string representation of the number * * @example * ```typescript * ordinal(1) // "1st" * ordinal(2) // "2nd" * ordinal(3) // "3rd" * ordinal(4) // "4th" * ordinal(21) // "21st" * ordinal(22) // "22nd" * ordinal(23) // "23rd" * ordinal(101) // "101st" * ``` */ declare function ordinal(num: number): string; /** * Parses a string or number to extract a numeric value. * * Attempts to parse a string representation of a number or return * the numeric value if already a number. Returns undefined if the * input cannot be parsed to a valid number. Properly handles the * case where the input is 0. * * @param str - The string, number, or undefined to parse as a number * @returns The parsed number or undefined if parsing fails * * @example * ```typescript * parse("123") // 123 * parse("123.45") // 123.45 * parse("-42") // -42 * parse("1,234") // 1234 * parse("0") // 0 * parse(0) // 0 * parse(42) // 42 * parse("not a number") // undefined * parse("") // undefined * parse(undefined) // undefined * ``` */ declare function parse(str: string | number | undefined): number | undefined; /** * Converts a number to its written English word representation. * * Transforms numeric values into their English word equivalents. * Supports integers and handles negative numbers appropriately. * * @param num - The number to convert to words * @returns The written English representation of the number * * @example * ```typescript * spell(42) // "forty-two" * spell(100) // "one hundred" * spell(1001) // "one thousand one" * spell(-5) // "minus five" * spell(0) // "zero" * ``` */ declare function spell(num: number): string; /** * Converts a number to its written English ordinal word representation. * * Transforms numeric values into their English ordinal word equivalents * (first, second, third, etc.). Supports positive integers. * * @param num - The number to convert to ordinal words * @returns The written English ordinal representation of the number * * @example * ```typescript * spellOrdinal(1) // "first" * spellOrdinal(2) // "second" * spellOrdinal(3) // "third" * spellOrdinal(21) // "twenty-first" * spellOrdinal(100) // "one hundredth" * ``` */ declare function spellOrdinal(num: number): string; /** * Rounds a number or array of numbers to a specified precision. * * Provides flexible rounding capabilities with configurable precision and rounding method. * Supports single numbers or arrays of numbers, returning the same type as the input. * Handles NaN values gracefully by preserving them in the output. * * Precision can be positive (decimal places), zero (nearest integer), or negative * (rounding to tens, hundreds, etc.). * * @param number - The number or array of numbers to round * @param options - Configuration options for rounding behavior * @param options.precision - Number of decimal places to round to (default: 1) * - Positive: round to decimal places (e.g., 2 = 0.01, 3 = 0.001) * - Zero: round to nearest integer * - Negative: round to tens, hundreds, etc. (e.g., -1 = 10, -2 = 100) * @param options.method - Rounding method to use: 'round' (default), 'ceil', or 'floor' * @returns The rounded number or array of numbers, matching the input type * * @example * ```typescript * // Basic rounding with default precision (1 decimal place) * round(3.14159) // 3.1 * round(2.718) // 2.7 * * // Custom precision * round(3.14159, {precision: 2}) // 3.14 * round(3.14159, {precision: 0}) // 3 * round(1.23456, {precision: 3}) // 1.235 * * // Negative precision (round to tens, hundreds, etc.) * round(1234.5678, {precision: -1}) // 1230 * round(1234.5678, {precision: -2}) // 1200 * round(1234.5678, {precision: -3}) // 1000 * * // Different rounding methods * round(3.14159, {precision: 2, method: 'round'}) // 3.14 * round(3.14159, {precision: 2, method: 'ceil'}) // 3.15 * round(3.14159, {precision: 2, method: 'floor'}) // 3.14 * round(1234, {precision: -1, method: 'ceil'}) // 1240 * round(1234, {precision: -1, method: 'floor'}) // 1230 * * // Array of numbers * round([3.14159, 2.71828], {precision: 2}) // [3.14, 2.72] * round([1.1, 2.2, 3.3], {precision: 0}) // [1, 2, 3] * round([1234, 5678], {precision: -2}) // [1200, 5700] * * // Handles NaN * round(NaN) // NaN * round([1.5, NaN, 2.7], {precision: 0}) // [2, NaN, 3] * ``` */ declare function round(number: number, options?: { precision?: number; method?: 'round' | 'ceil' | 'floor'; }): number; declare function round(number: number[], options?: { precision?: number; method?: 'round' | 'ceil' | 'floor'; }): number[]; declare const number_abbreviate: typeof abbreviate; declare const number_clamp: typeof clamp; declare const number_currencyFormat: typeof currencyFormat; declare const number_fileSize: typeof fileSize; declare const number_format: typeof format; declare const number_ordinal: typeof ordinal; declare const number_parse: typeof parse; declare const number_round: typeof round; declare const number_spell: typeof spell; declare const number_spellOrdinal: typeof spellOrdinal; declare namespace number { export { number_abbreviate as abbreviate, number_clamp as clamp, number_currencyFormat as currencyFormat, number_fileSize as fileSize, number_format as format, number_ordinal as ordinal, number_parse as parse, number_round as round, number_spell as spell, number_spellOrdinal as spellOrdinal }; } export { abbreviate as a, currencyFormat as b, clamp as c, format as d, spellOrdinal as e, fileSize as f, number as n, ordinal as o, parse as p, round as r, spell as s };