intl-messageformat 9.9.2 → 9.9.3

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.
@@ -242,11 +242,16 @@ function icuUnitToEcma(unit) {
242
242
  return unit.replace(/^(.*?)-/, "");
243
243
  }
244
244
  var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
245
- var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
245
+ var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g;
246
246
  var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
247
247
  var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
248
248
  function parseSignificantPrecision(str) {
249
249
  var result = {};
250
+ if (str[str.length - 1] === "r") {
251
+ result.roundingPriority = "morePrecision";
252
+ } else if (str[str.length - 1] === "s") {
253
+ result.roundingPriority = "lessPrecision";
254
+ }
250
255
  str.replace(SIGNIFICANT_PRECISION_REGEX, function(_, g1, g2) {
251
256
  if (typeof g2 !== "string") {
252
257
  result.minimumSignificantDigits = g1.length;
@@ -381,13 +386,13 @@ function parseNumberSkeleton(tokens) {
381
386
  result.compactDisplay = "long";
382
387
  continue;
383
388
  case "scientific":
384
- result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt) {
385
- return __assign(__assign({}, all), parseNotationOptions(opt));
389
+ result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt2) {
390
+ return __assign(__assign({}, all), parseNotationOptions(opt2));
386
391
  }, {}));
387
392
  continue;
388
393
  case "engineering":
389
- result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt) {
390
- return __assign(__assign({}, all), parseNotationOptions(opt));
394
+ result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt2) {
395
+ return __assign(__assign({}, all), parseNotationOptions(opt2));
391
396
  }, {}));
392
397
  continue;
393
398
  case "notation-simple":
@@ -449,8 +454,11 @@ function parseNumberSkeleton(tokens) {
449
454
  }
450
455
  return "";
451
456
  });
452
- if (token.options.length) {
453
- result = __assign(__assign({}, result), parseSignificantPrecision(token.options[0]));
457
+ var opt = token.options[0];
458
+ if (opt === "w") {
459
+ result = __assign(__assign({}, result), { trailingZeroDisplay: "stripIfInteger" });
460
+ } else if (opt) {
461
+ result = __assign(__assign({}, result), parseSignificantPrecision(opt));
454
462
  }
455
463
  continue;
456
464
  }
@@ -311,11 +311,16 @@ var IntlMessageFormat = (function() {
311
311
  return unit.replace(/^(.*?)-/, "");
312
312
  }
313
313
  var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
314
- var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
314
+ var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g;
315
315
  var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
316
316
  var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
317
317
  function parseSignificantPrecision(str) {
318
318
  var result = {};
319
+ if (str[str.length - 1] === "r") {
320
+ result.roundingPriority = "morePrecision";
321
+ } else if (str[str.length - 1] === "s") {
322
+ result.roundingPriority = "lessPrecision";
323
+ }
319
324
  str.replace(SIGNIFICANT_PRECISION_REGEX, function(_, g1, g2) {
320
325
  if (typeof g2 !== "string") {
321
326
  result.minimumSignificantDigits = g1.length;
@@ -450,13 +455,13 @@ var IntlMessageFormat = (function() {
450
455
  result.compactDisplay = "long";
451
456
  continue;
452
457
  case "scientific":
453
- result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt) {
454
- return __assign(__assign({}, all), parseNotationOptions(opt));
458
+ result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt2) {
459
+ return __assign(__assign({}, all), parseNotationOptions(opt2));
455
460
  }, {}));
456
461
  continue;
457
462
  case "engineering":
458
- result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt) {
459
- return __assign(__assign({}, all), parseNotationOptions(opt));
463
+ result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt2) {
464
+ return __assign(__assign({}, all), parseNotationOptions(opt2));
460
465
  }, {}));
461
466
  continue;
462
467
  case "notation-simple":
@@ -518,8 +523,11 @@ var IntlMessageFormat = (function() {
518
523
  }
519
524
  return "";
520
525
  });
521
- if (token.options.length) {
522
- result = __assign(__assign({}, result), parseSignificantPrecision(token.options[0]));
526
+ var opt = token.options[0];
527
+ if (opt === "w") {
528
+ result = __assign(__assign({}, result), { trailingZeroDisplay: "stripIfInteger" });
529
+ } else if (opt) {
530
+ result = __assign(__assign({}, result), parseSignificantPrecision(opt));
523
531
  }
524
532
  continue;
525
533
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-messageformat",
3
- "version": "9.9.2",
3
+ "version": "9.9.3",
4
4
  "description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -32,7 +32,7 @@
32
32
  "types": "index.d.ts",
33
33
  "dependencies": {
34
34
  "@formatjs/fast-memoize": "1.2.0",
35
- "@formatjs/icu-messageformat-parser": "2.0.12",
35
+ "@formatjs/icu-messageformat-parser": "2.0.13",
36
36
  "tslib": "^2.1.0"
37
37
  },
38
38
  "sideEffects": false,