@formatjs/intl-numberformat 9.1.0 → 9.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +6 -6
- package/polyfill-force.js +7 -9
- package/polyfill.iife.js +3289 -3426
- package/polyfill.js +8 -10
- package/should-polyfill.js +56 -66
- package/src/core.d.ts +4 -3
- package/src/core.js +175 -215
- package/src/currency-digits.generated.js +76 -76
- package/src/get_internal_slots.d.ts +2 -1
- package/src/get_internal_slots.js +8 -7
- package/src/numbering-systems.generated.js +99 -1
- package/src/to_locale_string.d.ts +4 -4
- package/src/to_locale_string.js +7 -6
- package/src/types.d.ts +18 -17
- package/src/types.js +1 -1
- package/supported-locales.generated.js +573 -1
package/polyfill.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { NumberFormat } from
|
|
2
|
-
import { toLocaleString as _toLocaleString } from
|
|
3
|
-
import { defineProperty } from
|
|
4
|
-
import { shouldPolyfill } from
|
|
1
|
+
import { NumberFormat } from "./src/core.js";
|
|
2
|
+
import { toLocaleString as _toLocaleString } from "./src/to_locale_string.js";
|
|
3
|
+
import { defineProperty } from "@formatjs/ecma402-abstract";
|
|
4
|
+
import { shouldPolyfill } from "./should-polyfill.js";
|
|
5
5
|
if (shouldPolyfill()) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
});
|
|
6
|
+
defineProperty(Intl, "NumberFormat", { value: NumberFormat });
|
|
7
|
+
defineProperty(Number.prototype, "toLocaleString", { value: function toLocaleString(locales, options) {
|
|
8
|
+
return _toLocaleString(this, locales, options);
|
|
9
|
+
} });
|
|
12
10
|
}
|
package/should-polyfill.js
CHANGED
|
@@ -1,78 +1,68 @@
|
|
|
1
|
-
import { match } from
|
|
2
|
-
import { supportedLocales } from
|
|
1
|
+
import { match } from "@formatjs/intl-localematcher";
|
|
2
|
+
import { supportedLocales } from "./supported-locales.generated.js";
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
* Check if this is old Node that only supports en
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
7
|
function onlySupportsEn() {
|
|
8
|
-
|
|
9
|
-
!Intl.NumberFormat.supportedLocalesOf(['es']).length);
|
|
8
|
+
return !Intl.NumberFormat.polyfilled && !Intl.NumberFormat.supportedLocalesOf(["es"]).length;
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
* Check if Intl.NumberFormat is ES2020 compatible.
|
|
12
|
+
* Caveat: we are not checking `toLocaleString`.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @param unit unit to check
|
|
16
|
+
*/
|
|
18
17
|
function supportsES2020() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return true;
|
|
18
|
+
try {
|
|
19
|
+
const s = new Intl.NumberFormat("en", {
|
|
20
|
+
style: "unit",
|
|
21
|
+
unit: "bit",
|
|
22
|
+
unitDisplay: "long",
|
|
23
|
+
notation: "scientific"
|
|
24
|
+
}).format(1e4);
|
|
25
|
+
// Check for a plurality bug in environment that uses the older versions of ICU:
|
|
26
|
+
// https://unicode-org.atlassian.net/browse/ICU-13836
|
|
27
|
+
if (s !== "1E4 bits") {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
* Check if Intl.NumberFormat is ES2020 compatible.
|
|
37
|
+
* Caveat: we are not checking `toLocaleString`.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
* @param unit unit to check
|
|
41
|
+
*/
|
|
44
42
|
function supportsES2023() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
43
|
+
try {
|
|
44
|
+
const s = new Intl.NumberFormat("en", {
|
|
45
|
+
notation: "compact",
|
|
46
|
+
minimumSignificantDigits: 3,
|
|
47
|
+
maximumSignificantDigits: 3,
|
|
48
|
+
minimumFractionDigits: 2,
|
|
49
|
+
maximumFractionDigits: 2,
|
|
50
|
+
roundingPriority: "morePrecision"
|
|
51
|
+
}).format(1e8);
|
|
52
|
+
return s === "100.00M";
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
60
56
|
}
|
|
61
57
|
function supportedLocalesOf(locale) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
if (!locale) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
const locales = Array.isArray(locale) ? locale : [locale];
|
|
62
|
+
return Intl.NumberFormat.supportedLocalesOf(locales).length === locales.length;
|
|
67
63
|
}
|
|
68
|
-
export function shouldPolyfill(locale) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
!supportsES2020() ||
|
|
73
|
-
!supportsES2023() ||
|
|
74
|
-
onlySupportsEn() ||
|
|
75
|
-
!supportedLocalesOf(locale)) {
|
|
76
|
-
return locale ? match([locale], supportedLocales, 'en') : undefined;
|
|
77
|
-
}
|
|
64
|
+
export function shouldPolyfill(locale = "en") {
|
|
65
|
+
if (typeof Intl === "undefined" || !("NumberFormat" in Intl) || !supportsES2020() || !supportsES2023() || onlySupportsEn() || !supportedLocalesOf(locale)) {
|
|
66
|
+
return locale ? match([locale], supportedLocales, "en") : undefined;
|
|
67
|
+
}
|
|
78
68
|
}
|
package/src/core.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { NumberFormatConstructor, NumberFormat as NumberFormatType } from
|
|
1
|
+
import { type NumberFormatConstructor, type NumberFormat as NumberFormatType } from "./types.js";
|
|
2
|
+
// Merge declaration with the constructor defined below.
|
|
2
3
|
export type NumberFormat = NumberFormatType;
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
* https://tc39.es/ecma402/#sec-intl-numberformat-constructor
|
|
6
|
+
*/
|
|
6
7
|
export declare const NumberFormat: NumberFormatConstructor;
|
package/src/core.js
CHANGED
|
@@ -1,236 +1,196 @@
|
|
|
1
|
-
import { CanonicalizeLocaleList, FormatNumeric, FormatNumericRange, FormatNumericRangeToParts, FormatNumericToParts, InitializeNumberFormat, OrdinaryHasInstance, SupportedLocales, ToIntlMathematicalValue, createMemoizedPluralRules, defineProperty, invariant
|
|
2
|
-
import { currencyDigitsData } from
|
|
3
|
-
import { numberingSystemNames } from
|
|
4
|
-
import getInternalSlots from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { CanonicalizeLocaleList, FormatNumeric, FormatNumericRange, FormatNumericRangeToParts, FormatNumericToParts, InitializeNumberFormat, OrdinaryHasInstance, SupportedLocales, ToIntlMathematicalValue, createMemoizedPluralRules, defineProperty, invariant } from "@formatjs/ecma402-abstract";
|
|
2
|
+
import { currencyDigitsData } from "./currency-digits.generated.js";
|
|
3
|
+
import { numberingSystemNames } from "./numbering-systems.generated.js";
|
|
4
|
+
import getInternalSlots from "./get_internal_slots.js";
|
|
5
|
+
import "./types.js";
|
|
6
|
+
const RESOLVED_OPTIONS_KEYS = [
|
|
7
|
+
"locale",
|
|
8
|
+
"numberingSystem",
|
|
9
|
+
"style",
|
|
10
|
+
"currency",
|
|
11
|
+
"currencyDisplay",
|
|
12
|
+
"currencySign",
|
|
13
|
+
"unit",
|
|
14
|
+
"unitDisplay",
|
|
15
|
+
"minimumIntegerDigits",
|
|
16
|
+
"minimumFractionDigits",
|
|
17
|
+
"maximumFractionDigits",
|
|
18
|
+
"minimumSignificantDigits",
|
|
19
|
+
"maximumSignificantDigits",
|
|
20
|
+
"useGrouping",
|
|
21
|
+
"notation",
|
|
22
|
+
"compactDisplay",
|
|
23
|
+
"signDisplay"
|
|
23
24
|
];
|
|
24
25
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
* https://tc39.es/ecma402/#sec-intl-numberformat-constructor
|
|
27
|
+
*/
|
|
28
|
+
export const NumberFormat = function(locales, options) {
|
|
29
|
+
// Cannot use `new.target` bc of IE11 & TS transpiles it to something else
|
|
30
|
+
if (!this || !OrdinaryHasInstance(NumberFormat, this)) {
|
|
31
|
+
return new NumberFormat(locales, options);
|
|
32
|
+
}
|
|
33
|
+
InitializeNumberFormat(this, locales, options, {
|
|
34
|
+
getInternalSlots,
|
|
35
|
+
localeData: NumberFormat.localeData,
|
|
36
|
+
availableLocales: NumberFormat.availableLocales,
|
|
37
|
+
getDefaultLocale: NumberFormat.getDefaultLocale,
|
|
38
|
+
currencyDigitsData,
|
|
39
|
+
numberingSystemNames
|
|
40
|
+
});
|
|
41
|
+
const internalSlots = getInternalSlots(this);
|
|
42
|
+
const dataLocale = internalSlots.dataLocale;
|
|
43
|
+
const dataLocaleData = NumberFormat.localeData[dataLocale];
|
|
44
|
+
invariant(dataLocaleData !== undefined, `Cannot load locale-dependent data for ${dataLocale}.`);
|
|
45
|
+
internalSlots.pl = createMemoizedPluralRules(dataLocale, {
|
|
46
|
+
minimumFractionDigits: internalSlots.minimumFractionDigits,
|
|
47
|
+
maximumFractionDigits: internalSlots.maximumFractionDigits,
|
|
48
|
+
minimumIntegerDigits: internalSlots.minimumIntegerDigits,
|
|
49
|
+
minimumSignificantDigits: internalSlots.minimumSignificantDigits,
|
|
50
|
+
maximumSignificantDigits: internalSlots.maximumSignificantDigits
|
|
51
|
+
});
|
|
52
|
+
return this;
|
|
52
53
|
};
|
|
53
54
|
function formatToParts(x) {
|
|
54
|
-
|
|
55
|
-
getInternalSlots: getInternalSlots,
|
|
56
|
-
});
|
|
55
|
+
return FormatNumericToParts(this, ToIntlMathematicalValue(x), { getInternalSlots });
|
|
57
56
|
}
|
|
58
57
|
function formatRange(start, end) {
|
|
59
|
-
|
|
60
|
-
getInternalSlots: getInternalSlots,
|
|
61
|
-
});
|
|
58
|
+
return FormatNumericRange(this, ToIntlMathematicalValue(start), ToIntlMathematicalValue(end), { getInternalSlots });
|
|
62
59
|
}
|
|
63
60
|
function formatRangeToParts(start, end) {
|
|
64
|
-
|
|
65
|
-
getInternalSlots: getInternalSlots,
|
|
66
|
-
});
|
|
61
|
+
return FormatNumericRangeToParts(this, ToIntlMathematicalValue(start), ToIntlMathematicalValue(end), { getInternalSlots });
|
|
67
62
|
}
|
|
68
63
|
try {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-number-format-functions
|
|
126
|
-
boundFormat = function (value) { return FormatNumeric(internalSlots, ToIntlMathematicalValue(value)); };
|
|
127
|
-
try {
|
|
128
|
-
// https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/format-function-name.js
|
|
129
|
-
Object.defineProperty(boundFormat, 'name', {
|
|
130
|
-
configurable: true,
|
|
131
|
-
enumerable: false,
|
|
132
|
-
writable: false,
|
|
133
|
-
value: '',
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
catch (_a) {
|
|
137
|
-
// In older browser (e.g Chrome 36 like polyfill-fastly.io)
|
|
138
|
-
// TypeError: Cannot redefine property: name
|
|
139
|
-
}
|
|
140
|
-
internalSlots.boundFormat = boundFormat;
|
|
141
|
-
}
|
|
142
|
-
return boundFormat;
|
|
143
|
-
},
|
|
64
|
+
Object.defineProperty(formatToParts, "name", {
|
|
65
|
+
value: "formatToParts",
|
|
66
|
+
enumerable: false,
|
|
67
|
+
writable: false,
|
|
68
|
+
configurable: true
|
|
69
|
+
});
|
|
70
|
+
} catch {}
|
|
71
|
+
defineProperty(NumberFormat.prototype, "formatToParts", { value: formatToParts });
|
|
72
|
+
defineProperty(NumberFormat.prototype, "formatRange", { value: formatRange });
|
|
73
|
+
defineProperty(NumberFormat.prototype, "formatRangeToParts", { value: formatRangeToParts });
|
|
74
|
+
defineProperty(NumberFormat.prototype, "resolvedOptions", { value: function resolvedOptions() {
|
|
75
|
+
if (typeof this !== "object" || !OrdinaryHasInstance(NumberFormat, this)) {
|
|
76
|
+
throw TypeError("Method Intl.NumberFormat.prototype.resolvedOptions called on incompatible receiver");
|
|
77
|
+
}
|
|
78
|
+
const internalSlots = getInternalSlots(this);
|
|
79
|
+
const ro = {};
|
|
80
|
+
for (const key of RESOLVED_OPTIONS_KEYS) {
|
|
81
|
+
const value = internalSlots[key];
|
|
82
|
+
if (value !== undefined) {
|
|
83
|
+
ro[key] = value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (internalSlots.roundingType === "morePrecision") {
|
|
87
|
+
ro.roundingPriority = "morePrecision";
|
|
88
|
+
} else if (internalSlots.roundingType === "lessPrecision") {
|
|
89
|
+
ro.roundingPriority = "lessPrecision";
|
|
90
|
+
} else {
|
|
91
|
+
ro.roundingPriority = "auto";
|
|
92
|
+
}
|
|
93
|
+
return ro;
|
|
94
|
+
} });
|
|
95
|
+
const formatDescriptor = {
|
|
96
|
+
enumerable: false,
|
|
97
|
+
configurable: true,
|
|
98
|
+
get() {
|
|
99
|
+
if (typeof this !== "object" || !OrdinaryHasInstance(NumberFormat, this)) {
|
|
100
|
+
throw TypeError("Intl.NumberFormat format property accessor called on incompatible receiver");
|
|
101
|
+
}
|
|
102
|
+
const internalSlots = getInternalSlots(this);
|
|
103
|
+
let boundFormat = internalSlots.boundFormat;
|
|
104
|
+
if (boundFormat === undefined) {
|
|
105
|
+
// https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-number-format-functions
|
|
106
|
+
boundFormat = (value) => FormatNumeric(internalSlots, ToIntlMathematicalValue(value));
|
|
107
|
+
try {
|
|
108
|
+
// https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/format-function-name.js
|
|
109
|
+
Object.defineProperty(boundFormat, "name", {
|
|
110
|
+
configurable: true,
|
|
111
|
+
enumerable: false,
|
|
112
|
+
writable: false,
|
|
113
|
+
value: ""
|
|
114
|
+
});
|
|
115
|
+
} catch {}
|
|
116
|
+
internalSlots.boundFormat = boundFormat;
|
|
117
|
+
}
|
|
118
|
+
return boundFormat;
|
|
119
|
+
}
|
|
144
120
|
};
|
|
145
121
|
try {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// In older browser (e.g Chrome 36 like polyfill-fastly.io)
|
|
156
|
-
// TypeError: Cannot redefine property: name
|
|
157
|
-
}
|
|
158
|
-
Object.defineProperty(NumberFormat.prototype, 'format', formatDescriptor);
|
|
122
|
+
// https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/name.js
|
|
123
|
+
Object.defineProperty(formatDescriptor.get, "name", {
|
|
124
|
+
configurable: true,
|
|
125
|
+
enumerable: false,
|
|
126
|
+
writable: false,
|
|
127
|
+
value: "get format"
|
|
128
|
+
});
|
|
129
|
+
} catch {}
|
|
130
|
+
Object.defineProperty(NumberFormat.prototype, "format", formatDescriptor);
|
|
159
131
|
// Static properties
|
|
160
|
-
defineProperty(NumberFormat,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
.minimize()
|
|
174
|
-
.toString();
|
|
175
|
-
NumberFormat.localeData[locale] = NumberFormat.localeData[minimizedLocale] =
|
|
176
|
-
d;
|
|
177
|
-
NumberFormat.availableLocales.add(minimizedLocale);
|
|
178
|
-
NumberFormat.availableLocales.add(locale);
|
|
179
|
-
if (!NumberFormat.__defaultLocale) {
|
|
180
|
-
NumberFormat.__defaultLocale = minimizedLocale;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
132
|
+
defineProperty(NumberFormat, "supportedLocalesOf", { value: function supportedLocalesOf(locales, options) {
|
|
133
|
+
return SupportedLocales(NumberFormat.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
134
|
+
} });
|
|
135
|
+
NumberFormat.__addLocaleData = function __addLocaleData(...data) {
|
|
136
|
+
for (const { data: d, locale } of data) {
|
|
137
|
+
const minimizedLocale = new Intl.Locale(locale).minimize().toString();
|
|
138
|
+
NumberFormat.localeData[locale] = NumberFormat.localeData[minimizedLocale] = d;
|
|
139
|
+
NumberFormat.availableLocales.add(minimizedLocale);
|
|
140
|
+
NumberFormat.availableLocales.add(locale);
|
|
141
|
+
if (!NumberFormat.__defaultLocale) {
|
|
142
|
+
NumberFormat.__defaultLocale = minimizedLocale;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
183
145
|
};
|
|
184
146
|
NumberFormat.__addUnitData = function __addUnitData(locale, unitsData) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
147
|
+
const { [locale]: existingData } = NumberFormat.localeData;
|
|
148
|
+
if (!existingData) {
|
|
149
|
+
throw new Error(`Locale data for "${locale}" has not been loaded in NumberFormat.
|
|
150
|
+
Please __addLocaleData before adding additional unit data`);
|
|
151
|
+
}
|
|
152
|
+
for (const unit in unitsData.simple) {
|
|
153
|
+
existingData.units.simple[unit] = unitsData.simple[unit];
|
|
154
|
+
}
|
|
155
|
+
for (const unit in unitsData.compound) {
|
|
156
|
+
existingData.units.compound[unit] = unitsData.compound[unit];
|
|
157
|
+
}
|
|
195
158
|
};
|
|
196
|
-
NumberFormat.__defaultLocale =
|
|
159
|
+
NumberFormat.__defaultLocale = "";
|
|
197
160
|
NumberFormat.localeData = {};
|
|
198
161
|
NumberFormat.availableLocales = new Set();
|
|
199
|
-
NumberFormat.getDefaultLocale =
|
|
200
|
-
|
|
162
|
+
NumberFormat.getDefaultLocale = () => {
|
|
163
|
+
return NumberFormat.__defaultLocale;
|
|
201
164
|
};
|
|
202
165
|
NumberFormat.polyfilled = true;
|
|
203
166
|
try {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
catch (_c) {
|
|
235
|
-
// Meta fix so we're test262-compliant, not important
|
|
236
|
-
}
|
|
167
|
+
// IE11 does not have Symbol
|
|
168
|
+
if (typeof Symbol !== "undefined") {
|
|
169
|
+
Object.defineProperty(NumberFormat.prototype, Symbol.toStringTag, {
|
|
170
|
+
configurable: true,
|
|
171
|
+
enumerable: false,
|
|
172
|
+
writable: false,
|
|
173
|
+
value: "Intl.NumberFormat"
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/length.js
|
|
177
|
+
Object.defineProperty(NumberFormat.prototype.constructor, "length", {
|
|
178
|
+
configurable: true,
|
|
179
|
+
enumerable: false,
|
|
180
|
+
writable: false,
|
|
181
|
+
value: 0
|
|
182
|
+
});
|
|
183
|
+
// https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/supportedLocalesOf/length.js
|
|
184
|
+
Object.defineProperty(NumberFormat.supportedLocalesOf, "length", {
|
|
185
|
+
configurable: true,
|
|
186
|
+
enumerable: false,
|
|
187
|
+
writable: false,
|
|
188
|
+
value: 1
|
|
189
|
+
});
|
|
190
|
+
Object.defineProperty(NumberFormat, "prototype", {
|
|
191
|
+
configurable: false,
|
|
192
|
+
enumerable: false,
|
|
193
|
+
writable: false,
|
|
194
|
+
value: NumberFormat.prototype
|
|
195
|
+
});
|
|
196
|
+
} catch {}
|