@litert/typeguard 1.0.0 → 1.2.0

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 (74) hide show
  1. package/CHANGES.md +15 -0
  2. package/lib/BuiltInTypeCompiler.d.ts +4 -4
  3. package/lib/BuiltInTypeCompiler.d.ts.map +1 -1
  4. package/lib/BuiltInTypeCompiler.js +167 -166
  5. package/lib/BuiltInTypeCompiler.js.map +1 -1
  6. package/lib/BuiltInTypes.d.ts +1 -1
  7. package/lib/BuiltInTypes.js +37 -36
  8. package/lib/BuiltInTypes.js.map +1 -1
  9. package/lib/Common.d.ts +13 -9
  10. package/lib/Common.d.ts.map +1 -1
  11. package/lib/Common.js +1 -1
  12. package/lib/Compiler.d.ts +2 -2
  13. package/lib/Compiler.d.ts.map +1 -1
  14. package/lib/Compiler.js +77 -72
  15. package/lib/Compiler.js.map +1 -1
  16. package/lib/Context.d.ts +2 -2
  17. package/lib/Context.js +3 -2
  18. package/lib/Context.js.map +1 -1
  19. package/lib/FilterCompiler.d.ts +5 -5
  20. package/lib/FilterCompiler.d.ts.map +1 -1
  21. package/lib/FilterCompiler.js +25 -24
  22. package/lib/FilterCompiler.js.map +1 -1
  23. package/lib/InlineCompiler.d.ts +12 -5
  24. package/lib/InlineCompiler.d.ts.map +1 -1
  25. package/lib/InlineCompiler.js +14 -5
  26. package/lib/InlineCompiler.js.map +1 -1
  27. package/lib/Internal.d.ts +2 -1
  28. package/lib/Internal.d.ts.map +1 -1
  29. package/lib/Internal.js +12 -10
  30. package/lib/Internal.js.map +1 -1
  31. package/lib/Modifiers.d.ts +1 -1
  32. package/lib/Modifiers.js +2 -1
  33. package/lib/Modifiers.js.map +1 -1
  34. package/lib/index.d.ts +5 -5
  35. package/lib/index.js +19 -7
  36. package/lib/index.js.map +1 -1
  37. package/lib/langs/JavaScript.d.ts +2 -2
  38. package/lib/langs/JavaScript.d.ts.map +1 -1
  39. package/lib/langs/JavaScript.js +30 -23
  40. package/lib/langs/JavaScript.js.map +1 -1
  41. package/package.json +18 -13
  42. package/src/{samples → examples}/quick-start.ts +22 -12
  43. package/src/lib/BuiltInTypeCompiler.ts +171 -171
  44. package/src/lib/BuiltInTypes.ts +36 -36
  45. package/src/lib/Common.ts +15 -10
  46. package/src/lib/Compiler.ts +213 -208
  47. package/src/lib/Context.ts +3 -3
  48. package/src/lib/FilterCompiler.ts +84 -84
  49. package/src/lib/InlineCompiler.ts +35 -14
  50. package/src/lib/Internal.ts +12 -10
  51. package/src/lib/Modifiers.ts +2 -2
  52. package/src/lib/index.ts +5 -5
  53. package/src/lib/langs/JavaScript.ts +34 -24
  54. package/src/test/00-all.ts +11 -9
  55. package/src/test/01-elemental-types.ts +1111 -1110
  56. package/src/test/02-array-and-list.ts +75 -75
  57. package/src/test/03-tuple.ts +87 -87
  58. package/src/test/04-from-string.ts +849 -848
  59. package/src/test/05-string-asserts.ts +422 -422
  60. package/src/test/06-structure.ts +107 -107
  61. package/src/test/07-modifiers.ts +151 -42
  62. package/src/test/08-map-and-dict.ts +46 -46
  63. package/src/test/09-exceptions.ts +67 -0
  64. package/src/test/abstracts.ts +52 -43
  65. package/dist/typeguard.amd.d.ts +0 -588
  66. package/dist/typeguard.amd.d.ts.map +0 -1
  67. package/dist/typeguard.amd.js +0 -2063
  68. package/dist/typeguard.amd.js.map +0 -1
  69. package/dist/typeguard.system.d.ts +0 -588
  70. package/dist/typeguard.system.d.ts.map +0 -1
  71. package/dist/typeguard.system.js +0 -2179
  72. package/dist/typeguard.system.js.map +0 -1
  73. package/tsconfig-amd.json +0 -72
  74. package/tsconfig-systemjs.json +0 -72
package/CHANGES.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changes Logs
2
2
 
3
+ ## v1.2.0
4
+
5
+ - Added API `IInlineCompiler.addPredefinedType`.
6
+ - Deprecated type `TypeChecker` with new type `ITypeChecker`.
7
+
8
+ ## v1.1.0
9
+
10
+ - Allows characters `.:-` in predefined type names.
11
+ - Removed the distribution of AMD/SystemJS modules.
12
+ - Improved the output of `$.or` and `$.and`.
13
+
14
+ ## v1.0.1
15
+
16
+ - Fixed lack of positive expression when `any` or `true` is used.
17
+
3
18
  ## v1.0.0
4
19
 
5
20
  - A full refactor, with a better and simple code generation.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2019 Angus.Fenying <fenying@litert.org>
2
+ * Copyright 2022 Angus Fenying <fenying@litert.org>
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -13,10 +13,10 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import * as C from "./Common";
17
- import * as I from "./Internal";
16
+ import * as C from './Common';
17
+ import * as I from './Internal';
18
18
  export declare class BuiltInTypeCompiler implements I.IBuiltInTypeCompiler {
19
- private _lang;
19
+ private readonly _lang;
20
20
  constructor(_lang: C.ILanguageBuilder);
21
21
  isStringType(type: string): boolean;
22
22
  isConstructed(type: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"BuiltInTypeCompiler.d.ts","sourceRoot":"","sources":["../src/lib/BuiltInTypeCompiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAmOhC,qBAAa,mBACb,YAAW,CAAC,CAAC,oBAAoB;IAGzB,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,CAAC,CAAC,gBAAgB;IAG9B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKnC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKpC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKlC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKpC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;IAiQrE,OAAO,CAAC,UAAU;IAiFlB,OAAO,CAAC,QAAQ;IAgEhB,OAAO,CAAC,SAAS;IA+FjB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,UAAU;IAuGlB,OAAO,CAAC,SAAS;CAuHpB"}
1
+ {"version":3,"file":"BuiltInTypeCompiler.d.ts","sourceRoot":"","sources":["../src/lib/BuiltInTypeCompiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAmOhC,qBAAa,mBACb,YAAW,CAAC,CAAC,oBAAoB;IAGzB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,CAAC,CAAC,gBAAgB;IAGvC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKnC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKpC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKlC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKpC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;IAiQrE,OAAO,CAAC,UAAU;IAiFlB,OAAO,CAAC,QAAQ;IAgEhB,OAAO,CAAC,SAAS;IA+FjB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,UAAU;IAuGlB,OAAO,CAAC,SAAS;CAuHpB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright 2019 Angus.Fenying <fenying@litert.org>
3
+ * Copyright 2022 Angus Fenying <fenying@litert.org>
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -15,218 +15,219 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.BuiltInTypeCompiler = void 0;
18
19
  const I = require("./Internal");
19
20
  const B = require("./BuiltInTypes");
20
21
  const BUILT_IN_TYPES = {
21
22
  [B.STRING]: {
22
- "kind": "string",
23
- "string": true,
24
- "constructed": false,
25
- "elemental": true
23
+ 'kind': 'string',
24
+ 'string': true,
25
+ 'constructed': false,
26
+ 'elemental': true
26
27
  },
27
28
  [B.ASCII_STRING]: {
28
- "kind": "string",
29
- "string": true,
30
- "constructed": false,
31
- "elemental": true
29
+ 'kind': 'string',
30
+ 'string': true,
31
+ 'constructed': false,
32
+ 'elemental': true
32
33
  },
33
34
  [B.HEX_STRING]: {
34
- "kind": "string",
35
- "string": true,
36
- "constructed": false,
37
- "elemental": true
35
+ 'kind': 'string',
36
+ 'string': true,
37
+ 'constructed': false,
38
+ 'elemental': true
38
39
  },
39
40
  [B.LATIN_STRING]: {
40
- "kind": "string",
41
- "string": true,
42
- "constructed": false,
43
- "elemental": true
41
+ 'kind': 'string',
42
+ 'string': true,
43
+ 'constructed': false,
44
+ 'elemental': true
44
45
  },
45
46
  [B.NUMERIC]: {
46
- "kind": "number",
47
- "string": true,
48
- "constructed": false,
49
- "elemental": true
47
+ 'kind': 'number',
48
+ 'string': true,
49
+ 'constructed': false,
50
+ 'elemental': true
50
51
  },
51
52
  [B.SAFE_INT]: {
52
- "kind": "number",
53
- "string": false,
54
- "constructed": false,
55
- "elemental": true
53
+ 'kind': 'number',
54
+ 'string': false,
55
+ 'constructed': false,
56
+ 'elemental': true
56
57
  },
57
58
  [B.INT]: {
58
- "kind": "number",
59
- "string": false,
60
- "constructed": false,
61
- "elemental": true
59
+ 'kind': 'number',
60
+ 'string': false,
61
+ 'constructed': false,
62
+ 'elemental': true
62
63
  },
63
64
  [B.INT8]: {
64
- "kind": "number",
65
- "string": false,
66
- "constructed": false,
67
- "elemental": true
65
+ 'kind': 'number',
66
+ 'string': false,
67
+ 'constructed': false,
68
+ 'elemental': true
68
69
  },
69
70
  [B.INT16]: {
70
- "kind": "number",
71
- "string": false,
72
- "constructed": false,
73
- "elemental": true
71
+ 'kind': 'number',
72
+ 'string': false,
73
+ 'constructed': false,
74
+ 'elemental': true
74
75
  },
75
76
  [B.INT32]: {
76
- "kind": "number",
77
- "string": false,
78
- "constructed": false,
79
- "elemental": true
77
+ 'kind': 'number',
78
+ 'string': false,
79
+ 'constructed': false,
80
+ 'elemental': true
80
81
  },
81
82
  [B.INT64]: {
82
- "kind": "number",
83
- "string": false,
84
- "constructed": false,
85
- "elemental": true
83
+ 'kind': 'number',
84
+ 'string': false,
85
+ 'constructed': false,
86
+ 'elemental': true
86
87
  },
87
88
  [B.SAFE_UINT]: {
88
- "kind": "number",
89
- "string": false,
90
- "constructed": false,
91
- "elemental": true
89
+ 'kind': 'number',
90
+ 'string': false,
91
+ 'constructed': false,
92
+ 'elemental': true
92
93
  },
93
94
  [B.UINT]: {
94
- "kind": "number",
95
- "string": false,
96
- "constructed": false,
97
- "elemental": true
95
+ 'kind': 'number',
96
+ 'string': false,
97
+ 'constructed': false,
98
+ 'elemental': true
98
99
  },
99
100
  [B.UINT8]: {
100
- "kind": "number",
101
- "string": false,
102
- "constructed": false,
103
- "elemental": true
101
+ 'kind': 'number',
102
+ 'string': false,
103
+ 'constructed': false,
104
+ 'elemental': true
104
105
  },
105
106
  [B.UINT16]: {
106
- "kind": "number",
107
- "string": false,
108
- "constructed": false,
109
- "elemental": true
107
+ 'kind': 'number',
108
+ 'string': false,
109
+ 'constructed': false,
110
+ 'elemental': true
110
111
  },
111
112
  [B.UINT32]: {
112
- "kind": "number",
113
- "string": false,
114
- "constructed": false,
115
- "elemental": true
113
+ 'kind': 'number',
114
+ 'string': false,
115
+ 'constructed': false,
116
+ 'elemental': true
116
117
  },
117
118
  [B.UINT64]: {
118
- "kind": "number",
119
- "string": false,
120
- "constructed": false,
121
- "elemental": true
119
+ 'kind': 'number',
120
+ 'string': false,
121
+ 'constructed': false,
122
+ 'elemental': true
122
123
  },
123
124
  [B.BOOLEAN]: {
124
- "kind": "boolean",
125
- "string": false,
126
- "constructed": false,
127
- "elemental": true
125
+ 'kind': 'boolean',
126
+ 'string': false,
127
+ 'constructed': false,
128
+ 'elemental': true
128
129
  },
129
130
  [B.ARRAY]: {
130
- "kind": "array",
131
- "string": false,
132
- "constructed": true,
133
- "elemental": false
131
+ 'kind': 'array',
132
+ 'string': false,
133
+ 'constructed': true,
134
+ 'elemental': false
134
135
  },
135
136
  [B.ANY]: {
136
- "kind": "unknown",
137
- "string": false,
138
- "constructed": false,
139
- "elemental": false
137
+ 'kind': 'unknown',
138
+ 'string': false,
139
+ 'constructed': false,
140
+ 'elemental': false
140
141
  },
141
142
  [B.STRUCT]: {
142
- "kind": "struct",
143
- "string": false,
144
- "constructed": true,
145
- "elemental": false
143
+ 'kind': 'struct',
144
+ 'string': false,
145
+ 'constructed': true,
146
+ 'elemental': false
146
147
  },
147
148
  [B.NULL]: {
148
- "kind": "null",
149
- "string": false,
150
- "constructed": false,
151
- "elemental": false
149
+ 'kind': 'null',
150
+ 'string': false,
151
+ 'constructed': false,
152
+ 'elemental': false
152
153
  },
153
154
  [B.UNDEFINED]: {
154
- "kind": "void",
155
- "string": false,
156
- "constructed": false,
157
- "elemental": false
155
+ 'kind': 'void',
156
+ 'string': false,
157
+ 'constructed': false,
158
+ 'elemental': false
158
159
  },
159
160
  [B.VOID]: {
160
- "kind": "void",
161
- "string": false,
162
- "constructed": false,
163
- "elemental": false
161
+ 'kind': 'void',
162
+ 'string': false,
163
+ 'constructed': false,
164
+ 'elemental': false
164
165
  },
165
166
  [B.FALSE]: {
166
- "kind": "boolean",
167
- "string": false,
168
- "constructed": false,
169
- "elemental": true
167
+ 'kind': 'boolean',
168
+ 'string': false,
169
+ 'constructed': false,
170
+ 'elemental': true
170
171
  },
171
172
  [B.TRUE]: {
172
- "kind": "boolean",
173
- "string": false,
174
- "constructed": false,
175
- "elemental": true
173
+ 'kind': 'boolean',
174
+ 'string': false,
175
+ 'constructed': false,
176
+ 'elemental': true
176
177
  },
177
178
  [B.FALSE_VALUE]: {
178
- "kind": "unknown",
179
- "string": false,
180
- "constructed": false,
181
- "elemental": false
179
+ 'kind': 'unknown',
180
+ 'string': false,
181
+ 'constructed': false,
182
+ 'elemental': false
182
183
  },
183
184
  [B.TRUE_VALUE]: {
184
- "kind": "unknown",
185
- "string": false,
186
- "constructed": false,
187
- "elemental": false
185
+ 'kind': 'unknown',
186
+ 'string': false,
187
+ 'constructed': false,
188
+ 'elemental': false
188
189
  },
189
190
  [B.OPTIONAL]: {
190
- "kind": "void",
191
- "string": false,
192
- "constructed": false,
193
- "elemental": false
191
+ 'kind': 'void',
192
+ 'string': false,
193
+ 'constructed': false,
194
+ 'elemental': false
194
195
  },
195
196
  [B.REQUIRED]: {
196
- "kind": "unknown",
197
- "string": false,
198
- "constructed": false,
199
- "elemental": false
197
+ 'kind': 'unknown',
198
+ 'string': false,
199
+ 'constructed': false,
200
+ 'elemental': false
200
201
  },
201
202
  [B.DECIMAL]: {
202
- "kind": "number",
203
- "string": true,
204
- "constructed": false,
205
- "elemental": true
203
+ 'kind': 'number',
204
+ 'string': true,
205
+ 'constructed': false,
206
+ 'elemental': true
206
207
  },
207
208
  [B.NUMBER]: {
208
- "kind": "number",
209
- "string": false,
210
- "constructed": false,
211
- "elemental": true
209
+ 'kind': 'number',
210
+ 'string': false,
211
+ 'constructed': false,
212
+ 'elemental': true
212
213
  },
213
214
  [B.FLOAT]: {
214
- "kind": "number",
215
- "string": false,
216
- "constructed": false,
217
- "elemental": true
215
+ 'kind': 'number',
216
+ 'string': false,
217
+ 'constructed': false,
218
+ 'elemental': true
218
219
  },
219
220
  [B.UDECIMAL]: {
220
- "kind": "number",
221
- "string": true,
222
- "constructed": false,
223
- "elemental": true
221
+ 'kind': 'number',
222
+ 'string': true,
223
+ 'constructed': false,
224
+ 'elemental': true
224
225
  },
225
226
  [B.UFLOAT]: {
226
- "kind": "number",
227
- "string": false,
228
- "constructed": false,
229
- "elemental": true
227
+ 'kind': 'number',
228
+ 'string': false,
229
+ 'constructed': false,
230
+ 'elemental': true
230
231
  }
231
232
  };
232
233
  class BuiltInTypeCompiler {
@@ -247,15 +248,15 @@ class BuiltInTypeCompiler {
247
248
  }
248
249
  compile(type, ctx, args) {
249
250
  const fromString = !!(ctx.flags[I.EFlags.FROM_STRING] &&
250
- this.isBuiltInType(type) && (BUILT_IN_TYPES[type].kind === "number" ||
251
- BUILT_IN_TYPES[type].kind === "boolean" ||
252
- BUILT_IN_TYPES[type].kind === "null"));
251
+ this.isBuiltInType(type) && (BUILT_IN_TYPES[type].kind === 'number' ||
252
+ BUILT_IN_TYPES[type].kind === 'boolean' ||
253
+ BUILT_IN_TYPES[type].kind === 'null'));
253
254
  switch (type) {
254
255
  case B.NULL: {
255
256
  if (fromString) {
256
257
  return this._lang.or([
257
258
  this._lang.isNull(ctx.vName, true),
258
- this._lang.eq(ctx.vName, this._lang.literal("null"))
259
+ this._lang.eq(ctx.vName, this._lang.literal('null'))
259
260
  ]);
260
261
  }
261
262
  return this._lang.isNull(ctx.vName, true);
@@ -270,13 +271,13 @@ class BuiltInTypeCompiler {
270
271
  return this._isString(ctx, args);
271
272
  }
272
273
  case B.ASCII_STRING: {
273
- return this._isString(ctx, args, "[\\u0000-\\u007F]");
274
+ return this._isString(ctx, args, '[\\u0000-\\u007F]');
274
275
  }
275
276
  case B.LATIN_STRING: {
276
- return this._isString(ctx, args, "[\\u0000-\\u024F\\u2C60-\\u2C7F]");
277
+ return this._isString(ctx, args, '[\\u0000-\\u024F\\u2C60-\\u2C7F]');
277
278
  }
278
279
  case B.HEX_STRING: {
279
- return this._isString(ctx, args, "[0-9A-Fa-f]");
280
+ return this._isString(ctx, args, '[0-9A-Fa-f]');
280
281
  }
281
282
  case B.UFLOAT: {
282
283
  return this._isNumber(ctx, [0, NaN], fromString);
@@ -356,7 +357,7 @@ class BuiltInTypeCompiler {
356
357
  case B.OPTIONAL:
357
358
  case B.UNDEFINED: {
358
359
  if (ctx.flags[I.EFlags.REQUIRED]) {
359
- throw new Error(`Conflicted: Can not use "optional" with "required" type.`);
360
+ throw new Error('Conflicted: Can not use "optional" with "required" type.');
360
361
  }
361
362
  if (ctx.flags[I.EFlags.OPTIONAL]) {
362
363
  return this._lang.literal(true);
@@ -366,7 +367,7 @@ class BuiltInTypeCompiler {
366
367
  }
367
368
  case B.REQUIRED: {
368
369
  if (ctx.flags[I.EFlags.OPTIONAL]) {
369
- throw new Error(`Conflicted: Can not use "required" with "optional" type.`);
370
+ throw new Error('Conflicted: Can not use "required" with "optional" type.');
370
371
  }
371
372
  if (ctx.flags[I.EFlags.REQUIRED]) {
372
373
  return this._lang.literal(true);
@@ -394,9 +395,9 @@ class BuiltInTypeCompiler {
394
395
  }
395
396
  _isDecimal(ctx, params, unsigned = false) {
396
397
  if (params[0] <= 0) {
397
- throw new RangeError(`Arg 0 can not be zero for decimal.`);
398
+ throw new RangeError('Arg 0 can not be zero for decimal.');
398
399
  }
399
- const sign = unsigned ? "" : "[-+]?";
400
+ const sign = unsigned ? '' : '[-+]?';
400
401
  switch (params.length) {
401
402
  default:
402
403
  case 0: {
@@ -409,12 +410,12 @@ class BuiltInTypeCompiler {
409
410
  return this._lang.and([
410
411
  this._lang.isString(ctx.vName, true),
411
412
  this._lang.matchRegExp(ctx.vName, `^${sign}([1-9]\\d*|0)(\\.\\d+)?$`),
412
- this._lang.ifElseOp(this._lang.instr(ctx.vName, this._lang.literal(".")), this._lang.lte(this._lang.stringLength(ctx.vName), params[0] + 1), this._lang.lte(this._lang.stringLength(ctx.vName), params[0]))
413
+ this._lang.ifElseOp(this._lang.instr(ctx.vName, this._lang.literal('.')), this._lang.lte(this._lang.stringLength(ctx.vName), params[0] + 1), this._lang.lte(this._lang.stringLength(ctx.vName), params[0]))
413
414
  ]);
414
415
  }
415
416
  case 2: {
416
417
  if (params[0] < params[1]) {
417
- throw new RangeError(`Arg 0 should not be larger than arg 1 for decimal.`);
418
+ throw new RangeError('Arg 0 should not be larger than arg 1 for decimal.');
418
419
  }
419
420
  if (params[1] === 0) {
420
421
  return this._lang.and([
@@ -457,7 +458,7 @@ class BuiltInTypeCompiler {
457
458
  ];
458
459
  if (this._checkValidUInteger(params[1], `Invalid argument "${params[1]}" for array.`)) {
459
460
  if (params[0] > params[1]) {
460
- throw new RangeError(`Arg 0 should not be larger than arg 1 for array.`);
461
+ throw new RangeError('Arg 0 should not be larger than arg 1 for array.');
461
462
  }
462
463
  result.push(this._lang.lte(this._lang.arrayLength(ctx.vName), params[1]));
463
464
  }
@@ -475,7 +476,7 @@ class BuiltInTypeCompiler {
475
476
  if (fromString) {
476
477
  result.push(this._lang.and([
477
478
  this._lang.isString(ctx.vName, true),
478
- this._lang.matchRegExp(ctx.vName, "^[-+]?\\d+(\\.\\d+)?$")
479
+ this._lang.matchRegExp(ctx.vName, '^[-+]?\\d+(\\.\\d+)?$')
479
480
  ]));
480
481
  }
481
482
  return this._lang.or(result);
@@ -491,12 +492,12 @@ class BuiltInTypeCompiler {
491
492
  }
492
493
  if (this._checkValidNumber(params[1], `Invalid argument "${params[1]}".`)) {
493
494
  if (params[0] > params[1]) {
494
- throw new RangeError(`Arg 0 should not be larger than arg 1 for number.`);
495
+ throw new RangeError('Arg 0 should not be larger than arg 1 for number.');
495
496
  }
496
497
  result.push(this._lang.lte(vName, params[1]));
497
498
  }
498
499
  if (result.length === 1) {
499
- throw new SyntaxError(`Invalid syntax of integer.`);
500
+ throw new SyntaxError('Invalid syntax of integer.');
500
501
  }
501
502
  if (fromString) {
502
503
  ctx.untrap();
@@ -505,7 +506,7 @@ class BuiltInTypeCompiler {
505
506
  result[0],
506
507
  this._lang.and([
507
508
  this._lang.isString(ctx.vName, true),
508
- this._lang.matchRegExp(ctx.vName, "^[-+]?\\d+(\\.\\d+)?$")
509
+ this._lang.matchRegExp(ctx.vName, '^[-+]?\\d+(\\.\\d+)?$')
509
510
  ])
510
511
  ]),
511
512
  result.length === 3 ? this._lang.closure([vName], [this._lang.str2Float(ctx.vName)], this._lang.returnValue(this._lang.and(result.slice(1)))) : result[1].replace(vName, this._lang.str2Float(ctx.vName))
@@ -525,7 +526,7 @@ class BuiltInTypeCompiler {
525
526
  throw new TypeError(msg);
526
527
  }
527
528
  _checkValidInteger(v, msg) {
528
- if (typeof v === "string") {
529
+ if (typeof v === 'string') {
529
530
  v = parseFloat(v);
530
531
  }
531
532
  if (Number.isNaN(v)) {
@@ -555,7 +556,7 @@ class BuiltInTypeCompiler {
555
556
  if (fromString) {
556
557
  result.push(this._lang.and([
557
558
  this._lang.isString(ctx.vName, true),
558
- this._lang.matchRegExp(ctx.vName, "^[-+]?\\d+$")
559
+ this._lang.matchRegExp(ctx.vName, '^[-+]?\\d+$')
559
560
  ]));
560
561
  }
561
562
  return this._lang.or(result);
@@ -571,12 +572,12 @@ class BuiltInTypeCompiler {
571
572
  }
572
573
  if (this._checkValidInteger(params[1], `Invalid argument "${params[1]}" for integer.`)) {
573
574
  if (params[0] > params[1]) {
574
- throw new RangeError(`Arg 0 should not be larger than arg 1 for number.`);
575
+ throw new RangeError('Arg 0 should not be larger than arg 1 for number.');
575
576
  }
576
577
  result.push(this._lang.lte(vName, params[1]));
577
578
  }
578
579
  if (result.length === 1) {
579
- throw new SyntaxError(`Invalid syntax of integer.`);
580
+ throw new SyntaxError('Invalid syntax of integer.');
580
581
  }
581
582
  if (fromString) {
582
583
  ctx.untrap();
@@ -585,7 +586,7 @@ class BuiltInTypeCompiler {
585
586
  result[0],
586
587
  this._lang.and([
587
588
  this._lang.isString(ctx.vName, true),
588
- this._lang.matchRegExp(ctx.vName, "^[-+]?\\d+$")
589
+ this._lang.matchRegExp(ctx.vName, '^[-+]?\\d+$')
589
590
  ])
590
591
  ]),
591
592
  result.length === 3 ? this._lang.closure([vName], [this._lang.str2Int(ctx.vName)], this._lang.returnValue(this._lang.and(result.slice(1)))) : result[1].replace(vName, this._lang.str2Int(ctx.vName))
@@ -623,7 +624,7 @@ class BuiltInTypeCompiler {
623
624
  if (elementRegExp) {
624
625
  if (this._checkValidUInteger(params[1], `Invalid argument "${params[1]}" for string.`)) {
625
626
  if (params[0] > params[1]) {
626
- throw new RangeError(`Arg 0 should not be larger than arg 1 for string.`);
627
+ throw new RangeError('Arg 0 should not be larger than arg 1 for string.');
627
628
  }
628
629
  result.push(this._lang.matchRegExp(ctx.vName, `^${elementRegExp}{${params[0]},${params[1]}}$`));
629
630
  }
@@ -634,7 +635,7 @@ class BuiltInTypeCompiler {
634
635
  else {
635
636
  if (this._checkValidUInteger(params[1], `Invalid argument "${params[1]}" for string.`)) {
636
637
  if (params[0] > params[1]) {
637
- throw new RangeError(`Arg 0 should not be larger than arg 1 for string.`);
638
+ throw new RangeError('Arg 0 should not be larger than arg 1 for string.');
638
639
  }
639
640
  result.push(this._lang.gte(this._lang.stringLength(ctx.vName), params[0]), this._lang.lte(this._lang.stringLength(ctx.vName), params[1]));
640
641
  }