@formatjs/icu-messageformat-parser 2.0.14 → 2.0.15

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/lib/parser.js CHANGED
@@ -4,8 +4,8 @@ import { ErrorKind } from './error';
4
4
  import { SKELETON_TYPE, TYPE, } from './types';
5
5
  import { SPACE_SEPARATOR_REGEX } from './regex.generated';
6
6
  import { parseNumberSkeleton, parseNumberSkeletonFromString, parseDateTimeSkeleton, } from '@formatjs/icu-skeleton-parser';
7
- var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
8
- var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
7
+ var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
8
+ var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
9
9
  function createLocation(start, end) {
10
10
  return { start: start, end: end };
11
11
  }
@@ -252,7 +252,7 @@ var Parser = /** @class */ (function () {
252
252
  return {
253
253
  val: {
254
254
  type: TYPE.literal,
255
- value: "<" + tagName + "/>",
255
+ value: "<".concat(tagName, "/>"),
256
256
  location: createLocation(startPosition, this.clonePosition()),
257
257
  },
258
258
  err: null,
@@ -858,7 +858,7 @@ var Parser = /** @class */ (function () {
858
858
  }
859
859
  var code = codePointAt(this.message, offset);
860
860
  if (code === undefined) {
861
- throw Error("Offset " + offset + " is at invalid UTF-16 code unit boundary");
861
+ throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
862
862
  }
863
863
  return code;
864
864
  };
@@ -926,7 +926,7 @@ var Parser = /** @class */ (function () {
926
926
  */
927
927
  Parser.prototype.bumpTo = function (targetOffset) {
928
928
  if (this.offset() > targetOffset) {
929
- throw Error("targetOffset " + targetOffset + " must be greater than or equal to the current offset " + this.offset());
929
+ throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
930
930
  }
931
931
  targetOffset = Math.min(targetOffset, this.message.length);
932
932
  while (true) {
@@ -935,7 +935,7 @@ var Parser = /** @class */ (function () {
935
935
  break;
936
936
  }
937
937
  if (offset > targetOffset) {
938
- throw Error("targetOffset " + targetOffset + " is at invalid UTF-16 code unit boundary");
938
+ throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
939
939
  }
940
940
  this.bump();
941
941
  if (this.isEOF()) {
package/lib/printer.js CHANGED
@@ -30,7 +30,7 @@ export function doPrintAST(ast, isInPlural) {
30
30
  return printedNodes.join('');
31
31
  }
32
32
  function printTagElement(el) {
33
- return "<" + el.value + ">" + printAST(el.children) + "</" + el.value + ">";
33
+ return "<".concat(el.value, ">").concat(printAST(el.children), "</").concat(el.value, ">");
34
34
  }
35
35
  function printEscapedMessage(message) {
36
36
  return message.replace(/([{}](?:.*[{}])?)/su, "'$1'");
@@ -42,26 +42,26 @@ function printLiteralElement(_a, isInPlural) {
42
42
  }
43
43
  function printArgumentElement(_a) {
44
44
  var value = _a.value;
45
- return "{" + value + "}";
45
+ return "{".concat(value, "}");
46
46
  }
47
47
  function printSimpleFormatElement(el) {
48
- return "{" + el.value + ", " + TYPE[el.type] + (el.style ? ", " + printArgumentStyle(el.style) : '') + "}";
48
+ return "{".concat(el.value, ", ").concat(TYPE[el.type]).concat(el.style ? ", ".concat(printArgumentStyle(el.style)) : '', "}");
49
49
  }
50
50
  function printNumberSkeletonToken(token) {
51
51
  var stem = token.stem, options = token.options;
52
52
  return options.length === 0
53
53
  ? stem
54
- : "" + stem + options.map(function (o) { return "/" + o; }).join('');
54
+ : "".concat(stem).concat(options.map(function (o) { return "/".concat(o); }).join(''));
55
55
  }
56
56
  function printArgumentStyle(style) {
57
57
  if (typeof style === 'string') {
58
58
  return printEscapedMessage(style);
59
59
  }
60
60
  else if (style.type === SKELETON_TYPE.dateTime) {
61
- return "::" + printDateTimeSkeleton(style);
61
+ return "::".concat(printDateTimeSkeleton(style));
62
62
  }
63
63
  else {
64
- return "::" + style.tokens.map(printNumberSkeletonToken).join(' ');
64
+ return "::".concat(style.tokens.map(printNumberSkeletonToken).join(' '));
65
65
  }
66
66
  }
67
67
  export function printDateTimeSkeleton(style) {
@@ -72,10 +72,10 @@ function printSelectElement(el) {
72
72
  el.value,
73
73
  'select',
74
74
  Object.keys(el.options)
75
- .map(function (id) { return id + "{" + doPrintAST(el.options[id].value, false) + "}"; })
75
+ .map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, false), "}"); })
76
76
  .join(' '),
77
77
  ].join(',');
78
- return "{" + msg + "}";
78
+ return "{".concat(msg, "}");
79
79
  }
80
80
  function printPluralElement(el) {
81
81
  var type = el.pluralType === 'cardinal' ? 'plural' : 'selectordinal';
@@ -83,9 +83,9 @@ function printPluralElement(el) {
83
83
  el.value,
84
84
  type,
85
85
  __spreadArray([
86
- el.offset ? "offset:" + el.offset : ''
87
- ], Object.keys(el.options).map(function (id) { return id + "{" + doPrintAST(el.options[id].value, true) + "}"; }), true).filter(Boolean)
86
+ el.offset ? "offset:".concat(el.offset) : ''
87
+ ], Object.keys(el.options).map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, true), "}"); }), true).filter(Boolean)
88
88
  .join(' '),
89
89
  ].join(',');
90
- return "{" + msg + "}";
90
+ return "{".concat(msg, "}");
91
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/icu-messageformat-parser",
3
- "version": "2.0.14",
3
+ "version": "2.0.15",
4
4
  "main": "index.js",
5
5
  "module": "lib/index.js",
6
6
  "types": "index.d.ts",
@@ -11,8 +11,8 @@
11
11
  "directory": "packages/icu-messageformat-parser"
12
12
  },
13
13
  "dependencies": {
14
- "@formatjs/ecma402-abstract": "1.10.0",
15
- "@formatjs/icu-skeleton-parser": "1.3.1",
14
+ "@formatjs/ecma402-abstract": "1.11.0",
15
+ "@formatjs/icu-skeleton-parser": "1.3.2",
16
16
  "tslib": "^2.1.0"
17
17
  }
18
18
  }
package/parser.js CHANGED
@@ -7,8 +7,8 @@ var error_1 = require("./error");
7
7
  var types_1 = require("./types");
8
8
  var regex_generated_1 = require("./regex.generated");
9
9
  var icu_skeleton_parser_1 = require("@formatjs/icu-skeleton-parser");
10
- var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + regex_generated_1.SPACE_SEPARATOR_REGEX.source + "*");
11
- var SPACE_SEPARATOR_END_REGEX = new RegExp(regex_generated_1.SPACE_SEPARATOR_REGEX.source + "*$");
10
+ var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(regex_generated_1.SPACE_SEPARATOR_REGEX.source, "*"));
11
+ var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(regex_generated_1.SPACE_SEPARATOR_REGEX.source, "*$"));
12
12
  function createLocation(start, end) {
13
13
  return { start: start, end: end };
14
14
  }
@@ -255,7 +255,7 @@ var Parser = /** @class */ (function () {
255
255
  return {
256
256
  val: {
257
257
  type: types_1.TYPE.literal,
258
- value: "<" + tagName + "/>",
258
+ value: "<".concat(tagName, "/>"),
259
259
  location: createLocation(startPosition, this.clonePosition()),
260
260
  },
261
261
  err: null,
@@ -861,7 +861,7 @@ var Parser = /** @class */ (function () {
861
861
  }
862
862
  var code = codePointAt(this.message, offset);
863
863
  if (code === undefined) {
864
- throw Error("Offset " + offset + " is at invalid UTF-16 code unit boundary");
864
+ throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
865
865
  }
866
866
  return code;
867
867
  };
@@ -929,7 +929,7 @@ var Parser = /** @class */ (function () {
929
929
  */
930
930
  Parser.prototype.bumpTo = function (targetOffset) {
931
931
  if (this.offset() > targetOffset) {
932
- throw Error("targetOffset " + targetOffset + " must be greater than or equal to the current offset " + this.offset());
932
+ throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
933
933
  }
934
934
  targetOffset = Math.min(targetOffset, this.message.length);
935
935
  while (true) {
@@ -938,7 +938,7 @@ var Parser = /** @class */ (function () {
938
938
  break;
939
939
  }
940
940
  if (offset > targetOffset) {
941
- throw Error("targetOffset " + targetOffset + " is at invalid UTF-16 code unit boundary");
941
+ throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
942
942
  }
943
943
  this.bump();
944
944
  if (this.isEOF()) {
package/printer.js CHANGED
@@ -35,7 +35,7 @@ function doPrintAST(ast, isInPlural) {
35
35
  }
36
36
  exports.doPrintAST = doPrintAST;
37
37
  function printTagElement(el) {
38
- return "<" + el.value + ">" + printAST(el.children) + "</" + el.value + ">";
38
+ return "<".concat(el.value, ">").concat(printAST(el.children), "</").concat(el.value, ">");
39
39
  }
40
40
  function printEscapedMessage(message) {
41
41
  return message.replace(/([{}](?:.*[{}])?)/su, "'$1'");
@@ -47,26 +47,26 @@ function printLiteralElement(_a, isInPlural) {
47
47
  }
48
48
  function printArgumentElement(_a) {
49
49
  var value = _a.value;
50
- return "{" + value + "}";
50
+ return "{".concat(value, "}");
51
51
  }
52
52
  function printSimpleFormatElement(el) {
53
- return "{" + el.value + ", " + types_1.TYPE[el.type] + (el.style ? ", " + printArgumentStyle(el.style) : '') + "}";
53
+ return "{".concat(el.value, ", ").concat(types_1.TYPE[el.type]).concat(el.style ? ", ".concat(printArgumentStyle(el.style)) : '', "}");
54
54
  }
55
55
  function printNumberSkeletonToken(token) {
56
56
  var stem = token.stem, options = token.options;
57
57
  return options.length === 0
58
58
  ? stem
59
- : "" + stem + options.map(function (o) { return "/" + o; }).join('');
59
+ : "".concat(stem).concat(options.map(function (o) { return "/".concat(o); }).join(''));
60
60
  }
61
61
  function printArgumentStyle(style) {
62
62
  if (typeof style === 'string') {
63
63
  return printEscapedMessage(style);
64
64
  }
65
65
  else if (style.type === types_1.SKELETON_TYPE.dateTime) {
66
- return "::" + printDateTimeSkeleton(style);
66
+ return "::".concat(printDateTimeSkeleton(style));
67
67
  }
68
68
  else {
69
- return "::" + style.tokens.map(printNumberSkeletonToken).join(' ');
69
+ return "::".concat(style.tokens.map(printNumberSkeletonToken).join(' '));
70
70
  }
71
71
  }
72
72
  function printDateTimeSkeleton(style) {
@@ -78,10 +78,10 @@ function printSelectElement(el) {
78
78
  el.value,
79
79
  'select',
80
80
  Object.keys(el.options)
81
- .map(function (id) { return id + "{" + doPrintAST(el.options[id].value, false) + "}"; })
81
+ .map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, false), "}"); })
82
82
  .join(' '),
83
83
  ].join(',');
84
- return "{" + msg + "}";
84
+ return "{".concat(msg, "}");
85
85
  }
86
86
  function printPluralElement(el) {
87
87
  var type = el.pluralType === 'cardinal' ? 'plural' : 'selectordinal';
@@ -89,9 +89,9 @@ function printPluralElement(el) {
89
89
  el.value,
90
90
  type,
91
91
  (0, tslib_1.__spreadArray)([
92
- el.offset ? "offset:" + el.offset : ''
93
- ], Object.keys(el.options).map(function (id) { return id + "{" + doPrintAST(el.options[id].value, true) + "}"; }), true).filter(Boolean)
92
+ el.offset ? "offset:".concat(el.offset) : ''
93
+ ], Object.keys(el.options).map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, true), "}"); }), true).filter(Boolean)
94
94
  .join(' '),
95
95
  ].join(',');
96
- return "{" + msg + "}";
96
+ return "{".concat(msg, "}");
97
97
  }