@formatjs/ecma402-abstract 1.9.1 → 1.9.5
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/IsValidTimeZoneName.d.ts +1 -1
- package/IsValidTimeZoneName.d.ts.map +1 -1
- package/IsValidTimeZoneName.js +6 -1
- package/NumberFormat/InitializeNumberFormat.d.ts +2 -2
- package/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
- package/NumberFormat/InitializeNumberFormat.js +2 -2
- package/NumberFormat/digit-mapping.generated.d.ts +2 -0
- package/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
- package/NumberFormat/digit-mapping.generated.js +4 -0
- package/NumberFormat/format_to_parts.js +2 -3
- package/SupportedLocales.js +3 -3
- package/index.d.ts +1 -24
- package/index.d.ts.map +1 -1
- package/index.js +13 -39
- package/lib/IsValidTimeZoneName.d.ts +1 -1
- package/lib/IsValidTimeZoneName.d.ts.map +1 -1
- package/lib/IsValidTimeZoneName.js +6 -1
- package/lib/NumberFormat/InitializeNumberFormat.d.ts +2 -2
- package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +1 -1
- package/lib/NumberFormat/InitializeNumberFormat.js +1 -1
- package/lib/NumberFormat/digit-mapping.generated.d.ts +2 -0
- package/lib/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
- package/lib/NumberFormat/digit-mapping.generated.js +1 -0
- package/lib/NumberFormat/format_to_parts.js +1 -1
- package/lib/SupportedLocales.js +1 -1
- package/lib/index.d.ts +1 -24
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -24
- package/lib/types/date-time.d.ts +1 -0
- package/lib/types/date-time.d.ts.map +1 -1
- package/package.json +2 -1
- package/types/date-time.d.ts +1 -0
- package/types/date-time.d.ts.map +1 -1
- package/BestAvailableLocale.d.ts +0 -7
- package/BestAvailableLocale.d.ts.map +0 -1
- package/BestAvailableLocale.js +0 -25
- package/BestFitMatcher.d.ts +0 -9
- package/BestFitMatcher.d.ts.map +0 -1
- package/BestFitMatcher.js +0 -52
- package/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
- package/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
- package/DateTimeFormat/BasicFormatMatcher.js +0 -61
- package/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
- package/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
- package/DateTimeFormat/BestFitFormatMatcher.js +0 -121
- package/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
- package/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
- package/DateTimeFormat/DateTimeStyleFormat.js +0 -54
- package/DateTimeFormat/FormatDateTime.d.ts +0 -8
- package/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTime.js +0 -19
- package/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
- package/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTimePattern.js +0 -182
- package/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
- package/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTimeRange.js +0 -14
- package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
- package/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -18
- package/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
- package/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
- package/DateTimeFormat/FormatDateTimeToParts.js +0 -25
- package/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
- package/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
- package/DateTimeFormat/InitializeDateTimeFormat.js +0 -188
- package/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
- package/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
- package/DateTimeFormat/PartitionDateTimePattern.js +0 -24
- package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
- package/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
- package/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -125
- package/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
- package/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
- package/DateTimeFormat/ToDateTimeOptions.js +0 -67
- package/DateTimeFormat/ToLocalTime.d.ts +0 -26
- package/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
- package/DateTimeFormat/ToLocalTime.js +0 -55
- package/DateTimeFormat/skeleton.d.ts +0 -14
- package/DateTimeFormat/skeleton.d.ts.map +0 -1
- package/DateTimeFormat/skeleton.js +0 -301
- package/DateTimeFormat/utils.d.ts +0 -10
- package/DateTimeFormat/utils.d.ts.map +0 -1
- package/DateTimeFormat/utils.js +0 -21
- package/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
- package/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
- package/DisplayNames/CanonicalCodeForDisplayNames.js +0 -37
- package/LookupMatcher.d.ts +0 -9
- package/LookupMatcher.d.ts.map +0 -1
- package/LookupMatcher.js +0 -29
- package/LookupSupportedLocales.d.ts +0 -7
- package/LookupSupportedLocales.d.ts.map +0 -1
- package/LookupSupportedLocales.js +0 -23
- package/NumberFormat/digit-mapping.json +0 -1
- package/PluralRules/GetOperands.d.ts +0 -32
- package/PluralRules/GetOperands.d.ts.map +0 -1
- package/PluralRules/GetOperands.js +0 -51
- package/PluralRules/InitializePluralRules.d.ts +0 -9
- package/PluralRules/InitializePluralRules.d.ts.map +0 -1
- package/PluralRules/InitializePluralRules.js +0 -24
- package/PluralRules/ResolvePlural.d.ts +0 -13
- package/PluralRules/ResolvePlural.d.ts.map +0 -1
- package/PluralRules/ResolvePlural.js +0 -29
- package/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
- package/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
- package/RelativeTimeFormat/FormatRelativeTime.js +0 -14
- package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
- package/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
- package/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -22
- package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
- package/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
- package/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -41
- package/RelativeTimeFormat/MakePartsList.d.ts +0 -2
- package/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
- package/RelativeTimeFormat/MakePartsList.js +0 -31
- package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
- package/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
- package/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -58
- package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
- package/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
- package/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -40
- package/ResolveLocale.d.ts +0 -15
- package/ResolveLocale.d.ts.map +0 -1
- package/ResolveLocale.js +0 -78
- package/UnicodeExtensionValue.d.ts +0 -7
- package/UnicodeExtensionValue.d.ts.map +0 -1
- package/UnicodeExtensionValue.js +0 -50
- package/lib/BestAvailableLocale.d.ts +0 -7
- package/lib/BestAvailableLocale.d.ts.map +0 -1
- package/lib/BestAvailableLocale.js +0 -21
- package/lib/BestFitMatcher.d.ts +0 -9
- package/lib/BestFitMatcher.d.ts.map +0 -1
- package/lib/BestFitMatcher.js +0 -48
- package/lib/DateTimeFormat/BasicFormatMatcher.d.ts +0 -8
- package/lib/DateTimeFormat/BasicFormatMatcher.d.ts.map +0 -1
- package/lib/DateTimeFormat/BasicFormatMatcher.js +0 -57
- package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts +0 -17
- package/lib/DateTimeFormat/BestFitFormatMatcher.d.ts.map +0 -1
- package/lib/DateTimeFormat/BestFitFormatMatcher.js +0 -116
- package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts +0 -3
- package/lib/DateTimeFormat/DateTimeStyleFormat.d.ts.map +0 -1
- package/lib/DateTimeFormat/DateTimeStyleFormat.js +0 -50
- package/lib/DateTimeFormat/FormatDateTime.d.ts +0 -8
- package/lib/DateTimeFormat/FormatDateTime.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTime.js +0 -15
- package/lib/DateTimeFormat/FormatDateTimePattern.d.ts +0 -14
- package/lib/DateTimeFormat/FormatDateTimePattern.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTimePattern.js +0 -178
- package/lib/DateTimeFormat/FormatDateTimeRange.d.ts +0 -4
- package/lib/DateTimeFormat/FormatDateTimeRange.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTimeRange.js +0 -10
- package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts +0 -4
- package/lib/DateTimeFormat/FormatDateTimeRangeToParts.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTimeRangeToParts.js +0 -14
- package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts +0 -11
- package/lib/DateTimeFormat/FormatDateTimeToParts.d.ts.map +0 -1
- package/lib/DateTimeFormat/FormatDateTimeToParts.js +0 -21
- package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts +0 -18
- package/lib/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +0 -1
- package/lib/DateTimeFormat/InitializeDateTimeFormat.js +0 -184
- package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts +0 -10
- package/lib/DateTimeFormat/PartitionDateTimePattern.d.ts.map +0 -1
- package/lib/DateTimeFormat/PartitionDateTimePattern.js +0 -20
- package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts +0 -5
- package/lib/DateTimeFormat/PartitionDateTimeRangePattern.d.ts.map +0 -1
- package/lib/DateTimeFormat/PartitionDateTimeRangePattern.js +0 -121
- package/lib/DateTimeFormat/ToDateTimeOptions.d.ts +0 -9
- package/lib/DateTimeFormat/ToDateTimeOptions.d.ts.map +0 -1
- package/lib/DateTimeFormat/ToDateTimeOptions.js +0 -63
- package/lib/DateTimeFormat/ToLocalTime.d.ts +0 -26
- package/lib/DateTimeFormat/ToLocalTime.d.ts.map +0 -1
- package/lib/DateTimeFormat/ToLocalTime.js +0 -51
- package/lib/DateTimeFormat/skeleton.d.ts +0 -14
- package/lib/DateTimeFormat/skeleton.d.ts.map +0 -1
- package/lib/DateTimeFormat/skeleton.js +0 -294
- package/lib/DateTimeFormat/utils.d.ts +0 -10
- package/lib/DateTimeFormat/utils.d.ts.map +0 -1
- package/lib/DateTimeFormat/utils.js +0 -18
- package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts +0 -2
- package/lib/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +0 -1
- package/lib/DisplayNames/CanonicalCodeForDisplayNames.js +0 -33
- package/lib/LookupMatcher.d.ts +0 -9
- package/lib/LookupMatcher.d.ts.map +0 -1
- package/lib/LookupMatcher.js +0 -25
- package/lib/LookupSupportedLocales.d.ts +0 -7
- package/lib/LookupSupportedLocales.d.ts.map +0 -1
- package/lib/LookupSupportedLocales.js +0 -19
- package/lib/NumberFormat/digit-mapping.json +0 -1
- package/lib/PluralRules/GetOperands.d.ts +0 -32
- package/lib/PluralRules/GetOperands.d.ts.map +0 -1
- package/lib/PluralRules/GetOperands.js +0 -47
- package/lib/PluralRules/InitializePluralRules.d.ts +0 -9
- package/lib/PluralRules/InitializePluralRules.d.ts.map +0 -1
- package/lib/PluralRules/InitializePluralRules.js +0 -20
- package/lib/PluralRules/ResolvePlural.d.ts +0 -13
- package/lib/PluralRules/ResolvePlural.d.ts.map +0 -1
- package/lib/PluralRules/ResolvePlural.js +0 -25
- package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts +0 -5
- package/lib/RelativeTimeFormat/FormatRelativeTime.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/FormatRelativeTime.js +0 -10
- package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +0 -5
- package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/FormatRelativeTimeToParts.js +0 -18
- package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +0 -9
- package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/InitializeRelativeTimeFormat.js +0 -37
- package/lib/RelativeTimeFormat/MakePartsList.d.ts +0 -2
- package/lib/RelativeTimeFormat/MakePartsList.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/MakePartsList.js +0 -27
- package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +0 -5
- package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/PartitionRelativeTimePattern.js +0 -54
- package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +0 -7
- package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +0 -1
- package/lib/RelativeTimeFormat/SingularRelativeTimeUnit.js +0 -36
- package/lib/ResolveLocale.d.ts +0 -15
- package/lib/ResolveLocale.d.ts.map +0 -1
- package/lib/ResolveLocale.js +0 -74
- package/lib/UnicodeExtensionValue.d.ts +0 -7
- package/lib/UnicodeExtensionValue.d.ts.map +0 -1
- package/lib/UnicodeExtensionValue.js +0 -46
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PartitionRelativeTimePattern } from './PartitionRelativeTimePattern';
|
|
2
|
-
export function FormatRelativeTime(rtf, value, unit, implDetails) {
|
|
3
|
-
var parts = PartitionRelativeTimePattern(rtf, value, unit, implDetails);
|
|
4
|
-
var result = '';
|
|
5
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
6
|
-
var part = parts_1[_i];
|
|
7
|
-
result += part.value;
|
|
8
|
-
}
|
|
9
|
-
return result;
|
|
10
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RelativeTimeFormatInternal } from '../types/relative-time';
|
|
2
|
-
export declare function FormatRelativeTimeToParts(rtf: Intl.RelativeTimeFormat, value: number, unit: Intl.RelativeTimeFormatUnit, implDetails: {
|
|
3
|
-
getInternalSlots(rtf: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
|
|
4
|
-
}): Intl.RelativeTimeFormatPart[];
|
|
5
|
-
//# sourceMappingURL=FormatRelativeTimeToParts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormatRelativeTimeToParts.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/RelativeTimeFormat/FormatRelativeTimeToParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,wBAAwB,CAAA;AAIjE,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAC5B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,IAAI,CAAC,sBAAsB,EACjC,WAAW,EAAE;IACX,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,GAAG,0BAA0B,CAAA;CAC3E,GACA,IAAI,CAAC,sBAAsB,EAAE,CAe/B"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PartitionRelativeTimePattern } from './PartitionRelativeTimePattern';
|
|
2
|
-
import { ArrayCreate } from '../262';
|
|
3
|
-
export function FormatRelativeTimeToParts(rtf, value, unit, implDetails) {
|
|
4
|
-
var parts = PartitionRelativeTimePattern(rtf, value, unit, implDetails);
|
|
5
|
-
var result = ArrayCreate(0);
|
|
6
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
7
|
-
var part = parts_1[_i];
|
|
8
|
-
var o = {
|
|
9
|
-
type: part.type,
|
|
10
|
-
value: part.value,
|
|
11
|
-
};
|
|
12
|
-
if ('unit' in part) {
|
|
13
|
-
o.unit = part.unit;
|
|
14
|
-
}
|
|
15
|
-
result.push(o);
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { RelativeTimeFormatInternal, LocaleFieldsData } from '../types/relative-time';
|
|
2
|
-
export declare function InitializeRelativeTimeFormat(rtf: Intl.RelativeTimeFormat, locales: string | string[] | undefined, options: Intl.RelativeTimeFormatOptions | undefined, { getInternalSlots, availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, }: {
|
|
3
|
-
getInternalSlots(rtf: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
|
|
4
|
-
availableLocales: Set<string>;
|
|
5
|
-
relevantExtensionKeys: string[];
|
|
6
|
-
localeData: Record<string, LocaleFieldsData | undefined>;
|
|
7
|
-
getDefaultLocale(): string;
|
|
8
|
-
}): Intl.RelativeTimeFormat;
|
|
9
|
-
//# sourceMappingURL=InitializeRelativeTimeFormat.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InitializeRelativeTimeFormat.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/RelativeTimeFormat/InitializeRelativeTimeFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAS/B,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,yBAAyB,GAAG,SAAS,EACnD,EACE,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,GAAG,0BAA0B,CAAA;IAC1E,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAA;IACxD,gBAAgB,IAAI,MAAM,CAAA;CAC3B,2BA4DF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { CanonicalizeLocaleList } from '../CanonicalizeLocaleList';
|
|
2
|
-
import { GetOption } from '../GetOption';
|
|
3
|
-
import { ResolveLocale } from '../ResolveLocale';
|
|
4
|
-
import { invariant } from '../utils';
|
|
5
|
-
import { CoerceOptionsToObject } from '../CoerceOptionsToObject';
|
|
6
|
-
var NUMBERING_SYSTEM_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
|
|
7
|
-
export function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
|
|
8
|
-
var getInternalSlots = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
|
|
9
|
-
var internalSlots = getInternalSlots(rtf);
|
|
10
|
-
internalSlots.initializedRelativeTimeFormat = true;
|
|
11
|
-
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
12
|
-
var opt = Object.create(null);
|
|
13
|
-
var opts = CoerceOptionsToObject(options);
|
|
14
|
-
var matcher = GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
|
|
15
|
-
opt.localeMatcher = matcher;
|
|
16
|
-
var numberingSystem = GetOption(opts,
|
|
17
|
-
// @ts-expect-error TS option is wack
|
|
18
|
-
'numberingSystem', 'string', undefined, undefined);
|
|
19
|
-
if (numberingSystem !== undefined) {
|
|
20
|
-
if (!NUMBERING_SYSTEM_REGEX.test(numberingSystem)) {
|
|
21
|
-
throw new RangeError("Invalid numbering system " + numberingSystem);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
opt.nu = numberingSystem;
|
|
25
|
-
var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
26
|
-
var locale = r.locale, nu = r.nu;
|
|
27
|
-
internalSlots.locale = locale;
|
|
28
|
-
internalSlots.style = GetOption(opts, 'style', 'string', ['long', 'narrow', 'short'], 'long');
|
|
29
|
-
internalSlots.numeric = GetOption(opts, 'numeric', 'string', ['always', 'auto'], 'always');
|
|
30
|
-
var fields = localeData[r.dataLocale];
|
|
31
|
-
invariant(!!fields, "Missing locale data for " + r.dataLocale);
|
|
32
|
-
internalSlots.fields = fields;
|
|
33
|
-
internalSlots.numberFormat = new Intl.NumberFormat(locales);
|
|
34
|
-
internalSlots.pluralRules = new Intl.PluralRules(locales);
|
|
35
|
-
internalSlots.numberingSystem = nu;
|
|
36
|
-
return rtf;
|
|
37
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MakePartsList.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/RelativeTimeFormat/MakePartsList.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,CAAC,sBAAsB,EACjC,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,sBAAsB,EAAE,iCAsB/D"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { PartitionPattern } from '../PartitionPattern';
|
|
2
|
-
import { invariant } from '../utils';
|
|
3
|
-
export function MakePartsList(pattern, unit, parts) {
|
|
4
|
-
var patternParts = PartitionPattern(pattern);
|
|
5
|
-
var result = [];
|
|
6
|
-
for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
|
|
7
|
-
var patternPart = patternParts_1[_i];
|
|
8
|
-
if (patternPart.type === 'literal') {
|
|
9
|
-
result.push({
|
|
10
|
-
type: 'literal',
|
|
11
|
-
value: patternPart.value,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
invariant(patternPart.type === '0', "Malformed pattern " + pattern);
|
|
16
|
-
for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
|
|
17
|
-
var part = parts_1[_a];
|
|
18
|
-
result.push({
|
|
19
|
-
type: part.type,
|
|
20
|
-
value: part.value,
|
|
21
|
-
unit: unit,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RelativeTimeFormatInternal } from '../types/relative-time';
|
|
2
|
-
export declare function PartitionRelativeTimePattern(rtf: Intl.RelativeTimeFormat, value: number, unit: Intl.RelativeTimeFormatUnit, { getInternalSlots, }: {
|
|
3
|
-
getInternalSlots(rtf: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
|
|
4
|
-
}): Intl.RelativeTimeFormatPart[];
|
|
5
|
-
//# sourceMappingURL=PartitionRelativeTimePattern.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PartitionRelativeTimePattern.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/RelativeTimeFormat/PartitionRelativeTimePattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,0BAA0B,EAC3B,MAAM,wBAAwB,CAAA;AAO/B,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAC5B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,IAAI,CAAC,sBAAsB,EACjC,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,GAAG,0BAA0B,CAAA;CAC3E,GACA,IAAI,CAAC,sBAAsB,EAAE,CA0D/B"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { invariant } from '../utils';
|
|
2
|
-
import { SingularRelativeTimeUnit } from './SingularRelativeTimeUnit';
|
|
3
|
-
import { MakePartsList } from './MakePartsList';
|
|
4
|
-
import { ToString, Type, SameValue } from '../262';
|
|
5
|
-
export function PartitionRelativeTimePattern(rtf, value, unit, _a) {
|
|
6
|
-
var getInternalSlots = _a.getInternalSlots;
|
|
7
|
-
invariant(Type(value) === 'Number', "value must be number, instead got " + typeof value, TypeError);
|
|
8
|
-
invariant(Type(unit) === 'String', "unit must be number, instead got " + typeof value, TypeError);
|
|
9
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
10
|
-
throw new RangeError("Invalid value " + value);
|
|
11
|
-
}
|
|
12
|
-
var resolvedUnit = SingularRelativeTimeUnit(unit);
|
|
13
|
-
var _b = getInternalSlots(rtf), fields = _b.fields, style = _b.style, numeric = _b.numeric, pluralRules = _b.pluralRules, numberFormat = _b.numberFormat;
|
|
14
|
-
var entry = resolvedUnit;
|
|
15
|
-
if (style === 'short') {
|
|
16
|
-
entry = resolvedUnit + "-short";
|
|
17
|
-
}
|
|
18
|
-
else if (style === 'narrow') {
|
|
19
|
-
entry = resolvedUnit + "-narrow";
|
|
20
|
-
}
|
|
21
|
-
if (!(entry in fields)) {
|
|
22
|
-
entry = resolvedUnit;
|
|
23
|
-
}
|
|
24
|
-
var patterns = fields[entry];
|
|
25
|
-
if (numeric === 'auto') {
|
|
26
|
-
if (ToString(value) in patterns) {
|
|
27
|
-
return [
|
|
28
|
-
{
|
|
29
|
-
type: 'literal',
|
|
30
|
-
value: patterns[ToString(value)],
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
var tl = 'future';
|
|
36
|
-
if (SameValue(value, -0) || value < 0) {
|
|
37
|
-
tl = 'past';
|
|
38
|
-
}
|
|
39
|
-
var po = patterns[tl];
|
|
40
|
-
var fv = typeof numberFormat.formatToParts === 'function'
|
|
41
|
-
? numberFormat.formatToParts(Math.abs(value))
|
|
42
|
-
: // TODO: If formatToParts is not supported, we assume the whole formatted
|
|
43
|
-
// number is a part
|
|
44
|
-
[
|
|
45
|
-
{
|
|
46
|
-
type: 'literal',
|
|
47
|
-
value: numberFormat.format(Math.abs(value)),
|
|
48
|
-
unit: unit,
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
var pr = pluralRules.select(value);
|
|
52
|
-
var pattern = po[pr];
|
|
53
|
-
return MakePartsList(pattern, resolvedUnit, fv);
|
|
54
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RelativeTimeFormatSingularUnit } from '../types/relative-time';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/proposal-intl-relative-time/#sec-singularrelativetimeunit
|
|
4
|
-
* @param unit
|
|
5
|
-
*/
|
|
6
|
-
export declare function SingularRelativeTimeUnit(unit: Intl.RelativeTimeFormatUnit): RelativeTimeFormatSingularUnit;
|
|
7
|
-
//# sourceMappingURL=SingularRelativeTimeUnit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SingularRelativeTimeUnit.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/RelativeTimeFormat/SingularRelativeTimeUnit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,8BAA8B,EAAC,MAAM,wBAAwB,CAAA;AAErE;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,CAAC,sBAAsB,GAChC,8BAA8B,CAuBhC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { invariant } from '../utils';
|
|
2
|
-
import { Type } from '../262';
|
|
3
|
-
/**
|
|
4
|
-
* https://tc39.es/proposal-intl-relative-time/#sec-singularrelativetimeunit
|
|
5
|
-
* @param unit
|
|
6
|
-
*/
|
|
7
|
-
export function SingularRelativeTimeUnit(unit) {
|
|
8
|
-
invariant(Type(unit) === 'String', 'unit must be a string');
|
|
9
|
-
if (unit === 'seconds')
|
|
10
|
-
return 'second';
|
|
11
|
-
if (unit === 'minutes')
|
|
12
|
-
return 'minute';
|
|
13
|
-
if (unit === 'hours')
|
|
14
|
-
return 'hour';
|
|
15
|
-
if (unit === 'days')
|
|
16
|
-
return 'day';
|
|
17
|
-
if (unit === 'weeks')
|
|
18
|
-
return 'week';
|
|
19
|
-
if (unit === 'months')
|
|
20
|
-
return 'month';
|
|
21
|
-
if (unit === 'quarters')
|
|
22
|
-
return 'quarter';
|
|
23
|
-
if (unit === 'years')
|
|
24
|
-
return 'year';
|
|
25
|
-
if (unit !== 'second' &&
|
|
26
|
-
unit !== 'minute' &&
|
|
27
|
-
unit !== 'hour' &&
|
|
28
|
-
unit !== 'day' &&
|
|
29
|
-
unit !== 'week' &&
|
|
30
|
-
unit !== 'month' &&
|
|
31
|
-
unit !== 'quarter' &&
|
|
32
|
-
unit !== 'year') {
|
|
33
|
-
throw new RangeError('invalid unit');
|
|
34
|
-
}
|
|
35
|
-
return unit;
|
|
36
|
-
}
|
package/lib/ResolveLocale.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface ResolveLocaleResult {
|
|
2
|
-
locale: string;
|
|
3
|
-
dataLocale: string;
|
|
4
|
-
[k: string]: any;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* https://tc39.es/ecma402/#sec-resolvelocale
|
|
8
|
-
*/
|
|
9
|
-
export declare function ResolveLocale<K extends string, D extends {
|
|
10
|
-
[k in K]: any;
|
|
11
|
-
}>(availableLocales: Set<string>, requestedLocales: string[], options: {
|
|
12
|
-
localeMatcher: string;
|
|
13
|
-
[k: string]: string;
|
|
14
|
-
}, relevantExtensionKeys: K[], localeData: Record<string, D | undefined>, getDefaultLocale: () => string): ResolveLocaleResult;
|
|
15
|
-
//# sourceMappingURL=ResolveLocale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResolveLocale.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/ResolveLocale.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS;KAAE,CAAC,IAAI,CAAC,GAAG,GAAG;CAAC,EACvE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC7B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,EAAE;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,EACrD,qBAAqB,EAAE,CAAC,EAAE,EAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,EACzC,gBAAgB,EAAE,MAAM,MAAM,GAC7B,mBAAmB,CA6ErB"}
|
package/lib/ResolveLocale.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { LookupMatcher } from './LookupMatcher';
|
|
2
|
-
import { BestFitMatcher } from './BestFitMatcher';
|
|
3
|
-
import { invariant } from './utils';
|
|
4
|
-
import { UnicodeExtensionValue } from './UnicodeExtensionValue';
|
|
5
|
-
/**
|
|
6
|
-
* https://tc39.es/ecma402/#sec-resolvelocale
|
|
7
|
-
*/
|
|
8
|
-
export function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
9
|
-
var matcher = options.localeMatcher;
|
|
10
|
-
var r;
|
|
11
|
-
if (matcher === 'lookup') {
|
|
12
|
-
r = LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
r = BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
16
|
-
}
|
|
17
|
-
var foundLocale = r.locale;
|
|
18
|
-
var result = { locale: '', dataLocale: foundLocale };
|
|
19
|
-
var supportedExtension = '-u';
|
|
20
|
-
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
21
|
-
var key = relevantExtensionKeys_1[_i];
|
|
22
|
-
invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
|
|
23
|
-
var foundLocaleData = localeData[foundLocale];
|
|
24
|
-
invariant(typeof foundLocaleData === 'object' && foundLocaleData !== null, "locale data " + key + " must be an object");
|
|
25
|
-
var keyLocaleData = foundLocaleData[key];
|
|
26
|
-
invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
|
|
27
|
-
var value = keyLocaleData[0];
|
|
28
|
-
invariant(typeof value === 'string' || value === null, "value must be string or null but got " + typeof value + " in key " + key);
|
|
29
|
-
var supportedExtensionAddition = '';
|
|
30
|
-
if (r.extension) {
|
|
31
|
-
var requestedValue = UnicodeExtensionValue(r.extension, key);
|
|
32
|
-
if (requestedValue !== undefined) {
|
|
33
|
-
if (requestedValue !== '') {
|
|
34
|
-
if (~keyLocaleData.indexOf(requestedValue)) {
|
|
35
|
-
value = requestedValue;
|
|
36
|
-
supportedExtensionAddition = "-" + key + "-" + value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else if (~requestedValue.indexOf('true')) {
|
|
40
|
-
value = 'true';
|
|
41
|
-
supportedExtensionAddition = "-" + key;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (key in options) {
|
|
46
|
-
var optionsValue = options[key];
|
|
47
|
-
invariant(typeof optionsValue === 'string' ||
|
|
48
|
-
typeof optionsValue === 'undefined' ||
|
|
49
|
-
optionsValue === null, 'optionsValue must be String, Undefined or Null');
|
|
50
|
-
if (~keyLocaleData.indexOf(optionsValue)) {
|
|
51
|
-
if (optionsValue !== value) {
|
|
52
|
-
value = optionsValue;
|
|
53
|
-
supportedExtensionAddition = '';
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
result[key] = value;
|
|
58
|
-
supportedExtension += supportedExtensionAddition;
|
|
59
|
-
}
|
|
60
|
-
if (supportedExtension.length > 2) {
|
|
61
|
-
var privateIndex = foundLocale.indexOf('-x-');
|
|
62
|
-
if (privateIndex === -1) {
|
|
63
|
-
foundLocale = foundLocale + supportedExtension;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
var preExtension = foundLocale.slice(0, privateIndex);
|
|
67
|
-
var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
|
|
68
|
-
foundLocale = preExtension + supportedExtension + postExtension;
|
|
69
|
-
}
|
|
70
|
-
foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
|
|
71
|
-
}
|
|
72
|
-
result.locale = foundLocale;
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UnicodeExtensionValue.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/UnicodeExtensionValue.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,sBAoCnE"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { invariant } from './utils';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/ecma402/#sec-unicodeextensionvalue
|
|
4
|
-
* @param extension
|
|
5
|
-
* @param key
|
|
6
|
-
*/
|
|
7
|
-
export function UnicodeExtensionValue(extension, key) {
|
|
8
|
-
invariant(key.length === 2, 'key must have 2 elements');
|
|
9
|
-
var size = extension.length;
|
|
10
|
-
var searchValue = "-" + key + "-";
|
|
11
|
-
var pos = extension.indexOf(searchValue);
|
|
12
|
-
if (pos !== -1) {
|
|
13
|
-
var start = pos + 4;
|
|
14
|
-
var end = start;
|
|
15
|
-
var k = start;
|
|
16
|
-
var done = false;
|
|
17
|
-
while (!done) {
|
|
18
|
-
var e = extension.indexOf('-', k);
|
|
19
|
-
var len = void 0;
|
|
20
|
-
if (e === -1) {
|
|
21
|
-
len = size - k;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
len = e - k;
|
|
25
|
-
}
|
|
26
|
-
if (len === 2) {
|
|
27
|
-
done = true;
|
|
28
|
-
}
|
|
29
|
-
else if (e === -1) {
|
|
30
|
-
end = size;
|
|
31
|
-
done = true;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
end = e;
|
|
35
|
-
k = e + 1;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return extension.slice(start, end);
|
|
39
|
-
}
|
|
40
|
-
searchValue = "-" + key;
|
|
41
|
-
pos = extension.indexOf(searchValue);
|
|
42
|
-
if (pos !== -1 && pos + 3 === size) {
|
|
43
|
-
return '';
|
|
44
|
-
}
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|