@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,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResolvePlural = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
var _262_1 = require("../262");
|
|
6
|
-
var FormatNumericToString_1 = require("../NumberFormat/FormatNumericToString");
|
|
7
|
-
var GetOperands_1 = require("./GetOperands");
|
|
8
|
-
/**
|
|
9
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
|
|
10
|
-
* @param pl
|
|
11
|
-
* @param n
|
|
12
|
-
* @param PluralRuleSelect Has to pass in bc it's implementation-specific
|
|
13
|
-
*/
|
|
14
|
-
function ResolvePlural(pl, n, _a) {
|
|
15
|
-
var getInternalSlots = _a.getInternalSlots, PluralRuleSelect = _a.PluralRuleSelect;
|
|
16
|
-
var internalSlots = getInternalSlots(pl);
|
|
17
|
-
utils_1.invariant(_262_1.Type(internalSlots) === 'Object', 'pl has to be an object');
|
|
18
|
-
utils_1.invariant('initializedPluralRules' in internalSlots, 'pluralrules must be initialized');
|
|
19
|
-
utils_1.invariant(_262_1.Type(n) === 'Number', 'n must be a number');
|
|
20
|
-
if (!isFinite(n)) {
|
|
21
|
-
return 'other';
|
|
22
|
-
}
|
|
23
|
-
var locale = internalSlots.locale, type = internalSlots.type;
|
|
24
|
-
var res = FormatNumericToString_1.FormatNumericToString(internalSlots, n);
|
|
25
|
-
var s = res.formattedString;
|
|
26
|
-
var operands = GetOperands_1.GetOperands(s);
|
|
27
|
-
return PluralRuleSelect(locale, type, n, operands);
|
|
28
|
-
}
|
|
29
|
-
exports.ResolvePlural = ResolvePlural;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RelativeTimeFormatInternal } from '../types/relative-time';
|
|
2
|
-
export declare function FormatRelativeTime(rtf: Intl.RelativeTimeFormat, value: number, unit: Intl.RelativeTimeFormatUnit, implDetails: {
|
|
3
|
-
getInternalSlots(rtf: Intl.RelativeTimeFormat): RelativeTimeFormatInternal;
|
|
4
|
-
}): string;
|
|
5
|
-
//# sourceMappingURL=FormatRelativeTime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormatRelativeTime.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/RelativeTimeFormat/FormatRelativeTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,wBAAwB,CAAA;AAGjE,wBAAgB,kBAAkB,CAChC,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,MAAM,CAOR"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormatRelativeTime = void 0;
|
|
4
|
-
var PartitionRelativeTimePattern_1 = require("./PartitionRelativeTimePattern");
|
|
5
|
-
function FormatRelativeTime(rtf, value, unit, implDetails) {
|
|
6
|
-
var parts = PartitionRelativeTimePattern_1.PartitionRelativeTimePattern(rtf, value, unit, implDetails);
|
|
7
|
-
var result = '';
|
|
8
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
9
|
-
var part = parts_1[_i];
|
|
10
|
-
result += part.value;
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
14
|
-
exports.FormatRelativeTime = FormatRelativeTime;
|
|
@@ -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,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormatRelativeTimeToParts = void 0;
|
|
4
|
-
var PartitionRelativeTimePattern_1 = require("./PartitionRelativeTimePattern");
|
|
5
|
-
var _262_1 = require("../262");
|
|
6
|
-
function FormatRelativeTimeToParts(rtf, value, unit, implDetails) {
|
|
7
|
-
var parts = PartitionRelativeTimePattern_1.PartitionRelativeTimePattern(rtf, value, unit, implDetails);
|
|
8
|
-
var result = _262_1.ArrayCreate(0);
|
|
9
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
10
|
-
var part = parts_1[_i];
|
|
11
|
-
var o = {
|
|
12
|
-
type: part.type,
|
|
13
|
-
value: part.value,
|
|
14
|
-
};
|
|
15
|
-
if ('unit' in part) {
|
|
16
|
-
o.unit = part.unit;
|
|
17
|
-
}
|
|
18
|
-
result.push(o);
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
exports.FormatRelativeTimeToParts = FormatRelativeTimeToParts;
|
|
@@ -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,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InitializeRelativeTimeFormat = void 0;
|
|
4
|
-
var CanonicalizeLocaleList_1 = require("../CanonicalizeLocaleList");
|
|
5
|
-
var GetOption_1 = require("../GetOption");
|
|
6
|
-
var ResolveLocale_1 = require("../ResolveLocale");
|
|
7
|
-
var utils_1 = require("../utils");
|
|
8
|
-
var CoerceOptionsToObject_1 = require("../CoerceOptionsToObject");
|
|
9
|
-
var NUMBERING_SYSTEM_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
|
|
10
|
-
function InitializeRelativeTimeFormat(rtf, locales, options, _a) {
|
|
11
|
-
var getInternalSlots = _a.getInternalSlots, availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale;
|
|
12
|
-
var internalSlots = getInternalSlots(rtf);
|
|
13
|
-
internalSlots.initializedRelativeTimeFormat = true;
|
|
14
|
-
var requestedLocales = CanonicalizeLocaleList_1.CanonicalizeLocaleList(locales);
|
|
15
|
-
var opt = Object.create(null);
|
|
16
|
-
var opts = CoerceOptionsToObject_1.CoerceOptionsToObject(options);
|
|
17
|
-
var matcher = GetOption_1.GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
|
|
18
|
-
opt.localeMatcher = matcher;
|
|
19
|
-
var numberingSystem = GetOption_1.GetOption(opts,
|
|
20
|
-
// @ts-expect-error TS option is wack
|
|
21
|
-
'numberingSystem', 'string', undefined, undefined);
|
|
22
|
-
if (numberingSystem !== undefined) {
|
|
23
|
-
if (!NUMBERING_SYSTEM_REGEX.test(numberingSystem)) {
|
|
24
|
-
throw new RangeError("Invalid numbering system " + numberingSystem);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
opt.nu = numberingSystem;
|
|
28
|
-
var r = ResolveLocale_1.ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
29
|
-
var locale = r.locale, nu = r.nu;
|
|
30
|
-
internalSlots.locale = locale;
|
|
31
|
-
internalSlots.style = GetOption_1.GetOption(opts, 'style', 'string', ['long', 'narrow', 'short'], 'long');
|
|
32
|
-
internalSlots.numeric = GetOption_1.GetOption(opts, 'numeric', 'string', ['always', 'auto'], 'always');
|
|
33
|
-
var fields = localeData[r.dataLocale];
|
|
34
|
-
utils_1.invariant(!!fields, "Missing locale data for " + r.dataLocale);
|
|
35
|
-
internalSlots.fields = fields;
|
|
36
|
-
internalSlots.numberFormat = new Intl.NumberFormat(locales);
|
|
37
|
-
internalSlots.pluralRules = new Intl.PluralRules(locales);
|
|
38
|
-
internalSlots.numberingSystem = nu;
|
|
39
|
-
return rtf;
|
|
40
|
-
}
|
|
41
|
-
exports.InitializeRelativeTimeFormat = InitializeRelativeTimeFormat;
|
|
@@ -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,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MakePartsList = void 0;
|
|
4
|
-
var PartitionPattern_1 = require("../PartitionPattern");
|
|
5
|
-
var utils_1 = require("../utils");
|
|
6
|
-
function MakePartsList(pattern, unit, parts) {
|
|
7
|
-
var patternParts = PartitionPattern_1.PartitionPattern(pattern);
|
|
8
|
-
var result = [];
|
|
9
|
-
for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
|
|
10
|
-
var patternPart = patternParts_1[_i];
|
|
11
|
-
if (patternPart.type === 'literal') {
|
|
12
|
-
result.push({
|
|
13
|
-
type: 'literal',
|
|
14
|
-
value: patternPart.value,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
utils_1.invariant(patternPart.type === '0', "Malformed pattern " + pattern);
|
|
19
|
-
for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
|
|
20
|
-
var part = parts_1[_a];
|
|
21
|
-
result.push({
|
|
22
|
-
type: part.type,
|
|
23
|
-
value: part.value,
|
|
24
|
-
unit: unit,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
exports.MakePartsList = MakePartsList;
|
|
@@ -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,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PartitionRelativeTimePattern = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
var SingularRelativeTimeUnit_1 = require("./SingularRelativeTimeUnit");
|
|
6
|
-
var MakePartsList_1 = require("./MakePartsList");
|
|
7
|
-
var _262_1 = require("../262");
|
|
8
|
-
function PartitionRelativeTimePattern(rtf, value, unit, _a) {
|
|
9
|
-
var getInternalSlots = _a.getInternalSlots;
|
|
10
|
-
utils_1.invariant(_262_1.Type(value) === 'Number', "value must be number, instead got " + typeof value, TypeError);
|
|
11
|
-
utils_1.invariant(_262_1.Type(unit) === 'String', "unit must be number, instead got " + typeof value, TypeError);
|
|
12
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
13
|
-
throw new RangeError("Invalid value " + value);
|
|
14
|
-
}
|
|
15
|
-
var resolvedUnit = SingularRelativeTimeUnit_1.SingularRelativeTimeUnit(unit);
|
|
16
|
-
var _b = getInternalSlots(rtf), fields = _b.fields, style = _b.style, numeric = _b.numeric, pluralRules = _b.pluralRules, numberFormat = _b.numberFormat;
|
|
17
|
-
var entry = resolvedUnit;
|
|
18
|
-
if (style === 'short') {
|
|
19
|
-
entry = resolvedUnit + "-short";
|
|
20
|
-
}
|
|
21
|
-
else if (style === 'narrow') {
|
|
22
|
-
entry = resolvedUnit + "-narrow";
|
|
23
|
-
}
|
|
24
|
-
if (!(entry in fields)) {
|
|
25
|
-
entry = resolvedUnit;
|
|
26
|
-
}
|
|
27
|
-
var patterns = fields[entry];
|
|
28
|
-
if (numeric === 'auto') {
|
|
29
|
-
if (_262_1.ToString(value) in patterns) {
|
|
30
|
-
return [
|
|
31
|
-
{
|
|
32
|
-
type: 'literal',
|
|
33
|
-
value: patterns[_262_1.ToString(value)],
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
var tl = 'future';
|
|
39
|
-
if (_262_1.SameValue(value, -0) || value < 0) {
|
|
40
|
-
tl = 'past';
|
|
41
|
-
}
|
|
42
|
-
var po = patterns[tl];
|
|
43
|
-
var fv = typeof numberFormat.formatToParts === 'function'
|
|
44
|
-
? numberFormat.formatToParts(Math.abs(value))
|
|
45
|
-
: // TODO: If formatToParts is not supported, we assume the whole formatted
|
|
46
|
-
// number is a part
|
|
47
|
-
[
|
|
48
|
-
{
|
|
49
|
-
type: 'literal',
|
|
50
|
-
value: numberFormat.format(Math.abs(value)),
|
|
51
|
-
unit: unit,
|
|
52
|
-
},
|
|
53
|
-
];
|
|
54
|
-
var pr = pluralRules.select(value);
|
|
55
|
-
var pattern = po[pr];
|
|
56
|
-
return MakePartsList_1.MakePartsList(pattern, resolvedUnit, fv);
|
|
57
|
-
}
|
|
58
|
-
exports.PartitionRelativeTimePattern = PartitionRelativeTimePattern;
|
|
@@ -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,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SingularRelativeTimeUnit = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
var _262_1 = require("../262");
|
|
6
|
-
/**
|
|
7
|
-
* https://tc39.es/proposal-intl-relative-time/#sec-singularrelativetimeunit
|
|
8
|
-
* @param unit
|
|
9
|
-
*/
|
|
10
|
-
function SingularRelativeTimeUnit(unit) {
|
|
11
|
-
utils_1.invariant(_262_1.Type(unit) === 'String', 'unit must be a string');
|
|
12
|
-
if (unit === 'seconds')
|
|
13
|
-
return 'second';
|
|
14
|
-
if (unit === 'minutes')
|
|
15
|
-
return 'minute';
|
|
16
|
-
if (unit === 'hours')
|
|
17
|
-
return 'hour';
|
|
18
|
-
if (unit === 'days')
|
|
19
|
-
return 'day';
|
|
20
|
-
if (unit === 'weeks')
|
|
21
|
-
return 'week';
|
|
22
|
-
if (unit === 'months')
|
|
23
|
-
return 'month';
|
|
24
|
-
if (unit === 'quarters')
|
|
25
|
-
return 'quarter';
|
|
26
|
-
if (unit === 'years')
|
|
27
|
-
return 'year';
|
|
28
|
-
if (unit !== 'second' &&
|
|
29
|
-
unit !== 'minute' &&
|
|
30
|
-
unit !== 'hour' &&
|
|
31
|
-
unit !== 'day' &&
|
|
32
|
-
unit !== 'week' &&
|
|
33
|
-
unit !== 'month' &&
|
|
34
|
-
unit !== 'quarter' &&
|
|
35
|
-
unit !== 'year') {
|
|
36
|
-
throw new RangeError('invalid unit');
|
|
37
|
-
}
|
|
38
|
-
return unit;
|
|
39
|
-
}
|
|
40
|
-
exports.SingularRelativeTimeUnit = SingularRelativeTimeUnit;
|
package/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
|
package/ResolveLocale.d.ts.map
DELETED
|
@@ -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/ResolveLocale.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResolveLocale = void 0;
|
|
4
|
-
var LookupMatcher_1 = require("./LookupMatcher");
|
|
5
|
-
var BestFitMatcher_1 = require("./BestFitMatcher");
|
|
6
|
-
var utils_1 = require("./utils");
|
|
7
|
-
var UnicodeExtensionValue_1 = require("./UnicodeExtensionValue");
|
|
8
|
-
/**
|
|
9
|
-
* https://tc39.es/ecma402/#sec-resolvelocale
|
|
10
|
-
*/
|
|
11
|
-
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
12
|
-
var matcher = options.localeMatcher;
|
|
13
|
-
var r;
|
|
14
|
-
if (matcher === 'lookup') {
|
|
15
|
-
r = LookupMatcher_1.LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
19
|
-
}
|
|
20
|
-
var foundLocale = r.locale;
|
|
21
|
-
var result = { locale: '', dataLocale: foundLocale };
|
|
22
|
-
var supportedExtension = '-u';
|
|
23
|
-
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
24
|
-
var key = relevantExtensionKeys_1[_i];
|
|
25
|
-
utils_1.invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
|
|
26
|
-
var foundLocaleData = localeData[foundLocale];
|
|
27
|
-
utils_1.invariant(typeof foundLocaleData === 'object' && foundLocaleData !== null, "locale data " + key + " must be an object");
|
|
28
|
-
var keyLocaleData = foundLocaleData[key];
|
|
29
|
-
utils_1.invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
|
|
30
|
-
var value = keyLocaleData[0];
|
|
31
|
-
utils_1.invariant(typeof value === 'string' || value === null, "value must be string or null but got " + typeof value + " in key " + key);
|
|
32
|
-
var supportedExtensionAddition = '';
|
|
33
|
-
if (r.extension) {
|
|
34
|
-
var requestedValue = UnicodeExtensionValue_1.UnicodeExtensionValue(r.extension, key);
|
|
35
|
-
if (requestedValue !== undefined) {
|
|
36
|
-
if (requestedValue !== '') {
|
|
37
|
-
if (~keyLocaleData.indexOf(requestedValue)) {
|
|
38
|
-
value = requestedValue;
|
|
39
|
-
supportedExtensionAddition = "-" + key + "-" + value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else if (~requestedValue.indexOf('true')) {
|
|
43
|
-
value = 'true';
|
|
44
|
-
supportedExtensionAddition = "-" + key;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (key in options) {
|
|
49
|
-
var optionsValue = options[key];
|
|
50
|
-
utils_1.invariant(typeof optionsValue === 'string' ||
|
|
51
|
-
typeof optionsValue === 'undefined' ||
|
|
52
|
-
optionsValue === null, 'optionsValue must be String, Undefined or Null');
|
|
53
|
-
if (~keyLocaleData.indexOf(optionsValue)) {
|
|
54
|
-
if (optionsValue !== value) {
|
|
55
|
-
value = optionsValue;
|
|
56
|
-
supportedExtensionAddition = '';
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
result[key] = value;
|
|
61
|
-
supportedExtension += supportedExtensionAddition;
|
|
62
|
-
}
|
|
63
|
-
if (supportedExtension.length > 2) {
|
|
64
|
-
var privateIndex = foundLocale.indexOf('-x-');
|
|
65
|
-
if (privateIndex === -1) {
|
|
66
|
-
foundLocale = foundLocale + supportedExtension;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
var preExtension = foundLocale.slice(0, privateIndex);
|
|
70
|
-
var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
|
|
71
|
-
foundLocale = preExtension + supportedExtension + postExtension;
|
|
72
|
-
}
|
|
73
|
-
foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
|
|
74
|
-
}
|
|
75
|
-
result.locale = foundLocale;
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
exports.ResolveLocale = ResolveLocale;
|
|
@@ -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"}
|
package/UnicodeExtensionValue.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnicodeExtensionValue = void 0;
|
|
4
|
-
var utils_1 = require("./utils");
|
|
5
|
-
/**
|
|
6
|
-
* https://tc39.es/ecma402/#sec-unicodeextensionvalue
|
|
7
|
-
* @param extension
|
|
8
|
-
* @param key
|
|
9
|
-
*/
|
|
10
|
-
function UnicodeExtensionValue(extension, key) {
|
|
11
|
-
utils_1.invariant(key.length === 2, 'key must have 2 elements');
|
|
12
|
-
var size = extension.length;
|
|
13
|
-
var searchValue = "-" + key + "-";
|
|
14
|
-
var pos = extension.indexOf(searchValue);
|
|
15
|
-
if (pos !== -1) {
|
|
16
|
-
var start = pos + 4;
|
|
17
|
-
var end = start;
|
|
18
|
-
var k = start;
|
|
19
|
-
var done = false;
|
|
20
|
-
while (!done) {
|
|
21
|
-
var e = extension.indexOf('-', k);
|
|
22
|
-
var len = void 0;
|
|
23
|
-
if (e === -1) {
|
|
24
|
-
len = size - k;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
len = e - k;
|
|
28
|
-
}
|
|
29
|
-
if (len === 2) {
|
|
30
|
-
done = true;
|
|
31
|
-
}
|
|
32
|
-
else if (e === -1) {
|
|
33
|
-
end = size;
|
|
34
|
-
done = true;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
end = e;
|
|
38
|
-
k = e + 1;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return extension.slice(start, end);
|
|
42
|
-
}
|
|
43
|
-
searchValue = "-" + key;
|
|
44
|
-
pos = extension.indexOf(searchValue);
|
|
45
|
-
if (pos !== -1 && pos + 3 === size) {
|
|
46
|
-
return '';
|
|
47
|
-
}
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
exports.UnicodeExtensionValue = UnicodeExtensionValue;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://tc39.es/ecma402/#sec-bestavailablelocale
|
|
3
|
-
* @param availableLocales
|
|
4
|
-
* @param locale
|
|
5
|
-
*/
|
|
6
|
-
export declare function BestAvailableLocale(availableLocales: Set<String>, locale: string): string | undefined;
|
|
7
|
-
//# sourceMappingURL=BestAvailableLocale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BestAvailableLocale.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/BestAvailableLocale.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC7B,MAAM,EAAE,MAAM,sBAgBf"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://tc39.es/ecma402/#sec-bestavailablelocale
|
|
3
|
-
* @param availableLocales
|
|
4
|
-
* @param locale
|
|
5
|
-
*/
|
|
6
|
-
export function BestAvailableLocale(availableLocales, locale) {
|
|
7
|
-
var candidate = locale;
|
|
8
|
-
while (true) {
|
|
9
|
-
if (availableLocales.has(candidate)) {
|
|
10
|
-
return candidate;
|
|
11
|
-
}
|
|
12
|
-
var pos = candidate.lastIndexOf('-');
|
|
13
|
-
if (!~pos) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
if (pos >= 2 && candidate[pos - 2] === '-') {
|
|
17
|
-
pos -= 2;
|
|
18
|
-
}
|
|
19
|
-
candidate = candidate.slice(0, pos);
|
|
20
|
-
}
|
|
21
|
-
}
|
package/lib/BestFitMatcher.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { LookupMatcherResult } from './types/core';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/ecma402/#sec-bestfitmatcher
|
|
4
|
-
* @param availableLocales
|
|
5
|
-
* @param requestedLocales
|
|
6
|
-
* @param getDefaultLocale
|
|
7
|
-
*/
|
|
8
|
-
export declare function BestFitMatcher(availableLocales: Set<string>, requestedLocales: string[], getDefaultLocale: () => string): LookupMatcherResult;
|
|
9
|
-
//# sourceMappingURL=BestFitMatcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BestFitMatcher.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/BestFitMatcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAA;AAGhD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC7B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,gBAAgB,EAAE,MAAM,MAAM,GAC7B,mBAAmB,CAiDrB"}
|
package/lib/BestFitMatcher.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { BestAvailableLocale } from './BestAvailableLocale';
|
|
2
|
-
import { UNICODE_EXTENSION_SEQUENCE_REGEX } from './utils';
|
|
3
|
-
/**
|
|
4
|
-
* https://tc39.es/ecma402/#sec-bestfitmatcher
|
|
5
|
-
* @param availableLocales
|
|
6
|
-
* @param requestedLocales
|
|
7
|
-
* @param getDefaultLocale
|
|
8
|
-
*/
|
|
9
|
-
export function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
10
|
-
var minimizedAvailableLocaleMap = {};
|
|
11
|
-
var minimizedAvailableLocales = new Set();
|
|
12
|
-
availableLocales.forEach(function (locale) {
|
|
13
|
-
var minimizedLocale = new Intl.Locale(locale)
|
|
14
|
-
.minimize()
|
|
15
|
-
.toString();
|
|
16
|
-
minimizedAvailableLocaleMap[minimizedLocale] = locale;
|
|
17
|
-
minimizedAvailableLocales.add(minimizedLocale);
|
|
18
|
-
});
|
|
19
|
-
var foundLocale;
|
|
20
|
-
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
21
|
-
var l = requestedLocales_1[_i];
|
|
22
|
-
if (foundLocale) {
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
var noExtensionLocale = l.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
|
|
26
|
-
if (availableLocales.has(noExtensionLocale)) {
|
|
27
|
-
foundLocale = noExtensionLocale;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
if (minimizedAvailableLocales.has(noExtensionLocale)) {
|
|
31
|
-
foundLocale = minimizedAvailableLocaleMap[noExtensionLocale];
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
var locale = new Intl.Locale(noExtensionLocale);
|
|
35
|
-
var maximizedRequestedLocale = locale.maximize().toString();
|
|
36
|
-
var minimizedRequestedLocale = locale.minimize().toString();
|
|
37
|
-
// Check minimized locale
|
|
38
|
-
if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
|
|
39
|
-
foundLocale = minimizedAvailableLocaleMap[minimizedRequestedLocale];
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
// Lookup algo on maximized locale
|
|
43
|
-
foundLocale = BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
locale: foundLocale || getDefaultLocale(),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DateTimeFormatOptions, Formats } from '../types/date-time';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/ecma402/#sec-basicformatmatcher
|
|
4
|
-
* @param options
|
|
5
|
-
* @param formats
|
|
6
|
-
*/
|
|
7
|
-
export declare function BasicFormatMatcher(options: DateTimeFormatOptions, formats: Formats[]): Formats;
|
|
8
|
-
//# sourceMappingURL=BasicFormatMatcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BasicFormatMatcher.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/DateTimeFormat/BasicFormatMatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAE,OAAO,EAAC,MAAM,oBAAoB,CAAA;AAYjE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,OAAO,EAAE,GACjB,OAAO,CA2CT"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import { invariant } from '../utils';
|
|
3
|
-
import { DATE_TIME_PROPS, additionPenalty, removalPenalty, longMorePenalty, shortMorePenalty, shortLessPenalty, longLessPenalty, } from './utils';
|
|
4
|
-
/**
|
|
5
|
-
* https://tc39.es/ecma402/#sec-basicformatmatcher
|
|
6
|
-
* @param options
|
|
7
|
-
* @param formats
|
|
8
|
-
*/
|
|
9
|
-
export function BasicFormatMatcher(options, formats) {
|
|
10
|
-
var bestScore = -Infinity;
|
|
11
|
-
var bestFormat = formats[0];
|
|
12
|
-
invariant(Array.isArray(formats), 'formats should be a list of things');
|
|
13
|
-
for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
|
|
14
|
-
var format = formats_1[_i];
|
|
15
|
-
var score = 0;
|
|
16
|
-
for (var _a = 0, DATE_TIME_PROPS_1 = DATE_TIME_PROPS; _a < DATE_TIME_PROPS_1.length; _a++) {
|
|
17
|
-
var prop = DATE_TIME_PROPS_1[_a];
|
|
18
|
-
var optionsProp = options[prop];
|
|
19
|
-
var formatProp = format[prop];
|
|
20
|
-
if (optionsProp === undefined && formatProp !== undefined) {
|
|
21
|
-
score -= additionPenalty;
|
|
22
|
-
}
|
|
23
|
-
else if (optionsProp !== undefined && formatProp === undefined) {
|
|
24
|
-
score -= removalPenalty;
|
|
25
|
-
}
|
|
26
|
-
else if (optionsProp !== formatProp) {
|
|
27
|
-
var values = void 0;
|
|
28
|
-
if (prop === 'fractionalSecondDigits') {
|
|
29
|
-
values = [1, 2, 3];
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
values = ['2-digit', 'numeric', 'narrow', 'short', 'long'];
|
|
33
|
-
}
|
|
34
|
-
var optionsPropIndex = values.indexOf(optionsProp);
|
|
35
|
-
var formatPropIndex = values.indexOf(formatProp);
|
|
36
|
-
var delta = Math.max(-2, Math.min(formatPropIndex - optionsPropIndex, 2));
|
|
37
|
-
if (delta === 2) {
|
|
38
|
-
score -= longMorePenalty;
|
|
39
|
-
}
|
|
40
|
-
else if (delta === 1) {
|
|
41
|
-
score -= shortMorePenalty;
|
|
42
|
-
}
|
|
43
|
-
else if (delta === -1) {
|
|
44
|
-
score -= shortLessPenalty;
|
|
45
|
-
}
|
|
46
|
-
else if (delta === -2) {
|
|
47
|
-
score -= longLessPenalty;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (score > bestScore) {
|
|
52
|
-
bestScore = score;
|
|
53
|
-
bestFormat = format;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return __assign({}, bestFormat);
|
|
57
|
-
}
|