@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/polyfill.js CHANGED
@@ -1,12 +1,10 @@
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';
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
- defineProperty(Intl, 'NumberFormat', { value: NumberFormat });
7
- defineProperty(Number.prototype, 'toLocaleString', {
8
- value: function toLocaleString(locales, options) {
9
- return _toLocaleString(this, locales, options);
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
  }
@@ -1,78 +1,68 @@
1
- import { match } from '@formatjs/intl-localematcher';
2
- import { supportedLocales } from './supported-locales.generated.js';
1
+ import { match } from "@formatjs/intl-localematcher";
2
+ import { supportedLocales } from "./supported-locales.generated.js";
3
3
  /**
4
- * Check if this is old Node that only supports en
5
- * @returns
6
- */
4
+ * Check if this is old Node that only supports en
5
+ * @returns
6
+ */
7
7
  function onlySupportsEn() {
8
- return (!Intl.NumberFormat.polyfilled &&
9
- !Intl.NumberFormat.supportedLocalesOf(['es']).length);
8
+ return !Intl.NumberFormat.polyfilled && !Intl.NumberFormat.supportedLocalesOf(["es"]).length;
10
9
  }
11
10
  /**
12
- * Check if Intl.NumberFormat is ES2020 compatible.
13
- * Caveat: we are not checking `toLocaleString`.
14
- *
15
- * @public
16
- * @param unit unit to check
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
- try {
20
- var s = new Intl.NumberFormat('en', {
21
- style: 'unit',
22
- unit: 'bit',
23
- unitDisplay: 'long',
24
- notation: 'scientific',
25
- }).format(10000);
26
- // Check for a plurality bug in environment that uses the older versions of ICU:
27
- // https://unicode-org.atlassian.net/browse/ICU-13836
28
- if (s !== '1E4 bits') {
29
- return false;
30
- }
31
- }
32
- catch (_a) {
33
- return false;
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
- * Check if Intl.NumberFormat is ES2020 compatible.
39
- * Caveat: we are not checking `toLocaleString`.
40
- *
41
- * @public
42
- * @param unit unit to check
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
- try {
46
- var s = new Intl.NumberFormat('en', {
47
- notation: 'compact',
48
- minimumSignificantDigits: 3,
49
- maximumSignificantDigits: 3,
50
- minimumFractionDigits: 2,
51
- maximumFractionDigits: 2,
52
- // @ts-ignore TS types are old
53
- roundingPriority: 'morePrecision',
54
- }).format(1e8);
55
- return s === '100.00M';
56
- }
57
- catch (_a) {
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
- if (!locale) {
63
- return true;
64
- }
65
- var locales = Array.isArray(locale) ? locale : [locale];
66
- return Intl.NumberFormat.supportedLocalesOf(locales).length === locales.length;
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
- if (locale === void 0) { locale = 'en'; }
70
- if (typeof Intl === 'undefined' ||
71
- !('NumberFormat' in Intl) ||
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 './types.js';
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
- * https://tc39.es/ecma402/#sec-intl-numberformat-constructor
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, } 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
- var RESOLVED_OPTIONS_KEYS = [
6
- 'locale',
7
- 'numberingSystem',
8
- 'style',
9
- 'currency',
10
- 'currencyDisplay',
11
- 'currencySign',
12
- 'unit',
13
- 'unitDisplay',
14
- 'minimumIntegerDigits',
15
- 'minimumFractionDigits',
16
- 'maximumFractionDigits',
17
- 'minimumSignificantDigits',
18
- 'maximumSignificantDigits',
19
- 'useGrouping',
20
- 'notation',
21
- 'compactDisplay',
22
- 'signDisplay',
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
- * https://tc39.es/ecma402/#sec-intl-numberformat-constructor
26
- */
27
- export var NumberFormat = function (locales, options) {
28
- // Cannot use `new.target` bc of IE11 & TS transpiles it to something else
29
- if (!this || !OrdinaryHasInstance(NumberFormat, this)) {
30
- return new NumberFormat(locales, options);
31
- }
32
- InitializeNumberFormat(this, locales, options, {
33
- getInternalSlots: getInternalSlots,
34
- localeData: NumberFormat.localeData,
35
- availableLocales: NumberFormat.availableLocales,
36
- getDefaultLocale: NumberFormat.getDefaultLocale,
37
- currencyDigitsData: currencyDigitsData,
38
- numberingSystemNames: numberingSystemNames,
39
- });
40
- var internalSlots = getInternalSlots(this);
41
- var dataLocale = internalSlots.dataLocale;
42
- var dataLocaleData = NumberFormat.localeData[dataLocale];
43
- invariant(dataLocaleData !== undefined, "Cannot load locale-dependent data for ".concat(dataLocale, "."));
44
- internalSlots.pl = createMemoizedPluralRules(dataLocale, {
45
- minimumFractionDigits: internalSlots.minimumFractionDigits,
46
- maximumFractionDigits: internalSlots.maximumFractionDigits,
47
- minimumIntegerDigits: internalSlots.minimumIntegerDigits,
48
- minimumSignificantDigits: internalSlots.minimumSignificantDigits,
49
- maximumSignificantDigits: internalSlots.maximumSignificantDigits,
50
- });
51
- return this;
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
- return FormatNumericToParts(this, ToIntlMathematicalValue(x), {
55
- getInternalSlots: getInternalSlots,
56
- });
55
+ return FormatNumericToParts(this, ToIntlMathematicalValue(x), { getInternalSlots });
57
56
  }
58
57
  function formatRange(start, end) {
59
- return FormatNumericRange(this, ToIntlMathematicalValue(start), ToIntlMathematicalValue(end), {
60
- getInternalSlots: getInternalSlots,
61
- });
58
+ return FormatNumericRange(this, ToIntlMathematicalValue(start), ToIntlMathematicalValue(end), { getInternalSlots });
62
59
  }
63
60
  function formatRangeToParts(start, end) {
64
- return FormatNumericRangeToParts(this, ToIntlMathematicalValue(start), ToIntlMathematicalValue(end), {
65
- getInternalSlots: getInternalSlots,
66
- });
61
+ return FormatNumericRangeToParts(this, ToIntlMathematicalValue(start), ToIntlMathematicalValue(end), { getInternalSlots });
67
62
  }
68
63
  try {
69
- Object.defineProperty(formatToParts, 'name', {
70
- value: 'formatToParts',
71
- enumerable: false,
72
- writable: false,
73
- configurable: true,
74
- });
75
- }
76
- catch (_a) {
77
- // In older browser (e.g Chrome 36 like polyfill-fastly.io)
78
- // TypeError: Cannot redefine property: name
79
- }
80
- defineProperty(NumberFormat.prototype, 'formatToParts', {
81
- value: formatToParts,
82
- });
83
- defineProperty(NumberFormat.prototype, 'formatRange', {
84
- value: formatRange,
85
- });
86
- defineProperty(NumberFormat.prototype, 'formatRangeToParts', {
87
- value: formatRangeToParts,
88
- });
89
- defineProperty(NumberFormat.prototype, 'resolvedOptions', {
90
- value: function resolvedOptions() {
91
- if (typeof this !== 'object' || !OrdinaryHasInstance(NumberFormat, this)) {
92
- throw TypeError('Method Intl.NumberFormat.prototype.resolvedOptions called on incompatible receiver');
93
- }
94
- var internalSlots = getInternalSlots(this);
95
- var ro = {};
96
- for (var _i = 0, RESOLVED_OPTIONS_KEYS_1 = RESOLVED_OPTIONS_KEYS; _i < RESOLVED_OPTIONS_KEYS_1.length; _i++) {
97
- var key = RESOLVED_OPTIONS_KEYS_1[_i];
98
- var value = internalSlots[key];
99
- if (value !== undefined) {
100
- ro[key] = value;
101
- }
102
- }
103
- if (internalSlots.roundingType === 'morePrecision') {
104
- ro.roundingPriority = 'morePrecision';
105
- }
106
- else if (internalSlots.roundingType === 'lessPrecision') {
107
- ro.roundingPriority = 'lessPrecision';
108
- }
109
- else {
110
- ro.roundingPriority = 'auto';
111
- }
112
- return ro;
113
- },
114
- });
115
- var formatDescriptor = {
116
- enumerable: false,
117
- configurable: true,
118
- get: function () {
119
- if (typeof this !== 'object' || !OrdinaryHasInstance(NumberFormat, this)) {
120
- throw TypeError('Intl.NumberFormat format property accessor called on incompatible receiver');
121
- }
122
- var internalSlots = getInternalSlots(this);
123
- var boundFormat = internalSlots.boundFormat;
124
- if (boundFormat === undefined) {
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
- // https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/name.js
147
- Object.defineProperty(formatDescriptor.get, 'name', {
148
- configurable: true,
149
- enumerable: false,
150
- writable: false,
151
- value: 'get format',
152
- });
153
- }
154
- catch (_b) {
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, 'supportedLocalesOf', {
161
- value: function supportedLocalesOf(locales, options) {
162
- return SupportedLocales(NumberFormat.availableLocales, CanonicalizeLocaleList(locales), options);
163
- },
164
- });
165
- NumberFormat.__addLocaleData = function __addLocaleData() {
166
- var data = [];
167
- for (var _i = 0; _i < arguments.length; _i++) {
168
- data[_i] = arguments[_i];
169
- }
170
- for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
171
- var _b = data_1[_a], d = _b.data, locale = _b.locale;
172
- var minimizedLocale = new Intl.Locale(locale)
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
- var _a = NumberFormat.localeData, _b = locale, existingData = _a[_b];
186
- if (!existingData) {
187
- throw new Error("Locale data for \"".concat(locale, "\" has not been loaded in NumberFormat. \nPlease __addLocaleData before adding additional unit data"));
188
- }
189
- for (var unit in unitsData.simple) {
190
- existingData.units.simple[unit] = unitsData.simple[unit];
191
- }
192
- for (var unit in unitsData.compound) {
193
- existingData.units.compound[unit] = unitsData.compound[unit];
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 = function () {
200
- return NumberFormat.__defaultLocale;
162
+ NumberFormat.getDefaultLocale = () => {
163
+ return NumberFormat.__defaultLocale;
201
164
  };
202
165
  NumberFormat.polyfilled = true;
203
166
  try {
204
- // IE11 does not have Symbol
205
- if (typeof Symbol !== 'undefined') {
206
- Object.defineProperty(NumberFormat.prototype, Symbol.toStringTag, {
207
- configurable: true,
208
- enumerable: false,
209
- writable: false,
210
- value: 'Intl.NumberFormat',
211
- });
212
- }
213
- // https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/length.js
214
- Object.defineProperty(NumberFormat.prototype.constructor, 'length', {
215
- configurable: true,
216
- enumerable: false,
217
- writable: false,
218
- value: 0,
219
- });
220
- // https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/supportedLocalesOf/length.js
221
- Object.defineProperty(NumberFormat.supportedLocalesOf, 'length', {
222
- configurable: true,
223
- enumerable: false,
224
- writable: false,
225
- value: 1,
226
- });
227
- Object.defineProperty(NumberFormat, 'prototype', {
228
- configurable: false,
229
- enumerable: false,
230
- writable: false,
231
- value: NumberFormat.prototype,
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 {}