UNPKG

decimal.js-i18n

Version:
2 lines (1 loc) 49.1 kB
{"version":3,"file":"index.mjs","sources":["src/format/constants.ts","src/format/options.ts","src/format/format.ts","src/index.ts"],"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 Decimal from \"decimal.js\";\nimport type Currency from \"./currency\";\nimport type Locale from \"./locale\";\nimport type NumberingSystem from \"./numberingSystem\";\n\n/** Format extension used to create large integers with user-defined grouping. */\nexport const BIGINT_MODIFIERS = {\n maximumFractionDigits: 0,\n minimumFractionDigits: 0,\n maximumSignificantDigits: undefined,\n minimumSignificantDigits: undefined,\n notation: \"standard\",\n style: \"decimal\",\n} as const;\n\n/** Format extension used to create large integers using the standard notation and decimal system. */\nexport const PLAIN_MODIFIERS = {\n minimumIntegerDigits: 1,\n signDisplay: \"never\",\n useGrouping: false,\n} as const;\n\n/** The hard exponent limit of `decimal.js` and the digit-count threshold of the plugin. */\nexport const DECIMAL_LIMIT = 1e9;\n\n/**\n * Hard digit-count limit set by the ECMA internalization standard. Due to the arbitrary-precision of\n * `decimal.js`, this plugin chooses to ignore such limits, allowing values far larger.\n */\nexport const ECMA_LIMIT = 21;\n\n/** Default configuration of the formatting objects. */\nexport const DEFAULT_OPTIONS = {\n compactDisplay: \"short\",\n currencyDisplay: \"symbol\",\n currencySign: \"standard\",\n maximumFractionDigits: 499,\n minimumFractionDigits: 0,\n minimumIntegerDigits: 1,\n maximumSignificantDigits: 500,\n minimumSignificantDigits: 1,\n notation: \"standard\",\n rounding: Decimal.ROUND_HALF_UP,\n signDisplay: \"auto\",\n style: \"decimal\",\n unitDisplay: \"short\",\n trailingZeroDisplay: \"auto\",\n} as const;\n\n/** A big list of {@link Currency currencies}, containing most of the standard currencies of the world. */\nexport const CURRENCIES: ReadonlyArray<Currency> = [\n \"AED\",\n \"AFN\",\n \"ALL\",\n \"AMD\",\n \"ANG\",\n \"AOA\",\n \"ARS\",\n \"AUD\",\n \"AWG\",\n \"AZN\",\n \"BAM\",\n \"BBD\",\n \"BDT\",\n \"BGN\",\n \"BHD\",\n \"BIF\",\n \"BMD\",\n \"BND\",\n \"BOB\",\n \"BRL\",\n \"BSD\",\n \"BTN\",\n \"BWP\",\n \"BYR\",\n \"BZD\",\n \"CAD\",\n \"CDF\",\n \"CHF\",\n \"CLP\",\n \"CNY\",\n \"COP\",\n \"CRC\",\n \"CUP\",\n \"CVE\",\n \"CZK\",\n \"DJF\",\n \"DKK\",\n \"DOP\",\n \"DZD\",\n \"EEK\",\n \"EGP\",\n \"ERN\",\n \"ETB\",\n \"EUR\",\n \"FJD\",\n \"FKP\",\n \"GBP\",\n \"GEL\",\n \"GHS\",\n \"GIP\",\n \"GMD\",\n \"GNF\",\n \"GTQ\",\n \"GYD\",\n \"HKD\",\n \"HNL\",\n \"HRK\",\n \"HTG\",\n \"HUF\",\n \"IDR\",\n \"ILS\",\n \"INR\",\n \"IQD\",\n \"IRR\",\n \"ISK\",\n \"JMD\",\n \"JOD\",\n \"JPY\",\n \"KES\",\n \"KGS\",\n \"KHR\",\n \"KMF\",\n \"KPW\",\n \"KRW\",\n \"KWD\",\n \"KYD\",\n \"KZT\",\n \"LAK\",\n \"LBP\",\n \"LKR\",\n \"LRD\",\n \"LSL\",\n \"LTL\",\n \"LVL\",\n \"LYD\",\n \"MAD\",\n \"MDL\",\n \"MGA\",\n \"MKD\",\n \"MMK\",\n \"MNT\",\n \"MOP\",\n \"MRO\",\n \"MUR\",\n \"MVR\",\n \"MWK\",\n \"MXN\",\n \"MYR\",\n \"MZN\",\n \"NAD\",\n \"NGN\",\n \"NIO\",\n \"NOK\",\n \"NPR\",\n \"NZD\",\n \"OMR\",\n \"PAB\",\n \"PEN\",\n \"PGK\",\n \"PHP\",\n \"PKR\",\n \"PLN\",\n \"PYG\",\n \"QAR\",\n \"RON\",\n \"RSD\",\n \"RUB\",\n \"RWF\",\n \"SAR\",\n \"SBD\",\n \"SCR\",\n \"SDG\",\n \"SEK\",\n \"SGD\",\n \"SHP\",\n \"SLL\",\n \"SOS\",\n \"SRD\",\n \"STD\",\n \"SVC\",\n \"SYP\",\n \"SZL\",\n \"THB\",\n \"TJS\",\n \"TND\",\n \"TOP\",\n \"TRY\",\n \"TTD\",\n \"TWD\",\n \"TZS\",\n \"UAH\",\n \"UGX\",\n \"USD\",\n \"UYU\",\n \"UZS\",\n \"VEF\",\n \"VES\",\n \"VND\",\n \"VUV\",\n \"WST\",\n \"XAF\",\n \"XCD\",\n \"XOF\",\n \"XPF\",\n \"YER\",\n \"ZAR\",\n \"ZMK\",\n \"ZWD\",\n] as const;\n\n/** A big list of BCP 47 {@link Locale locales}, used for the new method `Decimal.Format.supportedLocales` */\nexport const LOCALES: ReadonlyArray<Locale> = [\n \"af-ZA\",\n \"am-ET\",\n \"ar-AE\",\n \"ar-BH\",\n \"ar-DZ\",\n \"ar-EG\",\n \"ar-IQ\",\n \"ar-JO\",\n \"ar-KW\",\n \"ar-LB\",\n \"ar-LY\",\n \"ar-MA\",\n \"arn-CL\",\n \"ar-OM\",\n \"ar-QA\",\n \"ar-SA\",\n \"ar-SD\",\n \"ar-SY\",\n \"ar-TN\",\n \"ar-YE\",\n \"as-IN\",\n \"az-az\",\n \"az-Cyrl-AZ\",\n \"az-Latn-AZ\",\n \"ba-RU\",\n \"be-BY\",\n \"bg-BG\",\n \"bn-BD\",\n \"bn-IN\",\n \"bo-CN\",\n \"br-FR\",\n \"bs-Cyrl-BA\",\n \"bs-Latn-BA\",\n \"ca-ES\",\n \"co-FR\",\n \"cs-CZ\",\n \"cy-GB\",\n \"da-DK\",\n \"de-AT\",\n \"de-CH\",\n \"de-DE\",\n \"de-LI\",\n \"de-LU\",\n \"dsb-DE\",\n \"dv-MV\",\n \"el-CY\",\n \"el-GR\",\n \"en-029\",\n \"en-AU\",\n \"en-BZ\",\n \"en-CA\",\n \"en-cb\",\n \"en-GB\",\n \"en-IE\",\n \"en-IN\",\n \"en-JM\",\n \"en-MT\",\n \"en-MY\",\n \"en-NZ\",\n \"en-PH\",\n \"en-SG\",\n \"en-TT\",\n \"en-US\",\n \"en-ZA\",\n \"en-ZW\",\n \"es-AR\",\n \"es-BO\",\n \"es-CL\",\n \"es-CO\",\n \"es-CR\",\n \"es-DO\",\n \"es-EC\",\n \"es-ES\",\n \"es-GT\",\n \"es-HN\",\n \"es-MX\",\n \"es-NI\",\n \"es-PA\",\n \"es-PE\",\n \"es-PR\",\n \"es-PY\",\n \"es-SV\",\n \"es-US\",\n \"es-UY\",\n \"es-VE\",\n \"et-EE\",\n \"eu-ES\",\n \"fa-IR\",\n \"fi-FI\",\n \"fil-PH\",\n \"fo-FO\",\n \"fr-BE\",\n \"fr-CA\",\n \"fr-CH\",\n \"fr-FR\",\n \"fr-LU\",\n \"fr-MC\",\n \"fy-NL\",\n \"ga-IE\",\n \"gd-GB\",\n \"gd-ie\",\n \"gl-ES\",\n \"gsw-FR\",\n \"gu-IN\",\n \"ha-Latn-NG\",\n \"he-IL\",\n \"hi-IN\",\n \"hr-BA\",\n \"hr-HR\",\n \"hsb-DE\",\n \"hu-HU\",\n \"hy-AM\",\n \"id-ID\",\n \"ig-NG\",\n \"ii-CN\",\n \"in-ID\",\n \"is-IS\",\n \"it-CH\",\n \"it-IT\",\n \"iu-Cans-CA\",\n \"iu-Latn-CA\",\n \"iw-IL\",\n \"ja-JP\",\n \"ka-GE\",\n \"kk-KZ\",\n \"kl-GL\",\n \"km-KH\",\n \"kn-IN\",\n \"kok-IN\",\n \"ko-KR\",\n \"ky-KG\",\n \"lb-LU\",\n \"lo-LA\",\n \"lt-LT\",\n \"lv-LV\",\n \"mi-NZ\",\n \"mk-MK\",\n \"ml-IN\",\n \"mn-MN\",\n \"mn-Mong-CN\",\n \"moh-CA\",\n \"mr-IN\",\n \"ms-BN\",\n \"ms-MY\",\n \"mt-MT\",\n \"nb-NO\",\n \"ne-NP\",\n \"nl-BE\",\n \"nl-NL\",\n \"nn-NO\",\n \"no-no\",\n \"nso-ZA\",\n \"oc-FR\",\n \"or-IN\",\n \"pa-IN\",\n \"pl-PL\",\n \"prs-AF\",\n \"ps-AF\",\n \"pt-BR\",\n \"pt-PT\",\n \"qut-GT\",\n \"quz-BO\",\n \"quz-EC\",\n \"quz-PE\",\n \"rm-CH\",\n \"ro-mo\",\n \"ro-RO\",\n \"ru-mo\",\n \"ru-RU\",\n \"rw-RW\",\n \"sah-RU\",\n \"sa-IN\",\n \"se-FI\",\n \"se-NO\",\n \"se-SE\",\n \"si-LK\",\n \"sk-SK\",\n \"sl-SI\",\n \"sma-NO\",\n \"sma-SE\",\n \"smj-NO\",\n \"smj-SE\",\n \"smn-FI\",\n \"sms-FI\",\n \"sq-AL\",\n \"sr-BA\",\n \"sr-CS\",\n \"sr-Cyrl-BA\",\n \"sr-Cyrl-CS\",\n \"sr-Cyrl-ME\",\n \"sr-Cyrl-RS\",\n \"sr-Latn-BA\",\n \"sr-Latn-CS\",\n \"sr-Latn-ME\",\n \"sr-Latn-RS\",\n \"sr-ME\",\n \"sr-RS\",\n \"sr-sp\",\n \"sv-FI\",\n \"sv-SE\",\n \"sw-KE\",\n \"syr-SY\",\n \"ta-IN\",\n \"te-IN\",\n \"tg-Cyrl-TJ\",\n \"th-TH\",\n \"tk-TM\",\n \"tlh-QS\",\n \"tn-ZA\",\n \"tr-TR\",\n \"tt-RU\",\n \"tzm-Latn-DZ\",\n \"ug-CN\",\n \"uk-UA\",\n \"ur-PK\",\n \"uz-Cyrl-UZ\",\n \"uz-Latn-UZ\",\n \"uz-uz\",\n \"vi-VN\",\n \"wo-SN\",\n \"xh-ZA\",\n \"yo-NG\",\n \"zh-CN\",\n \"zh-HK\",\n \"zh-MO\",\n \"zh-SG\",\n \"zh-TW\",\n \"zu-ZA\",\n] as const;\n\n/** A big list of {@link NumberingSystem numbering systems} representing multiple regions of the world. */\nexport const NUMBERING_SYSTEMS: ReadonlyArray<NumberingSystem> = [\n \"adlm\",\n \"ahom\",\n \"arab\",\n \"arabext\",\n \"armn\",\n \"armnlow\",\n \"bali\",\n \"beng\",\n \"bhks\",\n \"brah\",\n \"cakm\",\n \"cham\",\n \"cyrl\",\n \"deva\",\n \"ethi\",\n \"finance\",\n \"fullwide\",\n \"geor\",\n \"gong\",\n \"gonm\",\n \"grek\",\n \"greklow\",\n \"gujr\",\n \"guru\",\n \"hanidays\",\n \"hanidec\",\n \"hans\",\n \"hansfin\",\n \"hant\",\n \"hantfin\",\n \"hebr\",\n \"hmng\",\n \"hmnp\",\n \"java\",\n \"jpan\",\n \"jpanfin\",\n \"jpanyear\",\n \"kali\",\n \"khmr\",\n \"knda\",\n \"lana\",\n \"lanatham\",\n \"laoo\",\n \"latn\",\n \"lepc\",\n \"limb\",\n \"mathbold\",\n \"mathdbl\",\n \"mathmono\",\n \"mathsanb\",\n \"mathsans\",\n \"mlym\",\n \"modi\",\n \"mong\",\n \"mroo\",\n \"mtei\",\n \"mymr\",\n \"mymrshan\",\n \"mymrtlng\",\n \"native\",\n \"newa\",\n \"nkoo\",\n \"olck\",\n \"orya\",\n \"osma\",\n \"rohg\",\n \"roman\",\n \"romanlow\",\n \"saur\",\n \"shrd\",\n \"sind\",\n \"sinh\",\n \"sora\",\n \"sund\",\n \"takr\",\n \"talu\",\n \"taml\",\n \"tamldec\",\n \"telu\",\n \"thai\",\n \"tirh\",\n \"tibt\",\n \"traditio\",\n \"vaii\",\n \"wara\",\n \"wcho\",\n] as const;\n\n/** Array containing the supported locales of the current environment. */\nexport const SUPPORTED_LOCALES: Locale[] = Intl.NumberFormat.supportedLocalesOf(LOCALES as string[]);\n","/*!\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 BaseFormatOptions from \"./baseOptions\";\nimport { DECIMAL_LIMIT, DEFAULT_OPTIONS, ECMA_LIMIT } from \"./constants\";\nimport type LocaleMatcher from \"./localeMatcher\";\nimport type Notation from \"./notation\";\nimport type ResolvedFormatOptions from \"./resolvedOptions\";\nimport type Style from \"./style\";\n\ntype DigitsProperty =\n | \"maximumFractionDigits\"\n | \"minimumFractionDigits\"\n | \"minimumIntegerDigits\"\n | \"maximumSignificantDigits\"\n | \"minimumSignificantDigits\";\ntype DigitsPropertyCallback<T> = (property: DigitsProperty, factor: number) => T;\n\n// A generator function to be used to access or modify all digits properties\n// -> factor is a simple index shifting value (fractions go from 0 to 1e9-1, other from 1 to 1e9)\nconst forEachDigitsPropertyGenerator = function* <T>(callback: DigitsPropertyCallback<T>) {\n yield callback(\"maximumFractionDigits\", -1);\n yield callback(\"minimumFractionDigits\", -1);\n yield callback(\"minimumIntegerDigits\", 0);\n yield callback(\"maximumSignificantDigits\", 0);\n yield callback(\"minimumSignificantDigits\", 0);\n};\n\n// Spreads the generated values of `forEachDigitsPropertyGenerator` to an array\nconst forEachDigitsProperty = <T>(callback: DigitsPropertyCallback<T>) => [...forEachDigitsPropertyGenerator(callback)];\n\n/**\n * Creates and returns a new object with the extension of an existing set of options with any number of modifiers.\n *\n * @param options Object to be extended.\n * @param modifiers Anu number of objects containing the modifiers to the `options`.\n * @returns An extended format options.\n */\nexport const extend = <T extends FormatOptions | Intl.NumberFormatOptions>(options: T, ...modifiers: T[]) =>\n Object.assign({ ...options }, ...modifiers) as T;\n\n/**\n * Creates and returns an object based on a `Intl.ResolvedNumberFormatOptions`, however re-expanding it to\n * beyond the limits of the ECMA-specification.\n *\n * If the user wants 999999999 fraction digits, they can have it (though it would be larger than 2GBs and take\n * quite a while to calculate at in an average PC).\n *\n * @template N Numeric notation of formatting.\n * @template S Numeric style of formatting.\n * @param options Decimal format options to be merged with the ECMA resolved options.\n * @param ecma Object resulting from `Intl.NumberFormat.resolvedOptions()`.\n * @returns A resolved decimal format options.\n */\nexport const resolve = <N extends Notation = \"standard\", S extends Style = \"decimal\">(\n options: FormatOptions<N, S>,\n ecma: Intl.ResolvedNumberFormatOptions,\n) => {\n const result = { ...ecma } as ResolvedFormatOptions<\n typeof ecma.notation extends Notation ? typeof ecma.notation : N,\n typeof ecma.style extends Style ? typeof ecma.style : S\n >;\n\n forEachDigitsProperty(property => {\n if (!(property in result)) {\n return;\n }\n\n // Gets the maximum in between both objects and the defaults\n result[property] = Math.max(ecma[property] ?? 0, options[property] ?? DEFAULT_OPTIONS[property]);\n });\n\n // Parsed from group 1?\n if (typeof result.maximumFractionDigits === \"number\") {\n result.maximumFractionDigits = Math.max(result.minimumFractionDigits!, result.maximumFractionDigits);\n }\n // Or from group 2?\n else {\n result.maximumSignificantDigits = Math.max(result.minimumSignificantDigits!, result.maximumSignificantDigits!);\n }\n\n // Our custom defaults:\n result.rounding ??= options.rounding ?? DEFAULT_OPTIONS.rounding;\n result.trailingZeroDisplay ??= options.trailingZeroDisplay ?? DEFAULT_OPTIONS.trailingZeroDisplay;\n\n return result;\n};\n\n/**\n * Creates and returns an `Intl.NumberFormatOptions` object, copying from a {@link FormatOptions} object with\n * its digits limited to ECMA-specification's range.\n *\n * @template TNotation Numeric notation of formatting.\n * @template TStyle Numeric style of formatting.\n * @param options Decimal format options used as a baseline for the new object.\n * @returns A new `Intl.NumberFormatOptions` object.\n */\nexport const toEcma = <TNotation extends Notation = \"standard\", TStyle extends Style = \"decimal\">(\n options: FormatOptions<TNotation, TStyle>,\n) => {\n const result = { ...options };\n\n forEachDigitsProperty((property, factor) => {\n // Check if it already exists to prevent creating unnecessary properties\n if (property in result && Number(result[property]) > ECMA_LIMIT + factor) {\n result[property] = ECMA_LIMIT + factor;\n }\n });\n\n return result as Intl.NumberFormatOptions;\n};\n\n/**\n * Validates whether the given {@link FormatOptions} contains acceptable values.\n *\n * It specially checks if the digits properties are within `decimal.js`' range, which is 1e9±1.\n *\n * @template N Numeric notation of formatting.\n * @template S Numeric style of formatting.\n * @param options Decimal format options to be validated.\n * @returns `true` if all properties are valid. Otherwise, an array with the invalid properties names.\n */\nexport const validate = <N extends Notation = \"standard\", S extends Style = \"decimal\">(\n options: FormatOptions<N, S>,\n) => {\n const result = forEachDigitsProperty((property, factor) => {\n if (property in options && Number(options[property]) > DECIMAL_LIMIT + factor) {\n return property;\n }\n return true;\n });\n\n if (result.every(entry => entry === true)) {\n return true;\n }\n\n return result.filter(entry => entry !== true) as DigitsProperty[];\n};\n\n/**\n * Object used to configure a `Decimal.Format` object; the following properties fall into two groups:\n *\n * - {@link minimumIntegerDigits}, {@link minimumFractionDigits}, and {@link maximumFractionDigits} in one group;\n * - {@link minimumSignificantDigits} and {@link maximumSignificantDigits} in the other.\n *\n * If at least one property from the second group is defined, then the first group is ignored.\n *\n * @template N Numeric notation of formatting.\n * @template S Numeric style of formatting.\n */\nexport interface FormatOptions<N extends Notation = \"standard\", S extends Style = \"decimal\">\n extends Partial<BaseFormatOptions<N, S>> {\n /**\n * The locale matching algorithm to use. Possible values are \"`lookup`\" and \"`best fit`\"; the default is\n * \"`best fit`\". For information about this option, see the [Intl page on\n * MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).\n */\n localeMatcher?: LocaleMatcher | undefined;\n}\n\nexport default FormatOptions;\n","/*!\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 Decimal from \"decimal.js\";\nimport type BaseFormatOptions from \"./baseOptions\";\nimport type CompactDisplay from \"./compactDisplay\";\nimport { BIGINT_MODIFIERS, ECMA_LIMIT, PLAIN_MODIFIERS, SUPPORTED_LOCALES } from \"./constants\";\nimport type Currency from \"./currency\";\nimport type CurrencyDisplay from \"./currencyDisplay\";\nimport type CurrencySign from \"./currencySign\";\nimport type Locale from \"./locale\";\nimport type LocaleMatcher from \"./localeMatcher\";\nimport type Notation from \"./notation\";\nimport type NumberingSystem from \"./numberingSystem\";\nimport type FormatOptions from \"./options\";\nimport { extend, resolve, toEcma, validate } from \"./options\";\nimport type FormatPart from \"./part\";\nimport { exponents, fractions, integerGroups, integers, PartValue } from \"./part\";\nimport type FormatPartTypes from \"./partTypes\";\nimport type ResolvedFormatOptions from \"./resolvedOptions\";\nimport type SignDisplay from \"./signDisplay\";\nimport type Style from \"./style\";\nimport type TrailingZeroDisplay from \"./trailingZeroDisplay\";\nimport type Unit from \"./unit\";\nimport type UnitDisplay from \"./unitDisplay\";\nimport type UseGrouping from \"./useGrouping\";\n\nconst concatenate = <T extends PartValue>(filter: T[] | ((p: T) => boolean), parts: T[] = []) => {\n if (typeof filter === \"function\") {\n parts = parts.filter(filter);\n } else {\n parts = filter;\n }\n\n return parts.map(p => p.value).join(\"\");\n};\n\nconst pow10 = (exponent: Decimal.Value) => Decimal.pow(10, exponent);\n\n/**\n * The `Decimal.Format` object enables language-sensitive decimal number formatting. It is entirely based on\n * `Intl.NumberFormat`, with the options of the latter being 100% compatible with it.\n *\n * This class, however, extend the numeric digits constraints of `Intl.NumberFormat` from 21 to 1000000000 in\n * order to fully take advantage of the arbitrary-precision of `decimal.js`.\n *\n * @template N Numeric notation of formatting.\n * @template S Numeric style of formatting.\n */\nexport class DecimalFormat<N extends Notation, S extends Style> {\n static readonly [Symbol.toPrimitive] = DecimalFormat;\n readonly [Symbol.toStringTag] = \"Decimal.Format\";\n\n /**\n * Formats a number according to the locale and formatting options of this {@link DecimalFormat} object.\n *\n * @param value A valid [Decimal.Value](https://mikemcl.github.io/decimal.js/#decimal) to format.\n * @returns Formatted localized string.\n */\n readonly format: (value: Decimal.Value) => string;\n\n /**\n * Allows locale-aware formatting of strings produced by `Decimal.Format` formatters.\n *\n * @param value A valid [Decimal.Value](https://mikemcl.github.io/decimal.js/#decimal) to format.\n * @returns An array of objects containing the formatted number in parts.\n */\n readonly formatToParts: (value: Decimal.Value) => FormatPart[];\n\n /**\n * Returns a new object with properties reflecting the locale and number formatting options computed during\n * initialization of this {@link Decimal.Format} object.\n *\n * @returns A new object with properties reflecting the locale and number formatting options computed\n * during the initialization of this object.\n */\n readonly resolvedOptions: () => ResolvedFormatOptions<N, S>;\n\n /**\n * Creates a new instance of the `Decimal.Format` object.\n *\n * @param locales A string with a [BCP 47](https://www.rfc-editor.org/info/bcp47) language tag, or an array\n * of such strings.\n *\n * For the general form and interpretation of this parameter, see the [Intl page on\n * MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).\n * @param options Object used to configure the behavior of the string localization.\n * @throws `RangeError` when an invalid option is given.\n */\n constructor(locales?: Locale | Locale[], options?: FormatOptions<N, S>) {\n options ??= {};\n\n // 1. Check if options do not extrapolate the limits of decimal.js\n const valid = validate(options);\n\n if (valid !== true) {\n // -> it will either be exactly true or contain an array with all faulty properties:\n throw new RangeError(`${valid.join()} value${valid.length === 1 ? \" is\" : \"s are\"} out of range.\"`);\n }\n\n // 2. Create a baseline native formatter native\n const ecmaOptions = toEcma(options);\n const ecmaFormat = new Intl.NumberFormat(locales, ecmaOptions);\n\n // 3. Resolve this object's options, using the native resolution as a baseline\n const resolved = resolve(options, ecmaFormat.resolvedOptions());\n const { minimumIntegerDigits: minID, notation, rounding, style } = resolved;\n\n // 4. Create two auxiliary formatters:\n // One for the integer part, which can have up to a billion minimum digits...\n const bigintOptions = extend(ecmaOptions, BIGINT_MODIFIERS);\n const bigintFormat = new Intl.NumberFormat(locales, bigintOptions);\n\n // ...and another for a plain, localized reference, used for decimals and constants\n const plainOptions = extend(bigintOptions, PLAIN_MODIFIERS);\n const plainFormat = new Intl.NumberFormat(locales, plainOptions);\n\n // 5. Localized numeric constants\n const numbers = Array(10)\n .fill(null)\n .map((_, index) => plainFormat.format(index));\n const numberMatch = new RegExp(\"[\" + numbers.join(\"\") + \"]\", \"g\");\n const minusSign = /−/gu;\n\n // 5.1. Localized zero and one used in substitutions\n const [zero, one] = numbers;\n\n // 5.2. Helper functions\n const indexOfValue = (value: string) => numbers.indexOf(value).toString();\n const convert = (text: string) => text.replaceAll(numberMatch, indexOfValue).replaceAll(minusSign, \"-\");\n const zeroFill = (size: number) => Array(size).fill(zero).join(\"\");\n const zeroTrim = (text: string, mode: \"both\" | \"left\" | \"right\" = \"left\", max: number | boolean = false) => {\n let result = text;\n let count = 0;\n\n if (mode === \"both\" || mode === \"left\")\n while (result[0] === zero && result.length > 1 && (max === false || count < max)) {\n result = result.slice(1);\n count++;\n }\n\n if (mode === \"both\" || mode === \"right\")\n while (result[result.length - 1] === zero && result.length > 1 && (max === false || count < max)) {\n result = result.slice(0, -1);\n count++;\n }\n\n return result;\n };\n\n // #region Step 6. Main format method - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n const _formatToParts = (value: Decimal.Value) => {\n value = new Decimal(value);\n const sign = Decimal.sign(value);\n\n // 6.1. Create a baseline part array\n const ecmaParts = ecmaFormat.formatToParts(value.toNumber());\n\n // -> if the value is non-numeric or an infinity, the baseline is good enough\n if ((value.isFinite && !value.isFinite()) || (value.isNaN && value.isNaN())) {\n return ecmaParts;\n }\n\n // 6.2. Splitting the parts for easier assembly\n const ecmaExponentValue = concatenate(exponents, ecmaParts) || \"0\";\n const ecmaIntegerParts = ecmaParts.filter(integerGroups);\n const ecmaIntegerTrimmed = zeroTrim(concatenate(integers, ecmaIntegerParts));\n const ecmaIntegerDigits = concatenate(integers, ecmaIntegerParts).length;\n const ecmaIntegerTrimmedDigits = ecmaIntegerTrimmed.length;\n const ecmaFractionValue = concatenate(fractions, ecmaParts);\n const ecmaFractionDigits = ecmaFractionValue.length;\n\n // 6.3. Shifting exponents according to notation/style\n\n // 6.3.1. Compact notation: calculate the shift in integer digits, and therefore exponent\n if (notation === \"compact\" && !value.eq(0)) {\n const baseInteger = value.abs().trunc().toFixed();\n const baseIntegerDigits = baseInteger.length;\n const correctionDigits = baseIntegerDigits - ecmaIntegerTrimmedDigits;\n\n if (correctionDigits > 0) {\n value = value.mul(pow10(-correctionDigits));\n }\n }\n\n // 6.3.2. Engr./Scientific notations: evaluate the exponent from the text\n if ((notation === \"engineering\" || notation === \"scientific\") && ecmaExponentValue !== zero) {\n const exponential = new Decimal(convert(ecmaExponentValue));\n value = value.mul(pow10(exponential.mul(-1))).abs().mul(sign); // prettier-ignore\n }\n\n // 6.3.3. Percent style: shift the value accordingly (non numeric parts will remain the same)\n if (style === \"percent\") value = value.mul(100);\n\n // 6.4. Parsing the information about the numeric parts\n const integer = value.abs().trunc().mul(sign);\n const fraction = value.sub(integer).abs();\n const integerDigits = !value.eq(0) && integer.eq(0) ? 0 : value.abs().trunc().toFixed().length;\n const fractionDigits = value.dp();\n const maxSD = resolved.maximumSignificantDigits ?? integerDigits + fractionDigits;\n const maxFD = resolved.maximumFractionDigits ?? fractionDigits;\n const minSD = resolved.minimumSignificantDigits ?? resolved.minimumFractionDigits! + minID;\n const minFD = resolved.minimumFractionDigits ?? minSD - minID;\n\n // 6.5. Check for the possibility of the native formatter to have accomplished the desired output\n const integerCheck = !ecmaIntegerParts.length || (minID <= ECMA_LIMIT && ecmaIntegerDigits >= minID);\n const fractionCheck =\n ecmaFractionDigits >= fractionDigits && minFD < ECMA_LIMIT && ecmaFractionDigits >= minFD;\n\n // -> if the native formatter is good enough for our decimal value, leave it as-is\n if (integerCheck && fractionCheck) {\n return ecmaParts as FormatPart[];\n }\n\n // 6.6. Create the integer value\n const integerParts = (() => {\n if (integerCheck) return ecmaIntegerParts;\n\n // Expanding the integer part\n const targetDigits = Math.max(integerDigits, minID);\n\n // Creates a base 10 power of the target digits\n const bigint = BigInt(pow10(targetDigits - 1).toFixed());\n\n // Format using the bigint formatter and cut it before joining with the ECMA parts\n const bigintIntegerParts = bigintFormat.formatToParts(bigint).filter(integerGroups);\n\n // We need to replace the first 'one' (from the base 10 power) with a 'zero'\n bigintIntegerParts[0].value = bigintIntegerParts[0].value.replace(new RegExp(one), zero);\n\n // Merge the first part with the bigint part\n ecmaIntegerParts[0].value =\n bigintIntegerParts[ecmaIntegerParts.length - 1].value.slice(0, -ecmaIntegerParts[0].value.length) +\n ecmaIntegerParts[0].value;\n\n return [...bigintIntegerParts.slice(0, -ecmaIntegerParts.length), ...ecmaIntegerParts];\n })();\n\n // 6.7. Create the fraction value\n const fractionValue = (() => {\n if (fractionCheck) return ecmaFractionValue;\n\n // Simpler formatting if there is actually no fraction\n if (fraction.eq(0)) {\n return plainFormat.format(BigInt(pow10(minFD).toFixed())).slice(1);\n }\n\n // There are more digits in the number than in the formatting\n const value = fraction\n .toFixed()\n .slice(2)\n .split(\"\")\n .map(v => numbers[Number(v)])\n .join(\"\");\n\n if (value.length > maxFD) {\n return fraction\n .toDP(maxFD, rounding)\n .mul(pow10(maxFD))\n .toFixed()\n .split(\"\")\n .map(v => numbers[Number(v)])\n .join(\"\");\n }\n\n if (value.length < minFD) {\n return value + zeroFill(minFD - value.length);\n }\n\n return value;\n })();\n\n // 6.8. Parsing the numeric fragments in a unified part array\n const result: FormatPart[] = [];\n let integerDone = false;\n let fractionDone = false;\n\n while (ecmaParts.length) {\n const { type, value } = ecmaParts.shift()!;\n\n if (type === \"integer\" || type === \"group\") {\n if (!integerDone) {\n integerDone = true;\n result.push(...integerParts);\n }\n continue;\n }\n\n if (type === \"fraction\") {\n if (!fractionDone) {\n fractionDone = true;\n result.push({ type, value: fractionValue });\n }\n continue;\n }\n\n result.push({ type, value });\n }\n return result;\n };\n //#endregion\n\n this.format = value => concatenate(_formatToParts(value));\n this.formatToParts = value => _formatToParts(value);\n this.resolvedOptions = () => ({ ...resolved });\n }\n\n /**\n * Returns an array containing the default locales available to the environment, based on a default\n * dictionary of locales and regions.\n *\n * This method is non-standard method that is not available on `Intl` formatters.\n *\n * @returns Array of strings with the available locales.\n */\n static supportedLocales() {\n return SUPPORTED_LOCALES;\n }\n\n /**\n * Returns an array containing those of the provided locales that are supported without having to fall back\n * to the runtime's default locale.\n *\n * @template TNotation Numeric notation of formatting.\n * @template TStyle Numeric style of formatting.\n * @param locales A string with a BCP 47 language tag, or an array of such strings. For the general form\n * and interpretation of the locales argument, see the [Intl page on\n * MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).\n * @param options Object used to configure the behavior of the string localization.\n * @returns Array of strings with the available locales.\n */\n static supportedLocalesOf<TNotation extends Notation = \"standard\", TStyle extends Style = \"decimal\">(\n locales: string | string[],\n options?: FormatOptions<TNotation, TStyle>,\n ) {\n return Intl.NumberFormat.supportedLocalesOf(locales, options ? toEcma(options) : undefined) as Locale[];\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace DecimalFormat {\n export type {\n BaseFormatOptions,\n CompactDisplay,\n Currency,\n CurrencyDisplay,\n CurrencySign,\n Locale,\n LocaleMatcher,\n Notation,\n NumberingSystem,\n FormatOptions,\n FormatPart,\n FormatPartTypes,\n ResolvedFormatOptions,\n SignDisplay,\n Style,\n TrailingZeroDisplay,\n Unit,\n UnitDisplay,\n UseGrouping,\n };\n}\n\nexport default DecimalFormat;\n","/*!\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 */\n/* eslint-disable @typescript-eslint/naming-convention,@typescript-eslint/no-unsafe-argument */\nimport Decimal from \"decimal.js\";\nimport Format from \"./format\";\nimport type { Locale, FormatOptions, Notation, Style } from \"./format\";\n\nconst main = (Decimal: Decimal.Constructor) => {\n // Do not attempt to redefine the module, if already extended\n if (typeof Decimal.Format !== \"undefined\") {\n return;\n }\n\n Object.defineProperty(Decimal, \"Format\", { value: Format });\n Object.defineProperty(Decimal.prototype, \"toLocaleString\", {\n value: function (this: Decimal.Instance, locales, options) {\n return new Decimal.Format(locales, options).format(this);\n } as typeof Decimal.prototype.toLocaleString,\n });\n};\n\nmain(globalThis.__Decimal__Class__Global__ ?? require(\"decimal.js\"));\n\ndeclare module \"decimal.js\" {\n export interface Decimal {\n /**\n * Returns a string with a language-sensitive representation of this decimal number.\n *\n * @template N Numeric notation of formatting.\n * @template S Numeric style of formatting.\n * @param locales A string with a [BCP 47](https://www.rfc-editor.org/info/bcp47) language tag, or an\n * array of such strings.\n *\n * For the general form and interpretation of this parameter, see the [Intl page on\n * MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).\n * @param options Object used to configure the behavior of the string localization.\n * @returns A localized and formatted string.\n */\n toLocaleString: <N extends Notation = \"standard\", S extends Style = \"decimal\">(\n locales?: Locale | Locale[],\n options?: FormatOptions<N, S>,\n ) => string;\n }\n\n // In order to appropriately represent the Format class, it needs to be placed on Decimal as a 'static' member:\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace Decimal {\n /**\n * The `Decimal.Format` object enables language-sensitive decimal number formatting. It is entirely\n * based on `Intl.NumberFormat`, with the options of the latter being 100% compatible with it.\n *\n * This class, however, extend the numeric digits constraints of `Intl.NumberFormat` from 21 to\n * 1000000000 in order to fully take advantage of the arbitrary-precision of `decimal.js`.\n */\n export { Format };\n }\n}\n\ndeclare global {\n export class globalThis {\n /** Used by the `extend` submodule to prevent it from loading directly from `decimal.js`. */\n static __Decimal__Class__Global__: Decimal.Constructor | undefined;\n }\n}\nexport { Decimal };\nexport default Decimal;\n"],"names":["BIGINT_MODIFIERS","maximumFractionDigits","minimumFractionDigits","maximumSignificantDigits","undefined","minimumSignificantDigits","notation","style","PLAIN_MODIFIERS","minimumIntegerDigits","signDisplay","DECIMAL_LIMIT","ECMA_LIMIT","DEFAULT_OPTIONS","compactDisplay","currencyDisplay","currencySign","rounding","Decimal","ROUND_HALF_UP","unitDisplay","trailingZeroDisplay","LOCALES","extend","options","modifiers","assign","resolve","forEachDigitsProperty","property","result","Math","max","ecma","concatenate","filter","parts","pow10","exponent","pow","Symbol","toPrimitive","DecimalFormat","toStringTag","formatToParts","resolvedOptions","locales","valid","RangeError","join","length","ecmaOptions","ecmaFormat","Intl","NumberFormat","minID","resolved","bigintOptions","bigintFormat","plainOptions","plainFormat","numbers","Array","fill","map","_","index","format","numberMatch","RegExp","minusSign","zero","one","indexOfValue","value","indexOf","toString","convert","text","replaceAll","zeroFill","size","zeroTrim","mode","count","slice","_formatToParts","sign","ecmaParts","toNumber","isFinite","isNaN","ecmaExponentValue","exponents","ecmaIntegerParts","integerGroups","ecmaIntegerTrimmed","integers","ecmaIntegerDigits","ecmaIntegerTrimmedDigits","ecmaFractionValue","fractions","ecmaFractionDigits","eq","baseInteger","abs","trunc","toFixed","baseIntegerDigits","correctionDigits","mul","exponential","fraction","sub","integerDigits","integer","fractionDigits","dp","maxFD","minFD","minSD","integerCheck","fractionCheck","integerParts","targetDigits","bigint","BigInt","bigintIntegerParts","replace","fractionValue","v","Number","main","Format","Object","defineProperty","prototype"],"mappings":";;;AAAA;;;;AAaI;;AACA,MAAAA,mBAAmC;AACnCC,EAAAA,qBAAoB,EAAA,CADe;AAEnCC,EAAAA,qBAAgB,EAAA,CAFmB;AAG5BC,EAAAA,wBAAA,EAAAC,SAH4B;AAK8DC,EAAAA,wBAAA,EAAAD,SAL9D;AAMjCE,EAAAA,QAAO,EAAA,UAN0B;AAOnCC,EAAAA,KAAA,EAAA,SAAA;AAPmC,CAAnC,CAAA;;;AAYuF,MAAAC,eAAA,GAAA;AAC3FC,EAAAA,oBAA0B,EAAA,CADiE;AAG3FC,EAAAA,WAAA,EAAA,OAH2F;;AAAA,CAAA,CAAA;AAO3F;;AAEuD,MAAAC,aAAA,GAAA,GAAA,CAAA;AAEnD;;;;;AAIA,MAAAC,UAAA,KAAA,CAAA;AAEA;;AACA,MAAAC,eAAwB,GAAG;AAC3BC,EAAAA,cAAoB,EAAA,OADO;AAE3BC,EAAAA,eAAiB,EAAA,QAFU;AAG3BC,EAAAA,cAAmB,UAHQ;AAI3Bf,EAAAA,qBAAgB,EAAA,GAJW;AAK3BC,EAAAA,qBAAoB,EAAA,CALO;AAM3BO,EAAAA,sBAA2B,CANA;AAOpBN,EAAAA,wBAAA,EAAA,GAPoB;AAS2EE,EAAAA,wBAAA,EAAA,CAT3E;AAUzBC,EAAAA,QAAO,EAAA,UAVkB;EAW3BW,QAAK,EAAAC,OAAA,CAAAC,aAXsB;AAY3BT,EAAAA,WAAK,EAAA,MAZsB;AAa3BH,EAAAA,KAAK,EAAA,SAbsB;AAc3Ba,EAAAA,WAAK,EAAA,OAdsB;AAe3BC,EAAAA,mBAAK,EAAA,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