UNPKG

fitr

Version:
56 lines (55 loc) 2 kB
/** * Formats a number with the specified number of decimal places * * @param {number} value - The number to format * @param {number} [decimals=2] - The number of decimal places to display (default: 2) * @returns {string} The formatted number as a string with commas as thousand separators * * @example * // Returns "1,234.57" * formatNumber(1234.567) * * @example * // Returns "1,234.567" * formatNumber(1234.567, 3) */ export declare function formatNumber(value: number, decimals?: number): string; /** * Formats a number with color highlighting based on its value and adds an optional symbol * * @param {number} value - The number to format and color * @param {string} [symbol=''] - Optional symbol to append to the number (e.g., '%', '$') * @returns {string} The formatted number with color highlighting * * Features: * - Positive numbers get a green background (#384f21) * - Negative numbers get a red background (#732f2c) * - Numbers ≥ 1,000,000 are formatted as "X.XXm" (millions) * - Numbers ≥ 10,000 are formatted as "X.XXk" (thousands) * - Adds padding for consistent width display * * @example * // Returns a green-highlighted " 1,234.56 " * getColoredFormatedNumber(1234.56) * * @example * // Returns a green-highlighted " 1.23m$ " * getColoredFormatedNumber(1234567, '$') */ export declare function getColoredFormatedNumber(value: number, symbol?: string): string; /** * Conditionally highlights text with a bright yellow color * * @param {boolean} shouldHighlight - Whether the text should be highlighted * @param {string} text - The text to potentially highlight * @returns {string} The highlighted text if shouldHighlight is true, otherwise the original text * * @example * // Returns yellow-highlighted "test text" * highlight(true, "test text") * * @example * // Returns "test text" without highlighting * highlight(false, "test text") */ export declare function highlight(shouldHighlight: boolean, text: string): string;