Function
formatOutput
(result, e, u, output, spacer)
Source from the content-addressed store, hash-verified
| 448 | * @returns {string|Array|Object|number} Formatted result in requested type |
| 449 | */ |
| 450 | export function formatOutput(result, e, u, output, spacer) { |
| 451 | if (output === ARRAY) { |
| 452 | return result; |
| 453 | } |
| 454 | |
| 455 | if (output === OBJECT) { |
| 456 | return { |
| 457 | value: result[0], |
| 458 | symbol: result[1], |
| 459 | exponent: e, |
| 460 | unit: u, |
| 461 | }; |
| 462 | } |
| 463 | |
| 464 | let formatted; |
| 465 | if (spacer === SPACE) { |
| 466 | formatted = `${result[0]} ${result[1]}`; |
| 467 | } else { |
| 468 | formatted = result.join(spacer); |
| 469 | } |
| 470 | return formatted; |
| 471 | } |
Tested by
no test coverage detected