| Total Complexity | 4 |
| Complexity/F | 2 |
| Lines of Code | 28 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | /* |
||
| 2 | * decimal.js-i18n v0.2.6 |
||
| 3 | * Full internationalization support for decimal.js. |
||
| 4 | * MIT License |
||
| 5 | * Copyright (c) 2022 Pedro José Batista <[email protected]> |
||
| 6 | * https://github.com/pjbatista/decimal.js-i18n |
||
| 7 | */ |
||
| 8 | /* eslint-disable @typescript-eslint/no-unsafe-return */ |
||
| 9 | import type Decimal from "."; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * This function is the only export of this module, and can be used to extend custom builds of `decimal.js`. |
||
| 13 | * |
||
| 14 | * @param decimalClass Decimal class/constructor to be extended. |
||
| 15 | * @returns The augmented class/constructor. |
||
| 16 | */ |
||
| 17 | 1 | export function extend(decimalClass: Partial<Decimal.Constructor>) { |
|
| 18 | 4 | if (!decimalClass || typeof decimalClass.isDecimal !== "function") { |
|
| 19 | 1 | throw new TypeError("Invalid argument Decimal argument."); |
|
| 20 | } |
||
| 21 | |||
| 22 | 1 | globalThis.__Decimal__Class__Global__ = decimalClass as Decimal.Constructor; |
|
| 23 | 1 | require("."); |
|
| 24 | 1 | delete globalThis.__Decimal__Class__Global__; |
|
| 25 | 1 | return decimalClass as typeof Decimal; |
|
| 26 | } |
||
| 27 | export default extend; |
||
| 28 |