|
| 1 | +/** |
| 2 | + * Configuration object returned by getBaseConfiguration |
| 3 | + */ |
| 4 | +export interface BaseConfiguration { |
| 5 | + /** Whether to use decimal (base 10) calculations */ |
| 6 | + isDecimal: boolean; |
| 7 | + /** Ceiling value for auto-increment calculations */ |
| 8 | + ceil: number; |
| 9 | + /** The actual standard to use for formatting */ |
| 10 | + actualStandard: string; |
| 11 | +} |
| 12 | + |
| 13 | +/** |
| 14 | + * Value calculation result |
| 15 | + */ |
| 16 | +export interface OptimizedValueResult { |
| 17 | + /** The calculated result value */ |
| 18 | + result: number; |
| 19 | + /** The adjusted exponent */ |
| 20 | + e: number; |
| 21 | +} |
| 22 | + |
| 23 | +/** |
| 24 | + * Precision handling result |
| 25 | + */ |
| 26 | +export interface PrecisionHandlingResult { |
| 27 | + /** The formatted value */ |
| 28 | + value: string | number; |
| 29 | + /** The adjusted exponent */ |
| 30 | + e: number; |
| 31 | +} |
| 32 | + |
| 33 | +/** |
| 34 | + * Optimized base configuration lookup |
| 35 | + * @param standard - Standard type |
| 36 | + * @param base - Base number |
| 37 | + * @returns Configuration object |
| 38 | + */ |
| 39 | +export function getBaseConfiguration(standard: string, base: number): BaseConfiguration; |
| 40 | + |
| 41 | +/** |
| 42 | + * Optimized zero value handling |
| 43 | + * @param precision - Precision value |
| 44 | + * @param actualStandard - Standard to use |
| 45 | + * @param bits - Whether to use bits |
| 46 | + * @param symbols - Custom symbols |
| 47 | + * @param full - Whether to use full form |
| 48 | + * @param fullforms - Custom full forms |
| 49 | + * @param output - Output format |
| 50 | + * @param spacer - Spacer character |
| 51 | + * @returns Formatted result |
| 52 | + */ |
| 53 | +export function handleZeroValue( |
| 54 | + precision: number, |
| 55 | + actualStandard: string, |
| 56 | + bits: boolean, |
| 57 | + symbols: Record<string, string>, |
| 58 | + full: boolean, |
| 59 | + fullforms: string[], |
| 60 | + output: string, |
| 61 | + spacer: string |
| 62 | +): string | [number | string, string] | { value: number | string; symbol: string; exponent: number; unit: string } | number; |
| 63 | + |
| 64 | +/** |
| 65 | + * Optimized value calculation with bits handling |
| 66 | + * @param num - Input number |
| 67 | + * @param e - Exponent |
| 68 | + * @param isDecimal - Whether to use decimal powers |
| 69 | + * @param bits - Whether to calculate bits |
| 70 | + * @param ceil - Ceiling value for auto-increment |
| 71 | + * @returns Object with result and e properties |
| 72 | + */ |
| 73 | +export function calculateOptimizedValue( |
| 74 | + num: number, |
| 75 | + e: number, |
| 76 | + isDecimal: boolean, |
| 77 | + bits: boolean, |
| 78 | + ceil: number |
| 79 | +): OptimizedValueResult; |
| 80 | + |
| 81 | +/** |
| 82 | + * Optimized precision handling with scientific notation correction |
| 83 | + * @param value - Current value |
| 84 | + * @param precision - Precision to apply |
| 85 | + * @param e - Current exponent |
| 86 | + * @param num - Original number |
| 87 | + * @param isDecimal - Whether using decimal base |
| 88 | + * @param bits - Whether calculating bits |
| 89 | + * @param ceil - Ceiling value |
| 90 | + * @param roundingFunc - Rounding function |
| 91 | + * @param round - Round value |
| 92 | + * @returns Object with value and e properties |
| 93 | + */ |
| 94 | +export function applyPrecisionHandling( |
| 95 | + value: number, |
| 96 | + precision: number, |
| 97 | + e: number, |
| 98 | + num: number, |
| 99 | + isDecimal: boolean, |
| 100 | + bits: boolean, |
| 101 | + ceil: number, |
| 102 | + roundingFunc: (x: number) => number, |
| 103 | + round: number |
| 104 | +): PrecisionHandlingResult; |
| 105 | + |
| 106 | +/** |
| 107 | + * Optimized number formatting with locale, separator, and padding |
| 108 | + * @param value - Value to format |
| 109 | + * @param locale - Locale setting |
| 110 | + * @param localeOptions - Locale options |
| 111 | + * @param separator - Custom separator |
| 112 | + * @param pad - Whether to pad |
| 113 | + * @param round - Round value |
| 114 | + * @returns Formatted value |
| 115 | + */ |
| 116 | +export function applyNumberFormatting( |
| 117 | + value: number | string, |
| 118 | + locale: string | boolean, |
| 119 | + localeOptions: Intl.NumberFormatOptions, |
| 120 | + separator: string, |
| 121 | + pad: boolean, |
| 122 | + round: number |
| 123 | +): string | number; |
0 commit comments