@formatjs/ecma402-abstract 1.0.3 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/262.d.ts +79 -0
- package/262.d.ts.map +1 -0
- package/262.js +336 -0
- package/_validate_dist-base_options.optionsvalid.d.ts +2 -1
- package/_validate_dist-esm_options.optionsvalid.d.ts +2 -1
- package/index.d.ts +33 -0
- package/index.d.ts.map +1 -1
- package/index.js +52 -11
- package/lib/262.d.ts +79 -0
- package/lib/262.d.ts.map +1 -0
- package/lib/262.js +312 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +33 -0
- package/lib/src/CanonicalizeLocaleList.d.ts +6 -0
- package/lib/src/CanonicalizeLocaleList.d.ts.map +1 -0
- package/lib/src/CanonicalizeLocaleList.js +8 -0
- package/lib/src/CanonicalizeTimeZoneName.d.ts +9 -0
- package/lib/src/CanonicalizeTimeZoneName.d.ts.map +1 -0
- package/lib/src/CanonicalizeTimeZoneName.js +17 -0
- package/lib/src/DateTimeFormat/BasicFormatMatcher.d.ts +8 -0
- package/lib/src/DateTimeFormat/BasicFormatMatcher.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/BasicFormatMatcher.js +61 -0
- package/lib/src/DateTimeFormat/BestFitFormatMatcher.d.ts +17 -0
- package/lib/src/DateTimeFormat/BestFitFormatMatcher.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/BestFitFormatMatcher.js +119 -0
- package/lib/src/DateTimeFormat/DateTimeStyleFormat.d.ts +3 -0
- package/lib/src/DateTimeFormat/DateTimeStyleFormat.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/DateTimeStyleFormat.js +50 -0
- package/lib/src/DateTimeFormat/FormatDateTime.d.ts +8 -0
- package/lib/src/DateTimeFormat/FormatDateTime.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/FormatDateTime.js +15 -0
- package/lib/src/DateTimeFormat/FormatDateTimeToParts.d.ts +10 -0
- package/lib/src/DateTimeFormat/FormatDateTimeToParts.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/FormatDateTimeToParts.js +21 -0
- package/lib/src/DateTimeFormat/InitializeDateTimeFormat.d.ts +18 -0
- package/lib/src/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/InitializeDateTimeFormat.js +163 -0
- package/lib/src/DateTimeFormat/PartitionDateTimePattern.d.ts +13 -0
- package/lib/src/DateTimeFormat/PartitionDateTimePattern.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/PartitionDateTimePattern.js +176 -0
- package/lib/src/DateTimeFormat/ToDateTimeOptions.d.ts +9 -0
- package/lib/src/DateTimeFormat/ToDateTimeOptions.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/ToDateTimeOptions.js +57 -0
- package/lib/src/DateTimeFormat/ToLocalTime.d.ts +24 -0
- package/lib/src/DateTimeFormat/ToLocalTime.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/ToLocalTime.js +49 -0
- package/lib/src/DateTimeFormat/skeleton.d.ts +9 -0
- package/lib/src/DateTimeFormat/skeleton.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/skeleton.js +163 -0
- package/lib/src/DateTimeFormat/utils.d.ts +10 -0
- package/lib/src/DateTimeFormat/utils.d.ts.map +1 -0
- package/lib/src/DateTimeFormat/utils.js +18 -0
- package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts +2 -0
- package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +1 -0
- package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.js +33 -0
- package/lib/src/GetOption.js +1 -1
- package/lib/src/IsValidTimeZoneName.d.ts +10 -0
- package/lib/src/IsValidTimeZoneName.d.ts.map +1 -0
- package/lib/src/IsValidTimeZoneName.js +11 -0
- package/lib/src/NumberFormat/ComputeExponent.d.ts +12 -0
- package/lib/src/NumberFormat/ComputeExponent.d.ts.map +1 -0
- package/lib/src/NumberFormat/ComputeExponent.js +39 -0
- package/lib/src/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
- package/lib/src/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
- package/lib/src/NumberFormat/ComputeExponentForMagnitude.js +60 -0
- package/lib/src/NumberFormat/CurrencyDigits.d.ts +7 -0
- package/lib/src/NumberFormat/CurrencyDigits.d.ts.map +1 -0
- package/lib/src/NumberFormat/CurrencyDigits.js +10 -0
- package/lib/src/NumberFormat/FormatNumericToParts.d.ts +5 -0
- package/lib/src/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
- package/lib/src/NumberFormat/FormatNumericToParts.js +14 -0
- package/lib/src/NumberFormat/FormatNumericToString.js +1 -1
- package/lib/src/NumberFormat/InitializeNumberFormat.d.ts +13 -0
- package/lib/src/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
- package/lib/src/NumberFormat/InitializeNumberFormat.js +71 -0
- package/lib/src/NumberFormat/PartitionNumberPattern.d.ts +8 -0
- package/lib/src/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
- package/lib/src/NumberFormat/PartitionNumberPattern.js +74 -0
- package/lib/src/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
- package/lib/src/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
- package/lib/src/NumberFormat/SetNumberFormatUnitOptions.js +39 -0
- package/lib/src/NumberFormat/digit-mapping.json +1 -0
- package/lib/src/NumberFormat/format_to_parts.d.ts +22 -0
- package/lib/src/NumberFormat/format_to_parts.d.ts.map +1 -0
- package/lib/src/NumberFormat/format_to_parts.js +421 -0
- package/lib/src/PluralRules/GetOperands.d.ts +32 -0
- package/lib/src/PluralRules/GetOperands.d.ts.map +1 -0
- package/lib/src/PluralRules/GetOperands.js +47 -0
- package/lib/src/PluralRules/InitializePluralRules.d.ts +9 -0
- package/lib/src/PluralRules/InitializePluralRules.d.ts.map +1 -0
- package/lib/src/PluralRules/InitializePluralRules.js +20 -0
- package/lib/src/PluralRules/ResolvePlural.d.ts +13 -0
- package/lib/src/PluralRules/ResolvePlural.d.ts.map +1 -0
- package/lib/src/PluralRules/ResolvePlural.js +25 -0
- package/lib/src/RelativeTimeFormat/FormatRelativeTime.d.ts +5 -0
- package/lib/src/RelativeTimeFormat/FormatRelativeTime.d.ts.map +1 -0
- package/lib/src/RelativeTimeFormat/FormatRelativeTime.js +10 -0
- package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +5 -0
- package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +1 -0
- package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.js +18 -0
- package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +9 -0
- package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +1 -0
- package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.js +32 -0
- package/lib/src/RelativeTimeFormat/MakePartsList.d.ts +3 -0
- package/lib/src/RelativeTimeFormat/MakePartsList.d.ts.map +1 -0
- package/lib/src/RelativeTimeFormat/MakePartsList.js +27 -0
- package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +5 -0
- package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +1 -0
- package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.js +54 -0
- package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +7 -0
- package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +1 -0
- package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.js +36 -0
- package/lib/src/SupportedLocales.js +1 -1
- package/lib/src/data.js +1 -1
- package/lib/types/core.js +1 -0
- package/lib/types/date-time.d.ts +112 -0
- package/lib/types/date-time.d.ts.map +1 -0
- package/lib/types/date-time.js +1 -0
- package/lib/types/displaynames.js +1 -0
- package/lib/types/list.js +1 -0
- package/lib/types/number.d.ts +44 -0
- package/lib/types/number.d.ts.map +1 -1
- package/lib/types/number.js +1 -0
- package/lib/types/plural-rules.d.ts +6 -0
- package/lib/types/plural-rules.d.ts.map +1 -1
- package/lib/types/plural-rules.js +1 -0
- package/lib/types/relative-time.d.ts +63 -0
- package/lib/types/relative-time.d.ts.map +1 -1
- package/lib/types/relative-time.js +1 -0
- package/package.json +2 -6
- package/src/CanonicalizeLocaleList.d.ts +6 -0
- package/src/CanonicalizeLocaleList.d.ts.map +1 -0
- package/src/CanonicalizeLocaleList.js +12 -0
- package/src/CanonicalizeTimeZoneName.d.ts +9 -0
- package/src/CanonicalizeTimeZoneName.d.ts.map +1 -0
- package/src/CanonicalizeTimeZoneName.js +21 -0
- package/src/DateTimeFormat/BasicFormatMatcher.d.ts +8 -0
- package/src/DateTimeFormat/BasicFormatMatcher.d.ts.map +1 -0
- package/src/DateTimeFormat/BasicFormatMatcher.js +65 -0
- package/src/DateTimeFormat/BestFitFormatMatcher.d.ts +17 -0
- package/src/DateTimeFormat/BestFitFormatMatcher.d.ts.map +1 -0
- package/src/DateTimeFormat/BestFitFormatMatcher.js +124 -0
- package/src/DateTimeFormat/DateTimeStyleFormat.d.ts +3 -0
- package/src/DateTimeFormat/DateTimeStyleFormat.d.ts.map +1 -0
- package/src/DateTimeFormat/DateTimeStyleFormat.js +54 -0
- package/src/DateTimeFormat/FormatDateTime.d.ts +8 -0
- package/src/DateTimeFormat/FormatDateTime.d.ts.map +1 -0
- package/src/DateTimeFormat/FormatDateTime.js +19 -0
- package/src/DateTimeFormat/FormatDateTimeToParts.d.ts +10 -0
- package/src/DateTimeFormat/FormatDateTimeToParts.d.ts.map +1 -0
- package/src/DateTimeFormat/FormatDateTimeToParts.js +25 -0
- package/src/DateTimeFormat/InitializeDateTimeFormat.d.ts +18 -0
- package/src/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +1 -0
- package/src/DateTimeFormat/InitializeDateTimeFormat.js +167 -0
- package/src/DateTimeFormat/PartitionDateTimePattern.d.ts +13 -0
- package/src/DateTimeFormat/PartitionDateTimePattern.d.ts.map +1 -0
- package/src/DateTimeFormat/PartitionDateTimePattern.js +180 -0
- package/src/DateTimeFormat/ToDateTimeOptions.d.ts +9 -0
- package/src/DateTimeFormat/ToDateTimeOptions.d.ts.map +1 -0
- package/src/DateTimeFormat/ToDateTimeOptions.js +61 -0
- package/src/DateTimeFormat/ToLocalTime.d.ts +24 -0
- package/src/DateTimeFormat/ToLocalTime.d.ts.map +1 -0
- package/src/DateTimeFormat/ToLocalTime.js +53 -0
- package/src/DateTimeFormat/skeleton.d.ts +9 -0
- package/src/DateTimeFormat/skeleton.d.ts.map +1 -0
- package/src/DateTimeFormat/skeleton.js +167 -0
- package/src/DateTimeFormat/utils.d.ts +10 -0
- package/src/DateTimeFormat/utils.d.ts.map +1 -0
- package/src/DateTimeFormat/utils.js +21 -0
- package/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts +2 -0
- package/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +1 -0
- package/src/DisplayNames/CanonicalCodeForDisplayNames.js +37 -0
- package/src/GetOption.js +2 -5
- package/src/IsValidTimeZoneName.d.ts +10 -0
- package/src/IsValidTimeZoneName.d.ts.map +1 -0
- package/src/IsValidTimeZoneName.js +15 -0
- package/src/NumberFormat/ComputeExponent.d.ts +12 -0
- package/src/NumberFormat/ComputeExponent.d.ts.map +1 -0
- package/src/NumberFormat/ComputeExponent.js +43 -0
- package/src/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
- package/src/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
- package/src/NumberFormat/ComputeExponentForMagnitude.js +64 -0
- package/src/NumberFormat/CurrencyDigits.d.ts +7 -0
- package/src/NumberFormat/CurrencyDigits.d.ts.map +1 -0
- package/src/NumberFormat/CurrencyDigits.js +14 -0
- package/src/NumberFormat/FormatNumericToParts.d.ts +5 -0
- package/src/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
- package/src/NumberFormat/FormatNumericToParts.js +18 -0
- package/src/NumberFormat/FormatNumericToString.js +2 -5
- package/src/NumberFormat/InitializeNumberFormat.d.ts +13 -0
- package/src/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
- package/src/NumberFormat/InitializeNumberFormat.js +75 -0
- package/src/NumberFormat/PartitionNumberPattern.d.ts +8 -0
- package/src/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
- package/src/NumberFormat/PartitionNumberPattern.js +81 -0
- package/src/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
- package/src/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
- package/src/NumberFormat/SetNumberFormatUnitOptions.js +43 -0
- package/src/NumberFormat/digit-mapping.json +1 -0
- package/src/NumberFormat/format_to_parts.d.ts +22 -0
- package/src/NumberFormat/format_to_parts.d.ts.map +1 -0
- package/src/NumberFormat/format_to_parts.js +443 -0
- package/src/PluralRules/GetOperands.d.ts +32 -0
- package/src/PluralRules/GetOperands.d.ts.map +1 -0
- package/src/PluralRules/GetOperands.js +51 -0
- package/src/PluralRules/InitializePluralRules.d.ts +9 -0
- package/src/PluralRules/InitializePluralRules.d.ts.map +1 -0
- package/src/PluralRules/InitializePluralRules.js +24 -0
- package/src/PluralRules/ResolvePlural.d.ts +13 -0
- package/src/PluralRules/ResolvePlural.d.ts.map +1 -0
- package/src/PluralRules/ResolvePlural.js +29 -0
- package/src/RelativeTimeFormat/FormatRelativeTime.d.ts +5 -0
- package/src/RelativeTimeFormat/FormatRelativeTime.d.ts.map +1 -0
- package/src/RelativeTimeFormat/FormatRelativeTime.js +14 -0
- package/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +5 -0
- package/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +1 -0
- package/src/RelativeTimeFormat/FormatRelativeTimeToParts.js +22 -0
- package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +9 -0
- package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +1 -0
- package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.js +36 -0
- package/src/RelativeTimeFormat/MakePartsList.d.ts +3 -0
- package/src/RelativeTimeFormat/MakePartsList.d.ts.map +1 -0
- package/src/RelativeTimeFormat/MakePartsList.js +31 -0
- package/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +5 -0
- package/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +1 -0
- package/src/RelativeTimeFormat/PartitionRelativeTimePattern.js +58 -0
- package/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +7 -0
- package/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +1 -0
- package/src/RelativeTimeFormat/SingularRelativeTimeUnit.js +40 -0
- package/src/SupportedLocales.js +2 -5
- package/src/data.js +1 -1
- package/types/date-time.d.ts +112 -0
- package/types/date-time.d.ts.map +1 -0
- package/types/date-time.js +2 -0
- package/types/number.d.ts +44 -0
- package/types/number.d.ts.map +1 -1
- package/types/plural-rules.d.ts +6 -0
- package/types/plural-rules.d.ts.map +1 -1
- package/types/relative-time.d.ts +63 -0
- package/types/relative-time.d.ts.map +1 -1
- package/types.js +1 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CanonicalizeLocaleList } from '../CanonicalizeLocaleList';
|
|
2
|
+
import { ToObject } from '../../262';
|
|
3
|
+
import { GetOption } from '../GetOption';
|
|
4
|
+
import { ResolveLocale } from '../ResolveLocale';
|
|
5
|
+
import { SetNumberFormatUnitOptions } from './SetNumberFormatUnitOptions';
|
|
6
|
+
import { CurrencyDigits } from './CurrencyDigits';
|
|
7
|
+
import { SetNumberFormatDigitOptions } from './SetNumberFormatDigitOptions';
|
|
8
|
+
/**
|
|
9
|
+
* Chop off the unicode extension from the locale string.
|
|
10
|
+
*/
|
|
11
|
+
function removeUnicodeExtensionFromLocale(canonicalLocale) {
|
|
12
|
+
var extensionIndex = canonicalLocale.indexOf('-u-');
|
|
13
|
+
return extensionIndex >= 0
|
|
14
|
+
? canonicalLocale.slice(0, extensionIndex)
|
|
15
|
+
: canonicalLocale;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* https://tc39.es/ecma402/#sec-initializenumberformat
|
|
19
|
+
*/
|
|
20
|
+
export function InitializeNumberFormat(nf, locales, opts, _a) {
|
|
21
|
+
var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, availableLocales = _a.availableLocales, numberingSystemNames = _a.numberingSystemNames, getDefaultLocale = _a.getDefaultLocale, currencyDigitsData = _a.currencyDigitsData;
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
24
|
+
var options = opts === undefined ? Object.create(null) : ToObject(opts);
|
|
25
|
+
var opt = Object.create(null);
|
|
26
|
+
var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
|
27
|
+
opt.localeMatcher = matcher;
|
|
28
|
+
var numberingSystem = GetOption(options, 'numberingSystem', 'string', undefined, undefined);
|
|
29
|
+
if (numberingSystem !== undefined &&
|
|
30
|
+
numberingSystemNames.indexOf(numberingSystem) < 0) {
|
|
31
|
+
// 8.a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal,
|
|
32
|
+
// throw a RangeError exception.
|
|
33
|
+
throw RangeError("Invalid numberingSystems: " + numberingSystem);
|
|
34
|
+
}
|
|
35
|
+
opt.nu = numberingSystem;
|
|
36
|
+
var r = ResolveLocale(availableLocales, requestedLocales, opt,
|
|
37
|
+
// [[RelevantExtensionKeys]] slot, which is a constant
|
|
38
|
+
['nu'], localeData, getDefaultLocale);
|
|
39
|
+
var dataLocaleData = localeData[removeUnicodeExtensionFromLocale(r.locale)];
|
|
40
|
+
var internalSlots = getInternalSlots(nf);
|
|
41
|
+
internalSlots.locale = r.locale;
|
|
42
|
+
internalSlots.dataLocale = r.dataLocale;
|
|
43
|
+
internalSlots.numberingSystem = r.nu;
|
|
44
|
+
internalSlots.dataLocaleData = dataLocaleData;
|
|
45
|
+
SetNumberFormatUnitOptions(nf, options, { getInternalSlots: getInternalSlots });
|
|
46
|
+
var style = internalSlots.style;
|
|
47
|
+
var mnfdDefault;
|
|
48
|
+
var mxfdDefault;
|
|
49
|
+
if (style === 'currency') {
|
|
50
|
+
var currency = internalSlots.currency;
|
|
51
|
+
var cDigits = CurrencyDigits(currency, { currencyDigitsData: currencyDigitsData });
|
|
52
|
+
mnfdDefault = cDigits;
|
|
53
|
+
mxfdDefault = cDigits;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
mnfdDefault = 0;
|
|
57
|
+
mxfdDefault = style === 'percent' ? 0 : 3;
|
|
58
|
+
}
|
|
59
|
+
var notation = GetOption(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
|
|
60
|
+
internalSlots.notation = notation;
|
|
61
|
+
SetNumberFormatDigitOptions(internalSlots, options, mnfdDefault, mxfdDefault, notation);
|
|
62
|
+
var compactDisplay = GetOption(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
|
|
63
|
+
if (notation === 'compact') {
|
|
64
|
+
internalSlots.compactDisplay = compactDisplay;
|
|
65
|
+
}
|
|
66
|
+
var useGrouping = GetOption(options, 'useGrouping', 'boolean', undefined, true);
|
|
67
|
+
internalSlots.useGrouping = useGrouping;
|
|
68
|
+
var signDisplay = GetOption(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero'], 'auto');
|
|
69
|
+
internalSlots.signDisplay = signDisplay;
|
|
70
|
+
return nf;
|
|
71
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberFormatInternal } from '../../types/number';
|
|
2
|
+
/**
|
|
3
|
+
* https://tc39.es/ecma402/#sec-formatnumberstring
|
|
4
|
+
*/
|
|
5
|
+
export declare function PartitionNumberPattern(numberFormat: Intl.NumberFormat, x: number, { getInternalSlots, }: {
|
|
6
|
+
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
7
|
+
}): import("../../types/number").NumberFormatPart[];
|
|
8
|
+
//# sourceMappingURL=PartitionNumberPattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PartitionNumberPattern.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/NumberFormat/PartitionNumberPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAMxD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAC;CAC/D,mDAqEF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FormatNumericToString } from './FormatNumericToString';
|
|
2
|
+
import { SameValue } from '../../262';
|
|
3
|
+
import { ComputeExponent } from './ComputeExponent';
|
|
4
|
+
import formatToParts from './format_to_parts';
|
|
5
|
+
/**
|
|
6
|
+
* https://tc39.es/ecma402/#sec-formatnumberstring
|
|
7
|
+
*/
|
|
8
|
+
export function PartitionNumberPattern(numberFormat, x, _a) {
|
|
9
|
+
var _b;
|
|
10
|
+
var getInternalSlots = _a.getInternalSlots;
|
|
11
|
+
var internalSlots = getInternalSlots(numberFormat);
|
|
12
|
+
var pl = internalSlots.pl, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
|
|
13
|
+
var symbols = dataLocaleData.numbers.symbols[numberingSystem] ||
|
|
14
|
+
dataLocaleData.numbers.symbols[dataLocaleData.numbers.nu[0]];
|
|
15
|
+
var magnitude = 0;
|
|
16
|
+
var exponent = 0;
|
|
17
|
+
var n;
|
|
18
|
+
if (isNaN(x)) {
|
|
19
|
+
n = symbols.nan;
|
|
20
|
+
}
|
|
21
|
+
else if (!isFinite(x)) {
|
|
22
|
+
n = symbols.infinity;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (internalSlots.style === 'percent') {
|
|
26
|
+
x *= 100;
|
|
27
|
+
}
|
|
28
|
+
_b = ComputeExponent(numberFormat, x, {
|
|
29
|
+
getInternalSlots: getInternalSlots,
|
|
30
|
+
}), exponent = _b[0], magnitude = _b[1];
|
|
31
|
+
// Preserve more precision by doing multiplication when exponent is negative.
|
|
32
|
+
x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
|
|
33
|
+
var formatNumberResult = FormatNumericToString(internalSlots, x);
|
|
34
|
+
n = formatNumberResult.formattedString;
|
|
35
|
+
x = formatNumberResult.roundedNumber;
|
|
36
|
+
}
|
|
37
|
+
// Based on https://tc39.es/ecma402/#sec-getnumberformatpattern
|
|
38
|
+
// We need to do this before `x` is rounded.
|
|
39
|
+
var sign;
|
|
40
|
+
var signDisplay = internalSlots.signDisplay;
|
|
41
|
+
switch (signDisplay) {
|
|
42
|
+
case 'never':
|
|
43
|
+
sign = 0;
|
|
44
|
+
break;
|
|
45
|
+
case 'auto':
|
|
46
|
+
if (SameValue(x, 0) || x > 0 || isNaN(x)) {
|
|
47
|
+
sign = 0;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
sign = -1;
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case 'always':
|
|
54
|
+
if (SameValue(x, 0) || x > 0 || isNaN(x)) {
|
|
55
|
+
sign = 1;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
sign = -1;
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
// x === 0 -> x is 0 or x is -0
|
|
63
|
+
if (x === 0 || isNaN(x)) {
|
|
64
|
+
sign = 0;
|
|
65
|
+
}
|
|
66
|
+
else if (x > 0) {
|
|
67
|
+
sign = 1;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
sign = -1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return formatToParts({ roundedNumber: x, formattedString: n, exponent: exponent, magnitude: magnitude, sign: sign }, internalSlots.dataLocaleData, pl, internalSlots);
|
|
74
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NumberFormatInternal, NumberFormatOptions } from '../../types/number';
|
|
2
|
+
/**
|
|
3
|
+
* https://tc39.es/ecma402/#sec-setnumberformatunitoptions
|
|
4
|
+
*/
|
|
5
|
+
export declare function SetNumberFormatUnitOptions(nf: Intl.NumberFormat, options: NumberFormatOptions | undefined, { getInternalSlots, }: {
|
|
6
|
+
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
7
|
+
}): void;
|
|
8
|
+
//# sourceMappingURL=SetNumberFormatUnitOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetNumberFormatUnitOptions.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/NumberFormat/SetNumberFormatUnitOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAK7E;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,OAAO,iCAA2C,EAClD,EACE,gBAAgB,GACjB,EAAE;IAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAAC,QA+DnE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { GetOption } from '../GetOption';
|
|
2
|
+
import { IsWellFormedCurrencyCode } from '../IsWellFormedCurrencyCode';
|
|
3
|
+
import { IsWellFormedUnitIdentifier } from '../IsWellFormedUnitIdentifier';
|
|
4
|
+
/**
|
|
5
|
+
* https://tc39.es/ecma402/#sec-setnumberformatunitoptions
|
|
6
|
+
*/
|
|
7
|
+
export function SetNumberFormatUnitOptions(nf, options, _a) {
|
|
8
|
+
if (options === void 0) { options = Object.create(null); }
|
|
9
|
+
var getInternalSlots = _a.getInternalSlots;
|
|
10
|
+
var internalSlots = getInternalSlots(nf);
|
|
11
|
+
var style = GetOption(options, 'style', 'string', ['decimal', 'percent', 'currency', 'unit'], 'decimal');
|
|
12
|
+
internalSlots.style = style;
|
|
13
|
+
var currency = GetOption(options, 'currency', 'string', undefined, undefined);
|
|
14
|
+
if (currency !== undefined && !IsWellFormedCurrencyCode(currency)) {
|
|
15
|
+
throw RangeError('Malformed currency code');
|
|
16
|
+
}
|
|
17
|
+
if (style === 'currency' && currency === undefined) {
|
|
18
|
+
throw TypeError('currency cannot be undefined');
|
|
19
|
+
}
|
|
20
|
+
var currencyDisplay = GetOption(options, 'currencyDisplay', 'string', ['code', 'symbol', 'narrowSymbol', 'name'], 'symbol');
|
|
21
|
+
var currencySign = GetOption(options, 'currencySign', 'string', ['standard', 'accounting'], 'standard');
|
|
22
|
+
var unit = GetOption(options, 'unit', 'string', undefined, undefined);
|
|
23
|
+
if (unit !== undefined && !IsWellFormedUnitIdentifier(unit)) {
|
|
24
|
+
throw RangeError('Invalid unit argument for Intl.NumberFormat()');
|
|
25
|
+
}
|
|
26
|
+
if (style === 'unit' && unit === undefined) {
|
|
27
|
+
throw TypeError('unit cannot be undefined');
|
|
28
|
+
}
|
|
29
|
+
var unitDisplay = GetOption(options, 'unitDisplay', 'string', ['short', 'narrow', 'long'], 'short');
|
|
30
|
+
if (style === 'currency') {
|
|
31
|
+
internalSlots.currency = currency.toUpperCase();
|
|
32
|
+
internalSlots.currencyDisplay = currencyDisplay;
|
|
33
|
+
internalSlots.currencySign = currencySign;
|
|
34
|
+
}
|
|
35
|
+
if (style === 'unit') {
|
|
36
|
+
internalSlots.unit = unit;
|
|
37
|
+
internalSlots.unitDisplay = unitDisplay;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "adlm": ["𞥐", "𞥑", "𞥒", "𞥓", "𞥔", "𞥕", "𞥖", "𞥗", "𞥘", "𞥙"], "ahom": ["𑜰", "𑜱", "𑜲", "𑜳", "𑜴", "𑜵", "𑜶", "𑜷", "𑜸", "𑜹"], "arab": ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"], "arabext": ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"], "bali": ["᭐", "᭑", "᭒", "᭓", "᭔", "᭕", "᭖", "᭗", "᭘", "᭙"], "beng": ["০", "১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯"], "bhks": ["𑱐", "𑱑", "𑱒", "𑱓", "𑱔", "𑱕", "𑱖", "𑱗", "𑱘", "𑱙"], "brah": ["𑁦", "𑁧", "𑁨", "𑁩", "𑁪", "𑁫", "𑁬", "𑁭", "𑁮", "𑁯"], "cakm": ["𑄶", "𑄷", "𑄸", "𑄹", "𑄺", "𑄻", "𑄼", "𑄽", "𑄾", "𑄿"], "cham": ["꩐", "꩑", "꩒", "꩓", "꩔", "꩕", "꩖", "꩗", "꩘", "꩙"], "deva": ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"], "diak": ["𑥐", "𑥑", "𑥒", "𑥓", "𑥔", "𑥕", "𑥖", "𑥗", "𑥘", "𑥙"], "fullwide": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], "gong": ["𑶠", "𑶡", "𑶢", "𑶣", "𑶤", "𑶥", "𑶦", "𑶧", "𑶨", "𑶩"], "gonm": ["𑵐", "𑵑", "𑵒", "𑵓", "𑵔", "𑵕", "𑵖", "𑵗", "𑵘", "𑵙"], "gujr": ["૦", "૧", "૨", "૩", "૪", "૫", "૬", "૭", "૮", "૯"], "guru": ["੦", "੧", "੨", "੩", "੪", "੫", "੬", "੭", "੮", "੯"], "hanidec": ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"], "hmng": ["𖭐", "𖭑", "𖭒", "𖭓", "𖭔", "𖭕", "𖭖", "𖭗", "𖭘", "𖭙"], "hmnp": ["𞅀", "𞅁", "𞅂", "𞅃", "𞅄", "𞅅", "𞅆", "𞅇", "𞅈", "𞅉"], "java": ["꧐", "꧑", "꧒", "꧓", "꧔", "꧕", "꧖", "꧗", "꧘", "꧙"], "kali": ["꤀", "꤁", "꤂", "꤃", "꤄", "꤅", "꤆", "꤇", "꤈", "꤉"], "khmr": ["០", "១", "២", "៣", "៤", "៥", "៦", "៧", "៨", "៩"], "knda": ["೦", "೧", "೨", "೩", "೪", "೫", "೬", "೭", "೮", "೯"], "lana": ["᪀", "᪁", "᪂", "᪃", "᪄", "᪅", "᪆", "᪇", "᪈", "᪉"], "lanatham": ["᪐", "᪑", "᪒", "᪓", "᪔", "᪕", "᪖", "᪗", "᪘", "᪙"], "laoo": ["໐", "໑", "໒", "໓", "໔", "໕", "໖", "໗", "໘", "໙"], "lepc": ["᪐", "᪑", "᪒", "᪓", "᪔", "᪕", "᪖", "᪗", "᪘", "᪙"], "limb": ["᥆", "᥇", "᥈", "᥉", "᥊", "᥋", "᥌", "᥍", "᥎", "᥏"], "mathbold": ["𝟎", "𝟏", "𝟐", "𝟑", "𝟒", "𝟓", "𝟔", "𝟕", "𝟖", "𝟗"], "mathdbl": ["𝟘", "𝟙", "𝟚", "𝟛", "𝟜", "𝟝", "𝟞", "𝟟", "𝟠", "𝟡"], "mathmono": ["𝟶", "𝟷", "𝟸", "𝟹", "𝟺", "𝟻", "𝟼", "𝟽", "𝟾", "𝟿"], "mathsanb": ["𝟬", "𝟭", "𝟮", "𝟯", "𝟰", "𝟱", "𝟲", "𝟳", "𝟴", "𝟵"], "mathsans": ["𝟢", "𝟣", "𝟤", "𝟥", "𝟦", "𝟧", "𝟨", "𝟩", "𝟪", "𝟫"], "mlym": ["൦", "൧", "൨", "൩", "൪", "൫", "൬", "൭", "൮", "൯"], "modi": ["𑙐", "𑙑", "𑙒", "𑙓", "𑙔", "𑙕", "𑙖", "𑙗", "𑙘", "𑙙"], "mong": ["᠐", "᠑", "᠒", "᠓", "᠔", "᠕", "᠖", "᠗", "᠘", "᠙"], "mroo": ["𖩠", "𖩡", "𖩢", "𖩣", "𖩤", "𖩥", "𖩦", "𖩧", "𖩨", "𖩩"], "mtei": ["꯰", "꯱", "꯲", "꯳", "꯴", "꯵", "꯶", "꯷", "꯸", "꯹"], "mymr": ["၀", "၁", "၂", "၃", "၄", "၅", "၆", "၇", "၈", "၉"], "mymrshan": ["႐", "႑", "႒", "႓", "႔", "႕", "႖", "႗", "႘", "႙"], "mymrtlng": ["꧰", "꧱", "꧲", "꧳", "꧴", "꧵", "꧶", "꧷", "꧸", "꧹"], "newa": ["𑑐", "𑑑", "𑑒", "𑑓", "𑑔", "𑑕", "𑑖", "𑑗", "𑑘", "𑑙"], "nkoo": ["߀", "߁", "߂", "߃", "߄", "߅", "߆", "߇", "߈", "߉"], "olck": ["᱐", "᱑", "᱒", "᱓", "᱔", "᱕", "᱖", "᱗", "᱘", "᱙"], "orya": ["୦", "୧", "୨", "୩", "୪", "୫", "୬", "୭", "୮", "୯"], "osma": ["𐒠", "𐒡", "𐒢", "𐒣", "𐒤", "𐒥", "𐒦", "𐒧", "𐒨", "𐒩"], "rohg": ["𐴰", "𐴱", "𐴲", "𐴳", "𐴴", "𐴵", "𐴶", "𐴷", "𐴸", "𐴹"], "saur": ["꣐", "꣑", "꣒", "꣓", "꣔", "꣕", "꣖", "꣗", "꣘", "꣙"], "segment": ["🯰", "🯱", "🯲", "🯳", "🯴", "🯵", "🯶", "🯷", "🯸", "🯹"], "shrd": ["𑇐", "𑇑", "𑇒", "𑇓", "𑇔", "𑇕", "𑇖", "𑇗", "𑇘", "𑇙"], "sind": ["𑋰", "𑋱", "𑋲", "𑋳", "𑋴", "𑋵", "𑋶", "𑋷", "𑋸", "𑋹"], "sinh": ["෦", "෧", "෨", "෩", "෪", "෫", "෬", "෭", "෮", "෯"], "sora": ["𑃰", "𑃱", "𑃲", "𑃳", "𑃴", "𑃵", "𑃶", "𑃷", "𑃸", "𑃹"], "sund": ["᮰", "᮱", "᮲", "᮳", "᮴", "᮵", "᮶", "᮷", "᮸", "᮹"], "takr": ["𑛀", "𑛁", "𑛂", "𑛃", "𑛄", "𑛅", "𑛆", "𑛇", "𑛈", "𑛉"], "talu": ["᧐", "᧑", "᧒", "᧓", "᧔", "᧕", "᧖", "᧗", "᧘", "᧙"], "tamldec": ["௦", "௧", "௨", "௩", "௪", "௫", "௬", "௭", "௮", "௯"], "telu": ["౦", "౧", "౨", "౩", "౪", "౫", "౬", "౭", "౮", "౯"], "thai": ["๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙"], "tibt": ["༠", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩"], "tirh": ["𑓐", "𑓑", "𑓒", "𑓓", "𑓔", "𑓕", "𑓖", "𑓗", "𑓘", "𑓙"], "vaii": ["ᘠ", "ᘡ", "ᘢ", "ᘣ", "ᘤ", "ᘥ", "ᘦ", "ᘧ", "ᘨ", "ᘩ"], "wara": ["𑣠", "𑣡", "𑣢", "𑣣", "𑣤", "𑣥", "𑣦", "𑣧", "𑣨", "𑣩"], "wcho": ["𞋰", "𞋱", "𞋲", "𞋳", "𞋴", "𞋵", "𞋶", "𞋷", "𞋸", "𞋹"] }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NumberFormatOptionsStyle, NumberFormatOptionsNotation, NumberFormatOptionsCompactDisplay, NumberFormatOptionsCurrencyDisplay, NumberFormatOptionsCurrencySign, NumberFormatOptionsUnitDisplay, NumberFormatLocaleInternalData, NumberFormatPart } from '../../types/number';
|
|
2
|
+
interface NumberResult {
|
|
3
|
+
formattedString: string;
|
|
4
|
+
roundedNumber: number;
|
|
5
|
+
sign: -1 | 0 | 1;
|
|
6
|
+
exponent: number;
|
|
7
|
+
magnitude: number;
|
|
8
|
+
}
|
|
9
|
+
export default function formatToParts(numberResult: NumberResult, data: NumberFormatLocaleInternalData, pl: Intl.PluralRules, options: {
|
|
10
|
+
numberingSystem: string;
|
|
11
|
+
useGrouping: boolean;
|
|
12
|
+
style: NumberFormatOptionsStyle;
|
|
13
|
+
notation: NumberFormatOptionsNotation;
|
|
14
|
+
compactDisplay?: NumberFormatOptionsCompactDisplay;
|
|
15
|
+
currency?: string;
|
|
16
|
+
currencyDisplay?: NumberFormatOptionsCurrencyDisplay;
|
|
17
|
+
currencySign?: NumberFormatOptionsCurrencySign;
|
|
18
|
+
unit?: string;
|
|
19
|
+
unitDisplay?: NumberFormatOptionsUnitDisplay;
|
|
20
|
+
}): NumberFormatPart[];
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=format_to_parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format_to_parts.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/NumberFormat/format_to_parts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,+BAA+B,EAC/B,8BAA8B,EAC9B,8BAA8B,EAM9B,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAe5B,UAAU,YAAY;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,8BAA8B,EACpC,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,OAAO,EAAE;IACP,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,wBAAwB,CAAC;IAEhC,QAAQ,EAAE,2BAA2B,CAAC;IAEtC,cAAc,CAAC,EAAE,iCAAiC,CAAC;IAEnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,YAAY,CAAC,EAAE,+BAA+B,CAAC;IAE/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,8BAA8B,CAAC;CAC9C,GACA,gBAAgB,EAAE,CAySpB"}
|