@formatjs/intl-pluralrules 5.4.6 → 6.0.0
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/abstract/GetOperands.js +10 -13
- package/abstract/InitializePluralRules.js +9 -12
- package/abstract/ResolvePlural.d.ts +1 -1
- package/abstract/ResolvePlural.js +7 -10
- package/get_internal_slots.js +1 -4
- package/index.js +16 -20
- package/package.json +18 -11
- package/polyfill-force.js +2 -4
- package/polyfill.iife.js +58 -60
- package/polyfill.js +4 -6
- package/should-polyfill.js +4 -7
- package/supported-locales.generated.js +1 -4
- package/lib/abstract/GetOperands.d.ts +0 -32
- package/lib/abstract/GetOperands.js +0 -46
- package/lib/abstract/InitializePluralRules.d.ts +0 -8
- package/lib/abstract/InitializePluralRules.js +0 -17
- package/lib/abstract/ResolvePlural.d.ts +0 -13
- package/lib/abstract/ResolvePlural.js +0 -22
- package/lib/get_internal_slots.d.ts +0 -2
- package/lib/get_internal_slots.js +0 -9
- package/lib/index.d.ts +0 -20
- package/lib/index.js +0 -144
- package/lib/polyfill-force.d.ts +0 -1
- package/lib/polyfill-force.js +0 -7
- package/lib/polyfill.d.ts +0 -1
- package/lib/polyfill.js +0 -10
- package/lib/should-polyfill.d.ts +0 -1
- package/lib/should-polyfill.js +0 -18
- package/lib/supported-locales.generated.d.ts +0 -1
- package/lib/supported-locales.generated.js +0 -1
package/abstract/GetOperands.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GetOperands = GetOperands;
|
|
4
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
1
|
+
import { invariant, ToNumber, ZERO } from '@formatjs/ecma402-abstract';
|
|
5
2
|
/**
|
|
6
3
|
* http://ecma-international.org/ecma-402/7.0/index.html#sec-getoperands
|
|
7
4
|
* @param s
|
|
8
5
|
*/
|
|
9
|
-
function GetOperands(s) {
|
|
10
|
-
|
|
11
|
-
var n =
|
|
12
|
-
|
|
6
|
+
export function GetOperands(s) {
|
|
7
|
+
invariant(typeof s === 'string', "GetOperands should have been called with a string");
|
|
8
|
+
var n = ToNumber(s);
|
|
9
|
+
invariant(n.isFinite(), 'n should be finite');
|
|
13
10
|
var dp = s.indexOf('.');
|
|
14
11
|
var iv;
|
|
15
12
|
var f;
|
|
@@ -17,26 +14,26 @@ function GetOperands(s) {
|
|
|
17
14
|
var fv = '';
|
|
18
15
|
if (dp === -1) {
|
|
19
16
|
iv = n;
|
|
20
|
-
f =
|
|
17
|
+
f = ZERO;
|
|
21
18
|
v = 0;
|
|
22
19
|
}
|
|
23
20
|
else {
|
|
24
21
|
iv = s.slice(0, dp);
|
|
25
22
|
fv = s.slice(dp, s.length);
|
|
26
|
-
f =
|
|
23
|
+
f = ToNumber(fv);
|
|
27
24
|
v = fv.length;
|
|
28
25
|
}
|
|
29
|
-
var i =
|
|
26
|
+
var i = ToNumber(iv).abs();
|
|
30
27
|
var w;
|
|
31
28
|
var t;
|
|
32
29
|
if (!f.isZero()) {
|
|
33
30
|
var ft = fv.replace(/0+$/, '');
|
|
34
31
|
w = ft.length;
|
|
35
|
-
t =
|
|
32
|
+
t = ToNumber(ft);
|
|
36
33
|
}
|
|
37
34
|
else {
|
|
38
35
|
w = 0;
|
|
39
|
-
t =
|
|
36
|
+
t = ZERO;
|
|
40
37
|
}
|
|
41
38
|
return {
|
|
42
39
|
Number: n,
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
5
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
6
|
-
function InitializePluralRules(pl, locales, options, _a) {
|
|
1
|
+
import { CanonicalizeLocaleList, CoerceOptionsToObject, GetOption, SetNumberFormatDigitOptions, } from '@formatjs/ecma402-abstract';
|
|
2
|
+
import { ResolveLocale } from '@formatjs/intl-localematcher';
|
|
3
|
+
export function InitializePluralRules(pl, locales, options, _a) {
|
|
7
4
|
var availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getInternalSlots = _a.getInternalSlots;
|
|
8
|
-
var requestedLocales =
|
|
5
|
+
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
9
6
|
var opt = Object.create(null);
|
|
10
|
-
var opts =
|
|
7
|
+
var opts = CoerceOptionsToObject(options);
|
|
11
8
|
var internalSlots = getInternalSlots(pl);
|
|
12
9
|
internalSlots.initializedPluralRules = true;
|
|
13
|
-
var matcher =
|
|
10
|
+
var matcher = GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
|
|
14
11
|
opt.localeMatcher = matcher;
|
|
15
|
-
var r =
|
|
12
|
+
var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
16
13
|
internalSlots.locale = r.locale;
|
|
17
|
-
internalSlots.type =
|
|
18
|
-
|
|
14
|
+
internalSlots.type = GetOption(opts, 'type', 'string', ['cardinal', 'ordinal'], 'cardinal');
|
|
15
|
+
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, 'standard');
|
|
19
16
|
return pl;
|
|
20
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LDMLPluralRule, PluralRulesInternal } from '@formatjs/ecma402-abstract';
|
|
2
2
|
import Decimal from 'decimal.js';
|
|
3
|
-
import { OperandsRecord } from './GetOperands';
|
|
3
|
+
import { OperandsRecord } from './GetOperands.js';
|
|
4
4
|
/**
|
|
5
5
|
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
|
|
6
6
|
* @param pl
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ResolvePlural = ResolvePlural;
|
|
4
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
5
|
-
var GetOperands_1 = require("./GetOperands");
|
|
1
|
+
import { FormatNumericToString, invariant, Type, } from '@formatjs/ecma402-abstract';
|
|
2
|
+
import { GetOperands } from './GetOperands.js';
|
|
6
3
|
/**
|
|
7
4
|
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
|
|
8
5
|
* @param pl
|
|
9
6
|
* @param n
|
|
10
7
|
* @param PluralRuleSelect Has to pass in bc it's implementation-specific
|
|
11
8
|
*/
|
|
12
|
-
function ResolvePlural(pl, n, _a) {
|
|
9
|
+
export function ResolvePlural(pl, n, _a) {
|
|
13
10
|
var getInternalSlots = _a.getInternalSlots, PluralRuleSelect = _a.PluralRuleSelect;
|
|
14
11
|
var internalSlots = getInternalSlots(pl);
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
invariant(Type(internalSlots) === 'Object', 'pl has to be an object');
|
|
13
|
+
invariant('initializedPluralRules' in internalSlots, 'pluralrules must be initialized');
|
|
17
14
|
if (!n.isFinite()) {
|
|
18
15
|
return 'other';
|
|
19
16
|
}
|
|
20
17
|
var locale = internalSlots.locale, type = internalSlots.type;
|
|
21
|
-
var res =
|
|
18
|
+
var res = FormatNumericToString(internalSlots, n);
|
|
22
19
|
var s = res.formattedString;
|
|
23
|
-
var operands =
|
|
20
|
+
var operands = GetOperands(s);
|
|
24
21
|
return PluralRuleSelect(locale, type, n, operands);
|
|
25
22
|
}
|
package/get_internal_slots.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getInternalSlots;
|
|
4
1
|
var internalSlotMap = new WeakMap();
|
|
5
|
-
function getInternalSlots(x) {
|
|
2
|
+
export default function getInternalSlots(x) {
|
|
6
3
|
var internalSlots = internalSlotMap.get(x);
|
|
7
4
|
if (!internalSlots) {
|
|
8
5
|
internalSlots = Object.create(null);
|
package/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var InitializePluralRules_1 = require("./abstract/InitializePluralRules");
|
|
7
|
-
var ResolvePlural_1 = require("./abstract/ResolvePlural");
|
|
8
|
-
var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import { CanonicalizeLocaleList, SupportedLocales, ToNumber, } from '@formatjs/ecma402-abstract';
|
|
3
|
+
import { InitializePluralRules } from './abstract/InitializePluralRules.js';
|
|
4
|
+
import { ResolvePlural } from './abstract/ResolvePlural.js';
|
|
5
|
+
import getInternalSlots from './get_internal_slots.js';
|
|
9
6
|
function validateInstance(instance, method) {
|
|
10
7
|
if (!(instance instanceof PluralRules)) {
|
|
11
8
|
throw new TypeError("Method Intl.PluralRules.prototype.".concat(method, " called on incompatible receiver ").concat(String(instance)));
|
|
@@ -32,18 +29,18 @@ var PluralRules = /** @class */ (function () {
|
|
|
32
29
|
if (!newTarget) {
|
|
33
30
|
throw new TypeError("Intl.PluralRules must be called with 'new'");
|
|
34
31
|
}
|
|
35
|
-
return
|
|
32
|
+
return InitializePluralRules(this, locales, options, {
|
|
36
33
|
availableLocales: PluralRules.availableLocales,
|
|
37
34
|
relevantExtensionKeys: PluralRules.relevantExtensionKeys,
|
|
38
35
|
localeData: PluralRules.localeData,
|
|
39
36
|
getDefaultLocale: PluralRules.getDefaultLocale,
|
|
40
|
-
getInternalSlots:
|
|
37
|
+
getInternalSlots: getInternalSlots,
|
|
41
38
|
});
|
|
42
39
|
}
|
|
43
40
|
PluralRules.prototype.resolvedOptions = function () {
|
|
44
41
|
validateInstance(this, 'resolvedOptions');
|
|
45
42
|
var opts = Object.create(null);
|
|
46
|
-
var internalSlots = (
|
|
43
|
+
var internalSlots = getInternalSlots(this);
|
|
47
44
|
opts.locale = internalSlots.locale;
|
|
48
45
|
opts.type = internalSlots.type;
|
|
49
46
|
[
|
|
@@ -58,20 +55,19 @@ var PluralRules = /** @class */ (function () {
|
|
|
58
55
|
opts[field] = val;
|
|
59
56
|
}
|
|
60
57
|
});
|
|
61
|
-
opts.pluralCategories =
|
|
58
|
+
opts.pluralCategories = __spreadArray([], PluralRules.localeData[opts.locale].categories[opts.type], true);
|
|
62
59
|
return opts;
|
|
63
60
|
};
|
|
64
61
|
PluralRules.prototype.select = function (val) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return (0, ResolvePlural_1.ResolvePlural)(pr, n, { getInternalSlots: get_internal_slots_1.default, PluralRuleSelect: PluralRuleSelect });
|
|
62
|
+
validateInstance(this, 'select');
|
|
63
|
+
var n = ToNumber(val);
|
|
64
|
+
return ResolvePlural(this, n, { getInternalSlots: getInternalSlots, PluralRuleSelect: PluralRuleSelect });
|
|
69
65
|
};
|
|
70
66
|
PluralRules.prototype.toString = function () {
|
|
71
67
|
return '[object Intl.PluralRules]';
|
|
72
68
|
};
|
|
73
69
|
PluralRules.supportedLocalesOf = function (locales, options) {
|
|
74
|
-
return
|
|
70
|
+
return SupportedLocales(PluralRules.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
75
71
|
};
|
|
76
72
|
PluralRules.__addLocaleData = function () {
|
|
77
73
|
var data = [];
|
|
@@ -97,7 +93,7 @@ var PluralRules = /** @class */ (function () {
|
|
|
97
93
|
PluralRules.polyfilled = true;
|
|
98
94
|
return PluralRules;
|
|
99
95
|
}());
|
|
100
|
-
|
|
96
|
+
export { PluralRules };
|
|
101
97
|
try {
|
|
102
98
|
// IE11 does not have Symbol
|
|
103
99
|
if (typeof Symbol !== 'undefined') {
|
|
@@ -117,7 +113,7 @@ try {
|
|
|
117
113
|
configurable: true,
|
|
118
114
|
});
|
|
119
115
|
}
|
|
120
|
-
catch (
|
|
116
|
+
catch (_a) {
|
|
121
117
|
// IE 11 sets Function.prototype.length to be non-configurable which will cause the
|
|
122
118
|
// above Object.defineProperty to throw an error.
|
|
123
119
|
}
|
|
@@ -142,6 +138,6 @@ try {
|
|
|
142
138
|
configurable: true,
|
|
143
139
|
});
|
|
144
140
|
}
|
|
145
|
-
catch (
|
|
141
|
+
catch (_b) {
|
|
146
142
|
// Meta fixes for test262
|
|
147
143
|
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-pluralrules",
|
|
3
3
|
"description": "Polyfill for Intl.PluralRules",
|
|
4
|
-
"version": "
|
|
5
|
-
"license": "MIT",
|
|
4
|
+
"version": "6.0.0",
|
|
6
5
|
"author": "Long Ho <holevietlong@gmail.com>",
|
|
7
|
-
"
|
|
6
|
+
"bugs": "https://github.com/formatjs/formatjs/issues",
|
|
8
7
|
"dependencies": {
|
|
8
|
+
"@formatjs/ecma402-abstract": "3.0.0",
|
|
9
|
+
"@formatjs/intl-localematcher": "0.7.0",
|
|
9
10
|
"decimal.js": "^10.4.3",
|
|
10
|
-
"tslib": "^2.8.0"
|
|
11
|
-
"@formatjs/intl-localematcher": "0.6.2",
|
|
12
|
-
"@formatjs/ecma402-abstract": "2.3.6"
|
|
11
|
+
"tslib": "^2.8.0"
|
|
13
12
|
},
|
|
14
13
|
"devDependencies": {
|
|
15
|
-
"@formatjs/intl-getcanonicallocales": "
|
|
16
|
-
"@formatjs/intl-locale": "
|
|
14
|
+
"@formatjs/intl-getcanonicallocales": "3.0.0",
|
|
15
|
+
"@formatjs/intl-locale": "5.0.0"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./index.js",
|
|
19
|
+
"./polyfill.js": "./polyfill.js",
|
|
20
|
+
"./polyfill-force.js": "./polyfill-force.js",
|
|
21
|
+
"./should-polyfill.js": "./should-polyfill.js",
|
|
22
|
+
"./locale-data/*": "./locale-data/*"
|
|
17
23
|
},
|
|
18
|
-
"bugs": "https://github.com/formatjs/formatjs/issues",
|
|
19
24
|
"gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c",
|
|
20
25
|
"homepage": "https://github.com/formatjs/formatjs",
|
|
21
26
|
"keywords": [
|
|
@@ -26,6 +31,8 @@
|
|
|
26
31
|
"polyfill",
|
|
27
32
|
"rules"
|
|
28
33
|
],
|
|
29
|
-
"
|
|
30
|
-
"repository": "formatjs/formatjs.git"
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": "formatjs/formatjs.git",
|
|
36
|
+
"type": "module",
|
|
37
|
+
"types": "index.d.ts"
|
|
31
38
|
}
|
package/polyfill-force.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var _1 = require("./");
|
|
1
|
+
import { PluralRules } from './index.js';
|
|
4
2
|
Object.defineProperty(Intl, 'PluralRules', {
|
|
5
|
-
value:
|
|
3
|
+
value: PluralRules,
|
|
6
4
|
writable: true,
|
|
7
5
|
enumerable: false,
|
|
8
6
|
configurable: true,
|
package/polyfill.iife.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
return value;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
9
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CanonicalizeLocaleList.js
|
|
10
10
|
function CanonicalizeLocaleList(locales) {
|
|
11
11
|
return Intl.getCanonicalLocales(locales);
|
|
12
12
|
}
|
|
@@ -2371,12 +2371,11 @@
|
|
|
2371
2371
|
var Decimal = P.constructor = clone(DEFAULTS);
|
|
2372
2372
|
LN10 = new Decimal(LN10);
|
|
2373
2373
|
PI = new Decimal(PI);
|
|
2374
|
-
var decimal_default = Decimal;
|
|
2375
2374
|
|
|
2376
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2377
|
-
var TEN = new
|
|
2378
|
-
var ZERO = new
|
|
2379
|
-
var NEGATIVE_ZERO = new
|
|
2375
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js
|
|
2376
|
+
var TEN = new Decimal(10);
|
|
2377
|
+
var ZERO = new Decimal(0);
|
|
2378
|
+
var NEGATIVE_ZERO = new Decimal(-0);
|
|
2380
2379
|
|
|
2381
2380
|
// node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
2382
2381
|
var extendStatics = function(d, b) {
|
|
@@ -2410,7 +2409,7 @@
|
|
|
2410
2409
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2411
2410
|
}
|
|
2412
2411
|
|
|
2413
|
-
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/
|
|
2412
|
+
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
2414
2413
|
function memoize(fn, options) {
|
|
2415
2414
|
var cache = options && options.cache ? options.cache : cacheDefault;
|
|
2416
2415
|
var serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
@@ -2483,12 +2482,12 @@
|
|
|
2483
2482
|
monadic: strategyMonadic
|
|
2484
2483
|
};
|
|
2485
2484
|
|
|
2486
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2485
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/utils.js
|
|
2487
2486
|
function repeat(s, times) {
|
|
2488
2487
|
if (typeof s.repeat === "function") {
|
|
2489
2488
|
return s.repeat(times);
|
|
2490
2489
|
}
|
|
2491
|
-
var arr =
|
|
2490
|
+
var arr = Array.from({ length: times });
|
|
2492
2491
|
for (var i = 0; i < arr.length; i++) {
|
|
2493
2492
|
arr[i] = s;
|
|
2494
2493
|
}
|
|
@@ -2553,7 +2552,7 @@
|
|
|
2553
2552
|
strategy: strategies.variadic
|
|
2554
2553
|
});
|
|
2555
2554
|
|
|
2556
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2555
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/262.js
|
|
2557
2556
|
function ToString(o) {
|
|
2558
2557
|
if (typeof o === "symbol") {
|
|
2559
2558
|
throw TypeError("Cannot convert a Symbol value to a string");
|
|
@@ -2577,7 +2576,7 @@
|
|
|
2577
2576
|
if (typeof arg === "string") {
|
|
2578
2577
|
try {
|
|
2579
2578
|
return new Decimal(arg);
|
|
2580
|
-
} catch (
|
|
2579
|
+
} catch (_a) {
|
|
2581
2580
|
return new Decimal(NaN);
|
|
2582
2581
|
}
|
|
2583
2582
|
}
|
|
@@ -2672,7 +2671,7 @@
|
|
|
2672
2671
|
return input;
|
|
2673
2672
|
}
|
|
2674
2673
|
|
|
2675
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2674
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CoerceOptionsToObject.js
|
|
2676
2675
|
function CoerceOptionsToObject(options) {
|
|
2677
2676
|
if (typeof options === "undefined") {
|
|
2678
2677
|
return /* @__PURE__ */ Object.create(null);
|
|
@@ -2680,7 +2679,7 @@
|
|
|
2680
2679
|
return ToObject(options);
|
|
2681
2680
|
}
|
|
2682
2681
|
|
|
2683
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2682
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/DefaultNumberOption.js
|
|
2684
2683
|
function DefaultNumberOption(inputVal, min2, max2, fallback) {
|
|
2685
2684
|
if (inputVal === void 0) {
|
|
2686
2685
|
return fallback;
|
|
@@ -2692,13 +2691,13 @@
|
|
|
2692
2691
|
return Math.floor(val);
|
|
2693
2692
|
}
|
|
2694
2693
|
|
|
2695
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2694
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetNumberOption.js
|
|
2696
2695
|
function GetNumberOption(options, property, minimum, maximum, fallback) {
|
|
2697
2696
|
var val = options[property];
|
|
2698
2697
|
return DefaultNumberOption(val, minimum, maximum, fallback);
|
|
2699
2698
|
}
|
|
2700
2699
|
|
|
2701
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2700
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetOption.js
|
|
2702
2701
|
function GetOption(opts, prop, type, values, fallback) {
|
|
2703
2702
|
if (typeof opts !== "object") {
|
|
2704
2703
|
throw new TypeError("Options must be an object");
|
|
@@ -2724,7 +2723,7 @@
|
|
|
2724
2723
|
return fallback;
|
|
2725
2724
|
}
|
|
2726
2725
|
|
|
2727
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2726
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/IsSanctionedSimpleUnitIdentifier.js
|
|
2728
2727
|
var SANCTIONED_UNITS = [
|
|
2729
2728
|
"angle-degree",
|
|
2730
2729
|
"area-acre",
|
|
@@ -2775,7 +2774,7 @@
|
|
|
2775
2774
|
}
|
|
2776
2775
|
var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
|
|
2777
2776
|
|
|
2778
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2777
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ApplyUnsignedRoundingMode.js
|
|
2779
2778
|
function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
|
|
2780
2779
|
if (x.eq(r1))
|
|
2781
2780
|
return r1;
|
|
@@ -2809,12 +2808,12 @@
|
|
|
2809
2808
|
return r2;
|
|
2810
2809
|
}
|
|
2811
2810
|
|
|
2812
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2813
|
-
|
|
2811
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
|
|
2812
|
+
Decimal.set({
|
|
2814
2813
|
toExpPos: 100
|
|
2815
2814
|
});
|
|
2816
2815
|
|
|
2817
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2816
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/GetUnsignedRoundingMode.js
|
|
2818
2817
|
var negativeMapping = {
|
|
2819
2818
|
ceil: "zero",
|
|
2820
2819
|
floor: "infinity",
|
|
@@ -2844,15 +2843,15 @@
|
|
|
2844
2843
|
return positiveMapping[roundingMode];
|
|
2845
2844
|
}
|
|
2846
2845
|
|
|
2847
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2848
|
-
|
|
2846
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawFixed.js
|
|
2847
|
+
Decimal.set({
|
|
2849
2848
|
toExpPos: 100
|
|
2850
2849
|
});
|
|
2851
2850
|
function ToRawFixedFn(n, f) {
|
|
2852
|
-
return n.times(
|
|
2851
|
+
return n.times(Decimal.pow(10, -f));
|
|
2853
2852
|
}
|
|
2854
2853
|
function findN1R1(x, f, roundingIncrement) {
|
|
2855
|
-
var nx = x.times(
|
|
2854
|
+
var nx = x.times(Decimal.pow(10, f)).floor();
|
|
2856
2855
|
var n1 = nx.div(roundingIncrement).floor().times(roundingIncrement);
|
|
2857
2856
|
var r1 = ToRawFixedFn(n1, f);
|
|
2858
2857
|
return {
|
|
@@ -2861,7 +2860,7 @@
|
|
|
2861
2860
|
};
|
|
2862
2861
|
}
|
|
2863
2862
|
function findN2R2(x, f, roundingIncrement) {
|
|
2864
|
-
var nx = x.times(
|
|
2863
|
+
var nx = x.times(Decimal.pow(10, f)).ceil();
|
|
2865
2864
|
var n2 = nx.div(roundingIncrement).ceil().times(roundingIncrement);
|
|
2866
2865
|
var r2 = ToRawFixedFn(n2, f);
|
|
2867
2866
|
return {
|
|
@@ -2919,16 +2918,16 @@
|
|
|
2919
2918
|
};
|
|
2920
2919
|
}
|
|
2921
2920
|
|
|
2922
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2921
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawPrecision.js
|
|
2923
2922
|
function findN1E1R1(x, p) {
|
|
2924
|
-
var maxN1 =
|
|
2925
|
-
var minN1 =
|
|
2923
|
+
var maxN1 = Decimal.pow(10, p);
|
|
2924
|
+
var minN1 = Decimal.pow(10, p - 1);
|
|
2926
2925
|
var maxE1 = x.div(minN1).log(10).plus(p).minus(1).ceil();
|
|
2927
2926
|
var currentE1 = maxE1;
|
|
2928
2927
|
while (true) {
|
|
2929
|
-
var currentN1 = x.div(
|
|
2928
|
+
var currentN1 = x.div(Decimal.pow(10, currentE1.minus(p).plus(1))).floor();
|
|
2930
2929
|
if (currentN1.lessThan(maxN1) && currentN1.greaterThanOrEqualTo(minN1)) {
|
|
2931
|
-
var currentR1 = currentN1.times(
|
|
2930
|
+
var currentR1 = currentN1.times(Decimal.pow(10, currentE1.minus(p).plus(1)));
|
|
2932
2931
|
if (currentR1.lessThanOrEqualTo(x)) {
|
|
2933
2932
|
return {
|
|
2934
2933
|
n1: currentN1,
|
|
@@ -2941,14 +2940,14 @@
|
|
|
2941
2940
|
}
|
|
2942
2941
|
}
|
|
2943
2942
|
function findN2E2R2(x, p) {
|
|
2944
|
-
var maxN2 =
|
|
2945
|
-
var minN2 =
|
|
2943
|
+
var maxN2 = Decimal.pow(10, p);
|
|
2944
|
+
var minN2 = Decimal.pow(10, p - 1);
|
|
2946
2945
|
var minE2 = x.div(maxN2).log(10).plus(p).minus(1).floor();
|
|
2947
2946
|
var currentE2 = minE2;
|
|
2948
2947
|
while (true) {
|
|
2949
|
-
var currentN2 = x.div(
|
|
2948
|
+
var currentN2 = x.div(Decimal.pow(10, currentE2.minus(p).plus(1))).ceil();
|
|
2950
2949
|
if (currentN2.lessThan(maxN2) && currentN2.greaterThanOrEqualTo(minN2)) {
|
|
2951
|
-
var currentR2 = currentN2.times(
|
|
2950
|
+
var currentR2 = currentN2.times(Decimal.pow(10, currentE2.minus(p).plus(1)));
|
|
2952
2951
|
if (currentR2.greaterThanOrEqualTo(x)) {
|
|
2953
2952
|
return {
|
|
2954
2953
|
n2: currentN2,
|
|
@@ -3015,7 +3014,7 @@
|
|
|
3015
3014
|
};
|
|
3016
3015
|
}
|
|
3017
3016
|
|
|
3018
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
3017
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/FormatNumericToString.js
|
|
3019
3018
|
function FormatNumericToString(intlObject, _x) {
|
|
3020
3019
|
var x = _x;
|
|
3021
3020
|
var sign2;
|
|
@@ -3086,19 +3085,19 @@
|
|
|
3086
3085
|
return { roundedNumber: x, formattedString: string };
|
|
3087
3086
|
}
|
|
3088
3087
|
|
|
3089
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
3088
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js
|
|
3090
3089
|
var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
|
|
3091
3090
|
|
|
3092
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
3091
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/format_to_parts.js
|
|
3093
3092
|
var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
|
|
3094
3093
|
var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
|
|
3095
3094
|
|
|
3096
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
3095
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeLocaleList.js
|
|
3097
3096
|
function CanonicalizeLocaleList2(locales) {
|
|
3098
3097
|
return Intl.getCanonicalLocales(locales);
|
|
3099
3098
|
}
|
|
3100
3099
|
|
|
3101
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
3100
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/languageMatching.js
|
|
3102
3101
|
var data = {
|
|
3103
3102
|
supplemental: {
|
|
3104
3103
|
languageMatching: {
|
|
@@ -5720,7 +5719,7 @@
|
|
|
5720
5719
|
}
|
|
5721
5720
|
};
|
|
5722
5721
|
|
|
5723
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
5722
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/regions.generated.js
|
|
5724
5723
|
var regions = {
|
|
5725
5724
|
"001": [
|
|
5726
5725
|
"001",
|
|
@@ -7055,7 +7054,7 @@
|
|
|
7055
7054
|
]
|
|
7056
7055
|
};
|
|
7057
7056
|
|
|
7058
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7057
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/utils.js
|
|
7059
7058
|
var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
7060
7059
|
function invariant2(condition, message, Err) {
|
|
7061
7060
|
if (Err === void 0) {
|
|
@@ -7209,7 +7208,7 @@
|
|
|
7209
7208
|
return result;
|
|
7210
7209
|
}
|
|
7211
7210
|
|
|
7212
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7211
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestFitMatcher.js
|
|
7213
7212
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
7214
7213
|
var foundLocale;
|
|
7215
7214
|
var extension;
|
|
@@ -7234,7 +7233,7 @@
|
|
|
7234
7233
|
};
|
|
7235
7234
|
}
|
|
7236
7235
|
|
|
7237
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7236
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUValue.js
|
|
7238
7237
|
function CanonicalizeUValue(ukey, uvalue) {
|
|
7239
7238
|
var lowerValue = uvalue.toLowerCase();
|
|
7240
7239
|
invariant2(ukey !== void 0, "ukey must be defined");
|
|
@@ -7242,12 +7241,12 @@
|
|
|
7242
7241
|
return canonicalized;
|
|
7243
7242
|
}
|
|
7244
7243
|
|
|
7245
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7244
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUnicodeLocaleId.js
|
|
7246
7245
|
function CanonicalizeUnicodeLocaleId(locale) {
|
|
7247
7246
|
return Intl.getCanonicalLocales(locale)[0];
|
|
7248
7247
|
}
|
|
7249
7248
|
|
|
7250
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7249
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/InsertUnicodeExtensionAndCanonicalize.js
|
|
7251
7250
|
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
|
|
7252
7251
|
invariant2(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
|
|
7253
7252
|
var extension = "-u";
|
|
@@ -7278,7 +7277,7 @@
|
|
|
7278
7277
|
return CanonicalizeUnicodeLocaleId(newLocale);
|
|
7279
7278
|
}
|
|
7280
7279
|
|
|
7281
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7280
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestAvailableLocale.js
|
|
7282
7281
|
function BestAvailableLocale(availableLocales, locale) {
|
|
7283
7282
|
var candidate = locale;
|
|
7284
7283
|
while (true) {
|
|
@@ -7296,7 +7295,7 @@
|
|
|
7296
7295
|
}
|
|
7297
7296
|
}
|
|
7298
7297
|
|
|
7299
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7298
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupMatcher.js
|
|
7300
7299
|
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
7301
7300
|
var result = { locale: "" };
|
|
7302
7301
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
@@ -7315,7 +7314,7 @@
|
|
|
7315
7314
|
return result;
|
|
7316
7315
|
}
|
|
7317
7316
|
|
|
7318
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7317
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/UnicodeExtensionComponents.js
|
|
7319
7318
|
function UnicodeExtensionComponents(extension) {
|
|
7320
7319
|
invariant2(extension === extension.toLowerCase(), "Expected extension to be lowercase");
|
|
7321
7320
|
invariant2(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
|
|
@@ -7356,7 +7355,7 @@
|
|
|
7356
7355
|
return { attributes, keywords };
|
|
7357
7356
|
}
|
|
7358
7357
|
|
|
7359
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7358
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/ResolveLocale.js
|
|
7360
7359
|
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
7361
7360
|
var _a;
|
|
7362
7361
|
var matcher = options.localeMatcher;
|
|
@@ -7442,7 +7441,7 @@
|
|
|
7442
7441
|
return result;
|
|
7443
7442
|
}
|
|
7444
7443
|
|
|
7445
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7444
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupSupportedLocales.js
|
|
7446
7445
|
function LookupSupportedLocales(availableLocales, requestedLocales) {
|
|
7447
7446
|
var subset = [];
|
|
7448
7447
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
@@ -7456,7 +7455,7 @@
|
|
|
7456
7455
|
return subset;
|
|
7457
7456
|
}
|
|
7458
7457
|
|
|
7459
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7458
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/index.js
|
|
7460
7459
|
function match(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
7461
7460
|
return ResolveLocale(availableLocales, CanonicalizeLocaleList2(requestedLocales), {
|
|
7462
7461
|
localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
|
|
@@ -7465,7 +7464,7 @@
|
|
|
7465
7464
|
}).locale;
|
|
7466
7465
|
}
|
|
7467
7466
|
|
|
7468
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7467
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/SetNumberFormatDigitOptions.js
|
|
7469
7468
|
var VALID_ROUNDING_INCREMENTS = /* @__PURE__ */ new Set([
|
|
7470
7469
|
1,
|
|
7471
7470
|
2,
|
|
@@ -7575,7 +7574,7 @@
|
|
|
7575
7574
|
}
|
|
7576
7575
|
}
|
|
7577
7576
|
|
|
7578
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7577
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/SupportedLocales.js
|
|
7579
7578
|
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
7580
7579
|
var matcher = "best fit";
|
|
7581
7580
|
if (options !== void 0) {
|
|
@@ -7588,7 +7587,7 @@
|
|
|
7588
7587
|
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
7589
7588
|
}
|
|
7590
7589
|
|
|
7591
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7590
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/data.js
|
|
7592
7591
|
var MissingLocaleDataError = (
|
|
7593
7592
|
/** @class */
|
|
7594
7593
|
function(_super) {
|
|
@@ -7602,7 +7601,7 @@
|
|
|
7602
7601
|
}(Error)
|
|
7603
7602
|
);
|
|
7604
7603
|
|
|
7605
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7604
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/types/date-time.js
|
|
7606
7605
|
var RangePatternType;
|
|
7607
7606
|
(function(RangePatternType2) {
|
|
7608
7607
|
RangePatternType2["startRange"] = "startRange";
|
|
@@ -7781,10 +7780,9 @@
|
|
|
7781
7780
|
return opts;
|
|
7782
7781
|
}
|
|
7783
7782
|
select(val) {
|
|
7784
|
-
|
|
7785
|
-
validateInstance(pr, "select");
|
|
7783
|
+
validateInstance(this, "select");
|
|
7786
7784
|
const n = ToNumber(val);
|
|
7787
|
-
return ResolvePlural(
|
|
7785
|
+
return ResolvePlural(this, n, { getInternalSlots, PluralRuleSelect });
|
|
7788
7786
|
}
|
|
7789
7787
|
toString() {
|
|
7790
7788
|
return "[object Intl.PluralRules]";
|
|
@@ -7831,7 +7829,7 @@
|
|
|
7831
7829
|
enumerable: false,
|
|
7832
7830
|
configurable: true
|
|
7833
7831
|
});
|
|
7834
|
-
} catch (
|
|
7832
|
+
} catch (e) {
|
|
7835
7833
|
}
|
|
7836
7834
|
Object.defineProperty(PluralRules.prototype.constructor, "length", {
|
|
7837
7835
|
value: 0,
|
|
@@ -7851,7 +7849,7 @@
|
|
|
7851
7849
|
enumerable: false,
|
|
7852
7850
|
configurable: true
|
|
7853
7851
|
});
|
|
7854
|
-
} catch (
|
|
7852
|
+
} catch (e) {
|
|
7855
7853
|
}
|
|
7856
7854
|
|
|
7857
7855
|
// packages/intl-pluralrules/supported-locales.generated.ts
|
package/polyfill.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var should_polyfill_1 = require("./should-polyfill");
|
|
5
|
-
if ((0, should_polyfill_1.shouldPolyfill)()) {
|
|
1
|
+
import { PluralRules } from './index.js';
|
|
2
|
+
import { shouldPolyfill } from './should-polyfill.js';
|
|
3
|
+
if (shouldPolyfill()) {
|
|
6
4
|
Object.defineProperty(Intl, 'PluralRules', {
|
|
7
|
-
value:
|
|
5
|
+
value: PluralRules,
|
|
8
6
|
writable: true,
|
|
9
7
|
enumerable: false,
|
|
10
8
|
configurable: true,
|
package/should-polyfill.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.shouldPolyfill = shouldPolyfill;
|
|
4
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
5
|
-
var supported_locales_generated_1 = require("./supported-locales.generated");
|
|
1
|
+
import { match } from '@formatjs/intl-localematcher';
|
|
2
|
+
import { supportedLocales } from './supported-locales.generated.js';
|
|
6
3
|
function supportedLocalesOf(locale) {
|
|
7
4
|
if (!locale) {
|
|
8
5
|
return true;
|
|
@@ -10,12 +7,12 @@ function supportedLocalesOf(locale) {
|
|
|
10
7
|
var locales = Array.isArray(locale) ? locale : [locale];
|
|
11
8
|
return Intl.PluralRules.supportedLocalesOf(locales).length === locales.length;
|
|
12
9
|
}
|
|
13
|
-
function shouldPolyfill(locale) {
|
|
10
|
+
export function shouldPolyfill(locale) {
|
|
14
11
|
if (locale === void 0) { locale = 'en'; }
|
|
15
12
|
if (!('PluralRules' in Intl) ||
|
|
16
13
|
new Intl.PluralRules('en', { minimumFractionDigits: 2 }).select(1) ===
|
|
17
14
|
'one' ||
|
|
18
15
|
!supportedLocalesOf(locale)) {
|
|
19
|
-
return locale ?
|
|
16
|
+
return locale ? match([locale], supportedLocales, 'en') : undefined;
|
|
20
17
|
}
|
|
21
18
|
}
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.supportedLocales = void 0;
|
|
4
|
-
exports.supportedLocales = ["af", "ak", "am", "an", "ar", "ars", "as", "asa", "ast", "az", "bal", "be", "bem", "bez", "bg", "bho", "bm", "bn", "bo", "br", "brx", "bs", "ca", "ce", "ceb", "cgg", "chr", "ckb", "cs", "cy", "da", "de", "doi", "dsb", "dv", "dz", "ee", "el", "en", "eo", "es", "et", "eu", "fa", "ff", "fi", "fil", "fo", "fr", "fur", "fy", "ga", "gd", "gl", "gsw", "gu", "guw", "gv", "ha", "haw", "he", "hi", "hnj", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "io", "is", "it", "iu", "ja", "jbo", "jgo", "jmc", "jv", "jw", "ka", "kab", "kaj", "kcg", "kde", "kea", "kk", "kkj", "kl", "km", "kn", "ko", "ks", "ksb", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lij", "lkt", "ln", "lo", "lt", "lv", "mas", "mg", "mgo", "mk", "ml", "mn", "mo", "mr", "ms", "mt", "my", "nah", "naq", "nb", "nd", "ne", "nl", "nn", "nnh", "no", "nqo", "nr", "nso", "ny", "nyn", "om", "or", "os", "osa", "pa", "pap", "pcm", "pl", "prg", "ps", "pt", "pt-PT", "rm", "ro", "rof", "ru", "rwk", "sah", "saq", "sat", "sc", "scn", "sd", "sdh", "se", "seh", "ses", "sg", "sh", "shi", "si", "sk", "sl", "sma", "smi", "smj", "smn", "sms", "sn", "so", "sq", "sr", "ss", "ssy", "st", "su", "sv", "sw", "syr", "ta", "te", "teo", "th", "ti", "tig", "tk", "tl", "tn", "to", "tpi", "tr", "ts", "tzm", "ug", "uk", "und", "ur", "uz", "ve", "vi", "vo", "vun", "wa", "wae", "wo", "xh", "xog", "yi", "yo", "yue", "zh", "zu"];
|
|
1
|
+
export var supportedLocales = ["af", "ak", "am", "an", "ar", "ars", "as", "asa", "ast", "az", "bal", "be", "bem", "bez", "bg", "bho", "bm", "bn", "bo", "br", "brx", "bs", "ca", "ce", "ceb", "cgg", "chr", "ckb", "cs", "cy", "da", "de", "doi", "dsb", "dv", "dz", "ee", "el", "en", "eo", "es", "et", "eu", "fa", "ff", "fi", "fil", "fo", "fr", "fur", "fy", "ga", "gd", "gl", "gsw", "gu", "guw", "gv", "ha", "haw", "he", "hi", "hnj", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "io", "is", "it", "iu", "ja", "jbo", "jgo", "jmc", "jv", "jw", "ka", "kab", "kaj", "kcg", "kde", "kea", "kk", "kkj", "kl", "km", "kn", "ko", "ks", "ksb", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lij", "lkt", "ln", "lo", "lt", "lv", "mas", "mg", "mgo", "mk", "ml", "mn", "mo", "mr", "ms", "mt", "my", "nah", "naq", "nb", "nd", "ne", "nl", "nn", "nnh", "no", "nqo", "nr", "nso", "ny", "nyn", "om", "or", "os", "osa", "pa", "pap", "pcm", "pl", "prg", "ps", "pt", "pt-PT", "rm", "ro", "rof", "ru", "rwk", "sah", "saq", "sat", "sc", "scn", "sd", "sdh", "se", "seh", "ses", "sg", "sh", "shi", "si", "sk", "sl", "sma", "smi", "smj", "smn", "sms", "sn", "so", "sq", "sr", "ss", "ssy", "st", "su", "sv", "sw", "syr", "ta", "te", "teo", "th", "ti", "tig", "tk", "tl", "tn", "to", "tpi", "tr", "ts", "tzm", "ug", "uk", "und", "ur", "uz", "ve", "vi", "vo", "vun", "wa", "wae", "wo", "xh", "xog", "yi", "yo", "yue", "zh", "zu"];
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Decimal from 'decimal.js';
|
|
2
|
-
export interface OperandsRecord {
|
|
3
|
-
/**
|
|
4
|
-
* Absolute value of the source number (integer and decimals)
|
|
5
|
-
*/
|
|
6
|
-
Number: Decimal;
|
|
7
|
-
/**
|
|
8
|
-
* Number of digits of `number`
|
|
9
|
-
*/
|
|
10
|
-
IntegerDigits: number;
|
|
11
|
-
/**
|
|
12
|
-
* Number of visible fraction digits in [[Number]], with trailing zeroes.
|
|
13
|
-
*/
|
|
14
|
-
NumberOfFractionDigits: number;
|
|
15
|
-
/**
|
|
16
|
-
* Number of visible fraction digits in [[Number]], without trailing zeroes.
|
|
17
|
-
*/
|
|
18
|
-
NumberOfFractionDigitsWithoutTrailing: number;
|
|
19
|
-
/**
|
|
20
|
-
* Number of visible fractional digits in [[Number]], with trailing zeroes.
|
|
21
|
-
*/
|
|
22
|
-
FractionDigits: number;
|
|
23
|
-
/**
|
|
24
|
-
* Number of visible fractional digits in [[Number]], without trailing zeroes.
|
|
25
|
-
*/
|
|
26
|
-
FractionDigitsWithoutTrailing: number;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-getoperands
|
|
30
|
-
* @param s
|
|
31
|
-
*/
|
|
32
|
-
export declare function GetOperands(s: string): OperandsRecord;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { invariant, ToNumber, ZERO } from '@formatjs/ecma402-abstract';
|
|
2
|
-
/**
|
|
3
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-getoperands
|
|
4
|
-
* @param s
|
|
5
|
-
*/
|
|
6
|
-
export function GetOperands(s) {
|
|
7
|
-
invariant(typeof s === 'string', "GetOperands should have been called with a string");
|
|
8
|
-
var n = ToNumber(s);
|
|
9
|
-
invariant(n.isFinite(), 'n should be finite');
|
|
10
|
-
var dp = s.indexOf('.');
|
|
11
|
-
var iv;
|
|
12
|
-
var f;
|
|
13
|
-
var v;
|
|
14
|
-
var fv = '';
|
|
15
|
-
if (dp === -1) {
|
|
16
|
-
iv = n;
|
|
17
|
-
f = ZERO;
|
|
18
|
-
v = 0;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
iv = s.slice(0, dp);
|
|
22
|
-
fv = s.slice(dp, s.length);
|
|
23
|
-
f = ToNumber(fv);
|
|
24
|
-
v = fv.length;
|
|
25
|
-
}
|
|
26
|
-
var i = ToNumber(iv).abs();
|
|
27
|
-
var w;
|
|
28
|
-
var t;
|
|
29
|
-
if (!f.isZero()) {
|
|
30
|
-
var ft = fv.replace(/0+$/, '');
|
|
31
|
-
w = ft.length;
|
|
32
|
-
t = ToNumber(ft);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
w = 0;
|
|
36
|
-
t = ZERO;
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
Number: n,
|
|
40
|
-
IntegerDigits: i.toNumber(),
|
|
41
|
-
NumberOfFractionDigits: v,
|
|
42
|
-
NumberOfFractionDigitsWithoutTrailing: w,
|
|
43
|
-
FractionDigits: f.toNumber(),
|
|
44
|
-
FractionDigitsWithoutTrailing: t.toNumber(),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PluralRulesData, PluralRulesInternal } from '@formatjs/ecma402-abstract';
|
|
2
|
-
export declare function InitializePluralRules(pl: Intl.PluralRules, locales: string | string[] | undefined, options: Intl.PluralRulesOptions | undefined, { availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, getInternalSlots, }: {
|
|
3
|
-
availableLocales: Set<string>;
|
|
4
|
-
relevantExtensionKeys: string[];
|
|
5
|
-
localeData: Record<string, PluralRulesData | undefined>;
|
|
6
|
-
getDefaultLocale(): string;
|
|
7
|
-
getInternalSlots(pl: Intl.PluralRules): PluralRulesInternal;
|
|
8
|
-
}): Intl.PluralRules;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CanonicalizeLocaleList, CoerceOptionsToObject, GetOption, SetNumberFormatDigitOptions, } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import { ResolveLocale } from '@formatjs/intl-localematcher';
|
|
3
|
-
export function InitializePluralRules(pl, locales, options, _a) {
|
|
4
|
-
var availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getInternalSlots = _a.getInternalSlots;
|
|
5
|
-
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
6
|
-
var opt = Object.create(null);
|
|
7
|
-
var opts = CoerceOptionsToObject(options);
|
|
8
|
-
var internalSlots = getInternalSlots(pl);
|
|
9
|
-
internalSlots.initializedPluralRules = true;
|
|
10
|
-
var matcher = GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
|
|
11
|
-
opt.localeMatcher = matcher;
|
|
12
|
-
var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
13
|
-
internalSlots.locale = r.locale;
|
|
14
|
-
internalSlots.type = GetOption(opts, 'type', 'string', ['cardinal', 'ordinal'], 'cardinal');
|
|
15
|
-
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, 'standard');
|
|
16
|
-
return pl;
|
|
17
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { LDMLPluralRule, PluralRulesInternal } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import Decimal from 'decimal.js';
|
|
3
|
-
import { OperandsRecord } from './GetOperands';
|
|
4
|
-
/**
|
|
5
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
|
|
6
|
-
* @param pl
|
|
7
|
-
* @param n
|
|
8
|
-
* @param PluralRuleSelect Has to pass in bc it's implementation-specific
|
|
9
|
-
*/
|
|
10
|
-
export declare function ResolvePlural(pl: Intl.PluralRules, n: Decimal, { getInternalSlots, PluralRuleSelect, }: {
|
|
11
|
-
getInternalSlots(pl: Intl.PluralRules): PluralRulesInternal;
|
|
12
|
-
PluralRuleSelect: (locale: string, type: 'cardinal' | 'ordinal', n: Decimal, operands: OperandsRecord) => LDMLPluralRule;
|
|
13
|
-
}): LDMLPluralRule;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { FormatNumericToString, invariant, Type, } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import { GetOperands } from './GetOperands';
|
|
3
|
-
/**
|
|
4
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
|
|
5
|
-
* @param pl
|
|
6
|
-
* @param n
|
|
7
|
-
* @param PluralRuleSelect Has to pass in bc it's implementation-specific
|
|
8
|
-
*/
|
|
9
|
-
export function ResolvePlural(pl, n, _a) {
|
|
10
|
-
var getInternalSlots = _a.getInternalSlots, PluralRuleSelect = _a.PluralRuleSelect;
|
|
11
|
-
var internalSlots = getInternalSlots(pl);
|
|
12
|
-
invariant(Type(internalSlots) === 'Object', 'pl has to be an object');
|
|
13
|
-
invariant('initializedPluralRules' in internalSlots, 'pluralrules must be initialized');
|
|
14
|
-
if (!n.isFinite()) {
|
|
15
|
-
return 'other';
|
|
16
|
-
}
|
|
17
|
-
var locale = internalSlots.locale, type = internalSlots.type;
|
|
18
|
-
var res = FormatNumericToString(internalSlots, n);
|
|
19
|
-
var s = res.formattedString;
|
|
20
|
-
var operands = GetOperands(s);
|
|
21
|
-
return PluralRuleSelect(locale, type, n, operands);
|
|
22
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var internalSlotMap = new WeakMap();
|
|
2
|
-
export default function getInternalSlots(x) {
|
|
3
|
-
var internalSlots = internalSlotMap.get(x);
|
|
4
|
-
if (!internalSlots) {
|
|
5
|
-
internalSlots = Object.create(null);
|
|
6
|
-
internalSlotMap.set(x, internalSlots);
|
|
7
|
-
}
|
|
8
|
-
return internalSlots;
|
|
9
|
-
}
|
package/lib/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { LDMLPluralRule, NumberFormatDigitInternalSlots, PluralRulesData, PluralRulesLocaleData } from '@formatjs/ecma402-abstract';
|
|
2
|
-
export interface PluralRulesInternal extends NumberFormatDigitInternalSlots {
|
|
3
|
-
initializedPluralRules: boolean;
|
|
4
|
-
locale: string;
|
|
5
|
-
type: 'cardinal' | 'ordinal';
|
|
6
|
-
}
|
|
7
|
-
export declare class PluralRules implements Intl.PluralRules {
|
|
8
|
-
constructor(locales?: string | string[], options?: Intl.PluralRulesOptions);
|
|
9
|
-
resolvedOptions(): Intl.ResolvedPluralRulesOptions;
|
|
10
|
-
select(val: number): LDMLPluralRule;
|
|
11
|
-
toString(): string;
|
|
12
|
-
static supportedLocalesOf(locales?: string | string[], options?: Pick<Intl.PluralRulesOptions, 'localeMatcher'>): string[];
|
|
13
|
-
static __addLocaleData(...data: PluralRulesLocaleData[]): void;
|
|
14
|
-
static localeData: Record<string, PluralRulesData>;
|
|
15
|
-
static availableLocales: Set<string>;
|
|
16
|
-
static __defaultLocale: string;
|
|
17
|
-
static getDefaultLocale(): string;
|
|
18
|
-
static relevantExtensionKeys: never[];
|
|
19
|
-
static polyfilled: boolean;
|
|
20
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { __spreadArray } from "tslib";
|
|
2
|
-
import { CanonicalizeLocaleList, SupportedLocales, ToNumber, } from '@formatjs/ecma402-abstract';
|
|
3
|
-
import { InitializePluralRules } from './abstract/InitializePluralRules';
|
|
4
|
-
import { ResolvePlural } from './abstract/ResolvePlural';
|
|
5
|
-
import getInternalSlots from './get_internal_slots';
|
|
6
|
-
function validateInstance(instance, method) {
|
|
7
|
-
if (!(instance instanceof PluralRules)) {
|
|
8
|
-
throw new TypeError("Method Intl.PluralRules.prototype.".concat(method, " called on incompatible receiver ").concat(String(instance)));
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-pluralruleselect
|
|
13
|
-
* @param locale
|
|
14
|
-
* @param type
|
|
15
|
-
* @param _n
|
|
16
|
-
* @param param3
|
|
17
|
-
*/
|
|
18
|
-
function PluralRuleSelect(locale, type, _n, _a) {
|
|
19
|
-
var IntegerDigits = _a.IntegerDigits, NumberOfFractionDigits = _a.NumberOfFractionDigits, FractionDigits = _a.FractionDigits;
|
|
20
|
-
return PluralRules.localeData[locale].fn(NumberOfFractionDigits
|
|
21
|
-
? "".concat(IntegerDigits, ".").concat(FractionDigits)
|
|
22
|
-
: IntegerDigits, type === 'ordinal');
|
|
23
|
-
}
|
|
24
|
-
var PluralRules = /** @class */ (function () {
|
|
25
|
-
function PluralRules(locales, options) {
|
|
26
|
-
// test262/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js
|
|
27
|
-
// Cannot use `new.target` bc of IE11 & TS transpiles it to something else
|
|
28
|
-
var newTarget = this && this instanceof PluralRules ? this.constructor : void 0;
|
|
29
|
-
if (!newTarget) {
|
|
30
|
-
throw new TypeError("Intl.PluralRules must be called with 'new'");
|
|
31
|
-
}
|
|
32
|
-
return InitializePluralRules(this, locales, options, {
|
|
33
|
-
availableLocales: PluralRules.availableLocales,
|
|
34
|
-
relevantExtensionKeys: PluralRules.relevantExtensionKeys,
|
|
35
|
-
localeData: PluralRules.localeData,
|
|
36
|
-
getDefaultLocale: PluralRules.getDefaultLocale,
|
|
37
|
-
getInternalSlots: getInternalSlots,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
PluralRules.prototype.resolvedOptions = function () {
|
|
41
|
-
validateInstance(this, 'resolvedOptions');
|
|
42
|
-
var opts = Object.create(null);
|
|
43
|
-
var internalSlots = getInternalSlots(this);
|
|
44
|
-
opts.locale = internalSlots.locale;
|
|
45
|
-
opts.type = internalSlots.type;
|
|
46
|
-
[
|
|
47
|
-
'minimumIntegerDigits',
|
|
48
|
-
'minimumFractionDigits',
|
|
49
|
-
'maximumFractionDigits',
|
|
50
|
-
'minimumSignificantDigits',
|
|
51
|
-
'maximumSignificantDigits',
|
|
52
|
-
].forEach(function (field) {
|
|
53
|
-
var val = internalSlots[field];
|
|
54
|
-
if (val !== undefined) {
|
|
55
|
-
opts[field] = val;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
opts.pluralCategories = __spreadArray([], PluralRules.localeData[opts.locale].categories[opts.type], true);
|
|
59
|
-
return opts;
|
|
60
|
-
};
|
|
61
|
-
PluralRules.prototype.select = function (val) {
|
|
62
|
-
var pr = this;
|
|
63
|
-
validateInstance(pr, 'select');
|
|
64
|
-
var n = ToNumber(val);
|
|
65
|
-
return ResolvePlural(pr, n, { getInternalSlots: getInternalSlots, PluralRuleSelect: PluralRuleSelect });
|
|
66
|
-
};
|
|
67
|
-
PluralRules.prototype.toString = function () {
|
|
68
|
-
return '[object Intl.PluralRules]';
|
|
69
|
-
};
|
|
70
|
-
PluralRules.supportedLocalesOf = function (locales, options) {
|
|
71
|
-
return SupportedLocales(PluralRules.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
72
|
-
};
|
|
73
|
-
PluralRules.__addLocaleData = function () {
|
|
74
|
-
var data = [];
|
|
75
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
76
|
-
data[_i] = arguments[_i];
|
|
77
|
-
}
|
|
78
|
-
for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
|
|
79
|
-
var _b = data_1[_a], d = _b.data, locale = _b.locale;
|
|
80
|
-
PluralRules.localeData[locale] = d;
|
|
81
|
-
PluralRules.availableLocales.add(locale);
|
|
82
|
-
if (!PluralRules.__defaultLocale) {
|
|
83
|
-
PluralRules.__defaultLocale = locale;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
PluralRules.getDefaultLocale = function () {
|
|
88
|
-
return PluralRules.__defaultLocale;
|
|
89
|
-
};
|
|
90
|
-
PluralRules.localeData = {};
|
|
91
|
-
PluralRules.availableLocales = new Set();
|
|
92
|
-
PluralRules.__defaultLocale = '';
|
|
93
|
-
PluralRules.relevantExtensionKeys = [];
|
|
94
|
-
PluralRules.polyfilled = true;
|
|
95
|
-
return PluralRules;
|
|
96
|
-
}());
|
|
97
|
-
export { PluralRules };
|
|
98
|
-
try {
|
|
99
|
-
// IE11 does not have Symbol
|
|
100
|
-
if (typeof Symbol !== 'undefined') {
|
|
101
|
-
Object.defineProperty(PluralRules.prototype, Symbol.toStringTag, {
|
|
102
|
-
value: 'Intl.PluralRules',
|
|
103
|
-
writable: false,
|
|
104
|
-
enumerable: false,
|
|
105
|
-
configurable: true,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
// https://github.com/tc39/test262/blob/master/test/intl402/PluralRules/length.js
|
|
110
|
-
Object.defineProperty(PluralRules, 'length', {
|
|
111
|
-
value: 0,
|
|
112
|
-
writable: false,
|
|
113
|
-
enumerable: false,
|
|
114
|
-
configurable: true,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
// IE 11 sets Function.prototype.length to be non-configurable which will cause the
|
|
119
|
-
// above Object.defineProperty to throw an error.
|
|
120
|
-
}
|
|
121
|
-
// https://github.com/tc39/test262/blob/master/test/intl402/RelativeTimeFormat/constructor/length.js
|
|
122
|
-
Object.defineProperty(PluralRules.prototype.constructor, 'length', {
|
|
123
|
-
value: 0,
|
|
124
|
-
writable: false,
|
|
125
|
-
enumerable: false,
|
|
126
|
-
configurable: true,
|
|
127
|
-
});
|
|
128
|
-
// https://github.com/tc39/test262/blob/master/test/intl402/RelativeTimeFormat/constructor/supportedLocalesOf/length.js
|
|
129
|
-
Object.defineProperty(PluralRules.supportedLocalesOf, 'length', {
|
|
130
|
-
value: 1,
|
|
131
|
-
writable: false,
|
|
132
|
-
enumerable: false,
|
|
133
|
-
configurable: true,
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(PluralRules, 'name', {
|
|
136
|
-
value: 'PluralRules',
|
|
137
|
-
writable: false,
|
|
138
|
-
enumerable: false,
|
|
139
|
-
configurable: true,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
catch (ex) {
|
|
143
|
-
// Meta fixes for test262
|
|
144
|
-
}
|
package/lib/polyfill-force.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/polyfill-force.js
DELETED
package/lib/polyfill.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/polyfill.js
DELETED
package/lib/should-polyfill.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function shouldPolyfill(locale?: string): string | undefined;
|
package/lib/should-polyfill.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { match } from '@formatjs/intl-localematcher';
|
|
2
|
-
import { supportedLocales } from './supported-locales.generated';
|
|
3
|
-
function supportedLocalesOf(locale) {
|
|
4
|
-
if (!locale) {
|
|
5
|
-
return true;
|
|
6
|
-
}
|
|
7
|
-
var locales = Array.isArray(locale) ? locale : [locale];
|
|
8
|
-
return Intl.PluralRules.supportedLocalesOf(locales).length === locales.length;
|
|
9
|
-
}
|
|
10
|
-
export function shouldPolyfill(locale) {
|
|
11
|
-
if (locale === void 0) { locale = 'en'; }
|
|
12
|
-
if (!('PluralRules' in Intl) ||
|
|
13
|
-
new Intl.PluralRules('en', { minimumFractionDigits: 2 }).select(1) ===
|
|
14
|
-
'one' ||
|
|
15
|
-
!supportedLocalesOf(locale)) {
|
|
16
|
-
return locale ? match([locale], supportedLocales, 'en') : undefined;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const supportedLocales: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export var supportedLocales = ["af", "ak", "am", "an", "ar", "ars", "as", "asa", "ast", "az", "bal", "be", "bem", "bez", "bg", "bho", "bm", "bn", "bo", "br", "brx", "bs", "ca", "ce", "ceb", "cgg", "chr", "ckb", "cs", "cy", "da", "de", "doi", "dsb", "dv", "dz", "ee", "el", "en", "eo", "es", "et", "eu", "fa", "ff", "fi", "fil", "fo", "fr", "fur", "fy", "ga", "gd", "gl", "gsw", "gu", "guw", "gv", "ha", "haw", "he", "hi", "hnj", "hr", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "io", "is", "it", "iu", "ja", "jbo", "jgo", "jmc", "jv", "jw", "ka", "kab", "kaj", "kcg", "kde", "kea", "kk", "kkj", "kl", "km", "kn", "ko", "ks", "ksb", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lij", "lkt", "ln", "lo", "lt", "lv", "mas", "mg", "mgo", "mk", "ml", "mn", "mo", "mr", "ms", "mt", "my", "nah", "naq", "nb", "nd", "ne", "nl", "nn", "nnh", "no", "nqo", "nr", "nso", "ny", "nyn", "om", "or", "os", "osa", "pa", "pap", "pcm", "pl", "prg", "ps", "pt", "pt-PT", "rm", "ro", "rof", "ru", "rwk", "sah", "saq", "sat", "sc", "scn", "sd", "sdh", "se", "seh", "ses", "sg", "sh", "shi", "si", "sk", "sl", "sma", "smi", "smj", "smn", "sms", "sn", "so", "sq", "sr", "ss", "ssy", "st", "su", "sv", "sw", "syr", "ta", "te", "teo", "th", "ti", "tig", "tk", "tl", "tn", "to", "tpi", "tr", "ts", "tzm", "ug", "uk", "und", "ur", "uz", "ve", "vi", "vo", "vun", "wa", "wae", "wo", "xh", "xog", "yi", "yo", "yue", "zh", "zu"];
|