@formatjs/intl-numberformat 8.14.2 → 8.14.4

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/polyfill.iife.js +49 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-numberformat",
3
- "version": "8.14.2",
3
+ "version": "8.14.4",
4
4
  "description": "Ponyfill for ES2020 Intl.NumberFormat",
5
5
  "keywords": [
6
6
  "polyfill",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "tslib": "2",
26
- "@formatjs/ecma402-abstract": "2.2.2",
26
+ "@formatjs/ecma402-abstract": "2.2.3",
27
27
  "@formatjs/intl-localematcher": "0.5.7"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@formatjs/intl-getcanonicallocales": "2.5.2",
31
- "@formatjs/intl-locale": "4.2.2",
32
- "@formatjs/intl-pluralrules": "5.3.2"
31
+ "@formatjs/intl-pluralrules": "5.3.4",
32
+ "@formatjs/intl-locale": "4.2.4"
33
33
  },
34
34
  "bugs": {
35
35
  "url": "https://github.com/formatjs/formatjs/issues"
package/polyfill.iife.js CHANGED
@@ -246,7 +246,54 @@
246
246
  }
247
247
 
248
248
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/CollapseNumberRange.js
249
- function CollapseNumberRange(result) {
249
+ var PART_TYPES_TO_COLLAPSE = /* @__PURE__ */ new Set([
250
+ "unit",
251
+ "exponentMinusSign",
252
+ "minusSign",
253
+ "plusSign",
254
+ "percentSign",
255
+ "exponentSeparator",
256
+ "percent",
257
+ "percentSign",
258
+ "currency",
259
+ "literal"
260
+ ]);
261
+ function CollapseNumberRange(numberFormat, result, _a) {
262
+ var getInternalSlots2 = _a.getInternalSlots;
263
+ var internalSlots = getInternalSlots2(numberFormat);
264
+ var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
265
+ var rangeSignRegex = new RegExp("s?[".concat(symbols.rangeSign, "]s?"));
266
+ var rangeSignIndex = result.findIndex(function(r) {
267
+ return r.type === "literal" && rangeSignRegex.test(r.value);
268
+ });
269
+ var prefixSignParts = [];
270
+ for (var i = rangeSignIndex - 1; i >= 0; i--) {
271
+ if (!PART_TYPES_TO_COLLAPSE.has(result[i].type)) {
272
+ break;
273
+ }
274
+ prefixSignParts.unshift(result[i]);
275
+ }
276
+ if (Array.from(prefixSignParts.map(function(p) {
277
+ return p.value;
278
+ }).join("")).length > 1) {
279
+ var newResult = Array.from(result);
280
+ newResult.splice(rangeSignIndex - prefixSignParts.length, prefixSignParts.length);
281
+ return newResult;
282
+ }
283
+ var suffixSignParts = [];
284
+ for (var i = rangeSignIndex + 1; i < result.length; i++) {
285
+ if (!PART_TYPES_TO_COLLAPSE.has(result[i].type)) {
286
+ break;
287
+ }
288
+ suffixSignParts.push(result[i]);
289
+ }
290
+ if (Array.from(suffixSignParts.map(function(p) {
291
+ return p.value;
292
+ }).join("")).length > 1) {
293
+ var newResult = Array.from(result);
294
+ newResult.splice(rangeSignIndex + 1, suffixSignParts.length);
295
+ return newResult;
296
+ }
250
297
  return result;
251
298
  }
252
299
 
@@ -1836,7 +1883,7 @@
1836
1883
  r.source = "endRange";
1837
1884
  }
1838
1885
  result = result.concat(yResult);
1839
- return CollapseNumberRange(result);
1886
+ return CollapseNumberRange(numberFormat, result, { getInternalSlots: getInternalSlots2 });
1840
1887
  }
1841
1888
 
1842
1889
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/FormatNumericRange.js