( precision, actualStandard, bits, symbols, full, fullforms, output, spacer, symbol, )
| 66 | * @returns {string|Array|Object|number} Formatted result |
| 67 | */ |
| 68 | export function handleZeroValue( |
| 69 | precision, |
| 70 | actualStandard, |
| 71 | bits, |
| 72 | symbols, |
| 73 | full, |
| 74 | fullforms, |
| 75 | output, |
| 76 | spacer, |
| 77 | symbol, |
| 78 | ) { |
| 79 | let value; |
| 80 | if (precision > 0) { |
| 81 | value = (0).toPrecision(precision); |
| 82 | } else { |
| 83 | value = 0; |
| 84 | } |
| 85 | |
| 86 | if (output === EXPONENT) { |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | // Set default symbol if not provided |
| 91 | if (!symbol) { |
| 92 | symbol = bits |
| 93 | ? STRINGS.symbol[actualStandard].bits[0] |
| 94 | : STRINGS.symbol[actualStandard].bytes[0]; |
| 95 | } |
| 96 | |
| 97 | // Apply symbol customization |
| 98 | if (symbols[symbol]) { |
| 99 | symbol = symbols[symbol]; |
| 100 | } |
| 101 | |
| 102 | // Apply full form |
| 103 | if (full) { |
| 104 | if (fullforms[0]) { |
| 105 | symbol = fullforms[0]; |
| 106 | } else { |
| 107 | symbol = STRINGS.fullform[actualStandard][0]; |
| 108 | if (bits) { |
| 109 | symbol += BIT; |
| 110 | } else { |
| 111 | symbol += BYTE; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // Return in requested format |
| 117 | if (output === ARRAY) { |
| 118 | return [value, symbol]; |
| 119 | } |
| 120 | |
| 121 | if (output === OBJECT) { |
| 122 | return { value, symbol, exponent: 0, unit: symbol }; |
| 123 | } |
| 124 | |
| 125 | return value + spacer + symbol; |
no outgoing calls
no test coverage detected