decimal.js-i18n
Version:
Full internationalization support for decimal.js.
2 lines (1 loc) • 1.37 kB
Source Map (JSON)
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../src/extend.esm.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,YAA0C,EAAE,EAAE;IACvE,IAAI,CAAC,YAAY,IAAI,OAAO,YAAY,CAAC,SAAS,KAAK,UAAU,EAAE;QAC/D,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;KACpD;IAED,UAAU,CAAC,0BAA0B,GAAG,YAAmC,CAAC;IAC5E,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IACxB,OAAO,UAAU,CAAC,0BAA0B,CAAC;IAC7C,OAAO,YAA8B,CAAC;AAC1C,CAAC,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*!\n * Copyright (c) 2022 Pedro José Batista, licensed under the MIT License.\n * See the LICENSE.md file in the project root for more information.\n */\nimport type Decimal from \".\";\n\n/**\n * Asynchronously extend a Decimal-like constructor with the internationalization support of `decimal.js-i18n`.\n *\n * @param decimalClass Decimal class/constructor to be extended.\n * @returns The augmented class/constructor.\n */\nexport const extend = async (decimalClass: Partial<Decimal.Constructor>) => {\n if (!decimalClass || typeof decimalClass.isDecimal !== \"function\") {\n throw new TypeError(\"Invalid Decimal argument.\");\n }\n\n globalThis.__Decimal__Class__Global__ = decimalClass as Decimal.Constructor;\n await import(\"./index\");\n delete globalThis.__Decimal__Class__Global__;\n return decimalClass as typeof Decimal;\n};\nexport default extend;\n"]}