@schukai/monster 3.4.2 → 3.7.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 (109) hide show
  1. package/example/i18n/providers/embed.mjs +5 -0
  2. package/package.json +1 -1
  3. package/source/constants.mjs +4 -9
  4. package/source/constraints/abstract.mjs +4 -6
  5. package/source/constraints/abstractoperator.mjs +6 -12
  6. package/source/constraints/andoperator.mjs +3 -6
  7. package/source/constraints/invalid.mjs +3 -6
  8. package/source/constraints/isarray.mjs +6 -9
  9. package/source/constraints/isobject.mjs +4 -7
  10. package/source/constraints/namespace.mjs +1 -3
  11. package/source/constraints/oroperator.mjs +26 -25
  12. package/source/constraints/valid.mjs +3 -6
  13. package/source/data/buildmap.mjs +20 -36
  14. package/source/data/buildtree.mjs +29 -29
  15. package/source/data/datasource/namespace.mjs +1 -1
  16. package/source/data/datasource/server/restapi/writeerror.mjs +6 -6
  17. package/source/data/datasource/server/restapi.mjs +51 -65
  18. package/source/data/datasource/server/webconnect.mjs +26 -35
  19. package/source/data/datasource/server.mjs +17 -21
  20. package/source/data/datasource/storage/localstorage.mjs +8 -11
  21. package/source/data/datasource/storage/sessionstorage.mjs +8 -10
  22. package/source/data/datasource/storage.mjs +18 -22
  23. package/source/data/datasource.mjs +27 -43
  24. package/source/data/diff.mjs +20 -32
  25. package/source/data/extend.mjs +20 -14
  26. package/source/data/namespace.mjs +1 -3
  27. package/source/data/pathfinder.mjs +40 -67
  28. package/source/data/pipe.mjs +6 -10
  29. package/source/data/transformer.mjs +141 -157
  30. package/source/dom/assembler.mjs +6 -9
  31. package/source/dom/attributes.mjs +36 -48
  32. package/source/dom/constants.mjs +55 -71
  33. package/source/dom/customcontrol.mjs +16 -21
  34. package/source/dom/customelement.mjs +140 -164
  35. package/source/dom/events.mjs +17 -24
  36. package/source/dom/focusmanager.mjs +30 -48
  37. package/source/dom/locale.mjs +41 -10
  38. package/source/dom/namespace.mjs +1 -1
  39. package/source/dom/ready.mjs +7 -10
  40. package/source/dom/resource/data.mjs +38 -46
  41. package/source/dom/resource/link/namespace.mjs +1 -3
  42. package/source/dom/resource/link/stylesheet.mjs +7 -11
  43. package/source/dom/resource/link.mjs +36 -17
  44. package/source/dom/resource/namespace.mjs +1 -1
  45. package/source/dom/resource/script.mjs +23 -13
  46. package/source/dom/resource.mjs +47 -60
  47. package/source/dom/resourcemanager.mjs +36 -43
  48. package/source/dom/template.mjs +17 -24
  49. package/source/dom/theme.mjs +8 -12
  50. package/source/dom/updater.mjs +150 -196
  51. package/source/dom/util.mjs +11 -12
  52. package/source/dom/worker/factory.mjs +21 -25
  53. package/source/dom/worker/namespace.mjs +1 -1
  54. package/source/i18n/formatter.mjs +20 -24
  55. package/source/i18n/locale.mjs +40 -42
  56. package/source/i18n/namespace.mjs +1 -1
  57. package/source/i18n/provider.mjs +4 -7
  58. package/source/i18n/providers/embed.mjs +115 -0
  59. package/source/i18n/providers/fetch.mjs +33 -38
  60. package/source/i18n/translations.mjs +16 -20
  61. package/source/logging/handler/console.mjs +6 -10
  62. package/source/logging/handler.mjs +15 -18
  63. package/source/logging/logentry.mjs +8 -9
  64. package/source/logging/logger.mjs +73 -55
  65. package/source/logging/namespace.mjs +1 -1
  66. package/source/math/namespace.mjs +1 -1
  67. package/source/math/random.mjs +13 -14
  68. package/source/monster.mjs +132 -100
  69. package/source/net/namespace.mjs +1 -3
  70. package/source/net/webconnect/message.mjs +6 -8
  71. package/source/net/webconnect/namespace.mjs +1 -3
  72. package/source/net/webconnect.mjs +28 -39
  73. package/source/text/formatter.mjs +44 -55
  74. package/source/types/base.mjs +16 -26
  75. package/source/types/basewithoptions.mjs +8 -14
  76. package/source/types/binary.mjs +4 -5
  77. package/source/types/dataurl.mjs +19 -27
  78. package/source/types/global.mjs +14 -26
  79. package/source/types/id.mjs +4 -6
  80. package/source/types/is.mjs +11 -16
  81. package/source/types/mediatype.mjs +29 -44
  82. package/source/types/namespace.mjs +0 -1
  83. package/source/types/node.mjs +16 -22
  84. package/source/types/nodelist.mjs +10 -14
  85. package/source/types/noderecursiveiterator.mjs +11 -14
  86. package/source/types/observablequeue.mjs +13 -16
  87. package/source/types/observer.mjs +16 -23
  88. package/source/types/observerlist.mjs +18 -21
  89. package/source/types/proxyobserver.mjs +24 -37
  90. package/source/types/queue.mjs +8 -13
  91. package/source/types/randomid.mjs +10 -10
  92. package/source/types/regex.mjs +3 -5
  93. package/source/types/stack.mjs +4 -8
  94. package/source/types/tokenlist.mjs +24 -31
  95. package/source/types/typeof.mjs +5 -7
  96. package/source/types/uniquequeue.mjs +8 -13
  97. package/source/types/uuid.mjs +18 -25
  98. package/source/types/validate.mjs +26 -27
  99. package/source/types/version.mjs +17 -25
  100. package/source/util/clone.mjs +23 -32
  101. package/source/util/comparator.mjs +7 -15
  102. package/source/util/deadmansswitch.mjs +16 -23
  103. package/source/util/freeze.mjs +5 -7
  104. package/source/util/namespace.mjs +1 -1
  105. package/source/util/processing.mjs +33 -39
  106. package/source/util/trimspaces.mjs +17 -24
  107. package/test/cases/dom/locale.mjs +15 -0
  108. package/test/cases/i18n/providers/embed.mjs +72 -0
  109. package/test/cases/monster.mjs +1 -1
@@ -5,11 +5,11 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {isIterable, isString} from '../types/is.mjs';
9
- import {validateFunction, validateString} from '../types/validate.mjs';
10
- import {Base} from './base.mjs';
8
+ import { isIterable, isString } from "../types/is.mjs";
9
+ import { validateFunction, validateString } from "../types/validate.mjs";
10
+ import { Base } from "./base.mjs";
11
11
 
12
- export {TokenList}
12
+ export { TokenList };
13
13
 
14
14
  /**
15
15
  * A `TokenList` allows you to manage tokens (individual character strings such as css classes in an attribute string).
@@ -25,7 +25,6 @@ export {TokenList}
25
25
  * @memberOf Monster.Types
26
26
  */
27
27
  class TokenList extends Base {
28
-
29
28
  /**
30
29
  *
31
30
  * @param {array|string|iteratable} init
@@ -37,7 +36,6 @@ class TokenList extends Base {
37
36
  if (typeof init !== "undefined") {
38
37
  this.add(init);
39
38
  }
40
-
41
39
  }
42
40
 
43
41
  /**
@@ -59,17 +57,17 @@ class TokenList extends Base {
59
57
  // iterations over the iterable safe for non-trivial cases,
60
58
  // such as use of break or nested looping over the same iterable.
61
59
  let index = 0;
62
- let entries = this.entries()
60
+ let entries = this.entries();
63
61
 
64
62
  return {
65
63
  next: () => {
66
64
  if (index < entries.length) {
67
- return {value: entries?.[index++], done: false}
65
+ return { value: entries?.[index++], done: false };
68
66
  } else {
69
- return {done: true}
67
+ return { done: true };
70
68
  }
71
- }
72
- }
69
+ },
70
+ };
73
71
  }
74
72
 
75
73
  /**
@@ -81,12 +79,12 @@ class TokenList extends Base {
81
79
  */
82
80
  contains(value) {
83
81
  if (isString(value)) {
84
- value = value.trim()
82
+ value = value.trim();
85
83
  let counter = 0;
86
- value.split(" ").forEach(token => {
84
+ value.split(" ").forEach((token) => {
87
85
  if (this.tokens.has(token.trim()) === false) return false;
88
- counter++
89
- })
86
+ counter++;
87
+ });
90
88
  return counter > 0 ? true : false;
91
89
  }
92
90
 
@@ -95,7 +93,7 @@ class TokenList extends Base {
95
93
  for (let token of value) {
96
94
  validateString(token);
97
95
  if (this.tokens.has(token.trim()) === false) return false;
98
- counter++
96
+ counter++;
99
97
  }
100
98
  return counter > 0 ? true : false;
101
99
  }
@@ -113,9 +111,9 @@ class TokenList extends Base {
113
111
  */
114
112
  add(value) {
115
113
  if (isString(value)) {
116
- value.split(" ").forEach(token => {
114
+ value.split(" ").forEach((token) => {
117
115
  this.tokens.add(token.trim());
118
- })
116
+ });
119
117
  } else if (isIterable(value)) {
120
118
  for (let token of value) {
121
119
  validateString(token);
@@ -148,9 +146,9 @@ class TokenList extends Base {
148
146
  */
149
147
  remove(value) {
150
148
  if (isString(value)) {
151
- value.split(" ").forEach(token => {
149
+ value.split(" ").forEach((token) => {
152
150
  this.tokens.delete(token.trim());
153
- })
151
+ });
154
152
  } else if (isIterable(value)) {
155
153
  for (let token of value) {
156
154
  validateString(token);
@@ -180,7 +178,7 @@ class TokenList extends Base {
180
178
  return this;
181
179
  }
182
180
 
183
- let a = Array.from(this.tokens)
181
+ let a = Array.from(this.tokens);
184
182
  let i = a.indexOf(token);
185
183
  if (i === -1) return this;
186
184
 
@@ -189,8 +187,6 @@ class TokenList extends Base {
189
187
  this.add(a);
190
188
 
191
189
  return this;
192
-
193
-
194
190
  }
195
191
 
196
192
  /**
@@ -202,11 +198,10 @@ class TokenList extends Base {
202
198
  * @throws {TypeError} unsupported value
203
199
  */
204
200
  toggle(value) {
205
-
206
201
  if (isString(value)) {
207
- value.split(" ").forEach(token => {
202
+ value.split(" ").forEach((token) => {
208
203
  toggleValue.call(this, token);
209
- })
204
+ });
210
205
  } else if (isIterable(value)) {
211
206
  for (let token of value) {
212
207
  toggleValue.call(this, token);
@@ -216,7 +211,6 @@ class TokenList extends Base {
216
211
  }
217
212
 
218
213
  return this;
219
-
220
214
  }
221
215
 
222
216
  /**
@@ -225,7 +219,7 @@ class TokenList extends Base {
225
219
  * @returns {array}
226
220
  */
227
221
  entries() {
228
- return Array.from(this.tokens)
222
+ return Array.from(this.tokens);
229
223
  }
230
224
 
231
225
  /**
@@ -246,9 +240,8 @@ class TokenList extends Base {
246
240
  * @returns {string}
247
241
  */
248
242
  toString() {
249
- return this.entries().join(' ');
243
+ return this.entries().join(" ");
250
244
  }
251
-
252
245
  }
253
246
 
254
247
  /**
@@ -258,7 +251,7 @@ class TokenList extends Base {
258
251
  * @throws {Error} must be called with TokenList.call
259
252
  */
260
253
  function toggleValue(token) {
261
- if (!(this instanceof TokenList)) throw Error("must be called with TokenList.call")
254
+ if (!(this instanceof TokenList)) throw Error("must be called with TokenList.call");
262
255
  validateString(token);
263
256
  token = token.trim();
264
257
  if (this.contains(token)) {
@@ -5,7 +5,7 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- export {typeOf}
8
+ export { typeOf };
9
9
 
10
10
  /**
11
11
  * The built-in typeof method is known to have some historical weaknesses. This function tries to provide a better and more accurate result.
@@ -20,18 +20,16 @@ export {typeOf}
20
20
  * @throws {TypeError} value is not a primitive
21
21
  */
22
22
  function typeOf(value) {
23
- let type = ({}).toString.call(value).match(/\s([a-zA-Z]+)/)[1];
24
- if ('Object' === type) {
25
-
23
+ let type = {}.toString.call(value).match(/\s([a-zA-Z]+)/)[1];
24
+ if ("Object" === type) {
26
25
  const name = value.constructor.name;
27
26
  if (name) {
28
27
  return name.toLowerCase();
29
28
  }
30
29
 
31
- const results = (/^(class|function)\s+(\w+)/).exec(value.constructor.toString());
32
- type = (results && results.length > 2) ? results[2] : '';
30
+ const results = /^(class|function)\s+(\w+)/.exec(value.constructor.toString());
31
+ type = results && results.length > 2 ? results[2] : "";
33
32
  }
34
33
 
35
34
  return type.toLowerCase();
36
35
  }
37
-
@@ -5,11 +5,11 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {Queue} from "./queue.mjs";
9
- import {internalSymbol} from "../constants.mjs";
10
- import {validateObject} from "./validate.mjs";
8
+ import { Queue } from "./queue.mjs";
9
+ import { internalSymbol } from "../constants.mjs";
10
+ import { validateObject } from "./validate.mjs";
11
11
 
12
- export {UniqueQueue}
12
+ export { UniqueQueue };
13
13
 
14
14
  /**
15
15
  * An UniqueQueue is a queue that contains items only once.
@@ -20,15 +20,14 @@ export {UniqueQueue}
20
20
  * @memberOf Monster.Types
21
21
  * @summary A queue for unique values
22
22
  */
23
- class UniqueQueue extends Queue {
24
-
23
+ class UniqueQueue extends Queue {
25
24
  /**
26
25
  *
27
26
  */
28
27
  constructor() {
29
28
  super();
30
- this[internalSymbol]={
31
- unique : new WeakSet()
29
+ this[internalSymbol] = {
30
+ unique: new WeakSet(),
32
31
  };
33
32
  }
34
33
 
@@ -40,7 +39,6 @@ export {UniqueQueue}
40
39
  * @throws {TypeError} value is not a object
41
40
  */
42
41
  add(value) {
43
-
44
42
  validateObject(value);
45
43
 
46
44
  if (!this[internalSymbol].unique.has(value)) {
@@ -58,7 +56,7 @@ export {UniqueQueue}
58
56
  */
59
57
  clear() {
60
58
  super.clear();
61
- this[internalSymbol].unique = new WeakSet;
59
+ this[internalSymbol].unique = new WeakSet();
62
60
  return this;
63
61
  }
64
62
 
@@ -69,7 +67,6 @@ export {UniqueQueue}
69
67
  * @return {object}
70
68
  */
71
69
  poll() {
72
-
73
70
  if (this.isEmpty()) {
74
71
  return undefined;
75
72
  }
@@ -77,6 +74,4 @@ export {UniqueQueue}
77
74
  this[internalSymbol].unique.delete(value);
78
75
  return value;
79
76
  }
80
-
81
-
82
77
  }
@@ -5,25 +5,24 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {internalSymbol} from "../constants.mjs";
9
- import {random} from "../math/random.mjs";
10
- import {isObject} from '../types/is.mjs';
11
- import {Base} from "./base.mjs";
12
- import {getGlobalObject} from "./global.mjs";
8
+ import { internalSymbol } from "../constants.mjs";
9
+ import { random } from "../math/random.mjs";
10
+ import { isObject } from "../types/is.mjs";
11
+ import { Base } from "./base.mjs";
12
+ import { getGlobalObject } from "./global.mjs";
13
13
 
14
- export {UUID}
14
+ export { UUID };
15
15
 
16
16
  /**
17
17
  * The UUID class makes it possible to get a unique UUID for an object.
18
- *
18
+ *
19
19
  * @license AGPLv3
20
20
  * @since 1.25.0
21
21
  * @copyright schukai GmbH
22
22
  * @memberOf Monster.Types
23
23
  * @throws {Error} unsupported
24
24
  */
25
- class UUID extends Base {
26
-
25
+ class UUID extends Base {
27
26
  /**
28
27
  *
29
28
  */
@@ -36,15 +35,13 @@ export {UUID}
36
35
  uuid = createWithRandom();
37
36
  }
38
37
 
39
-
40
38
  if (uuid === undefined) {
41
- throw new Error('unsupported')
39
+ throw new Error("unsupported");
42
40
  }
43
41
 
44
42
  this[internalSymbol] = {
45
- value: uuid
46
- }
47
-
43
+ value: uuid,
44
+ };
48
45
  }
49
46
 
50
47
  /**
@@ -52,10 +49,8 @@ export {UUID}
52
49
  * @return {string}
53
50
  */
54
51
  toString() {
55
- return this[internalSymbol]['value'];
52
+ return this[internalSymbol]["value"];
56
53
  }
57
-
58
-
59
54
  }
60
55
 
61
56
  /**
@@ -63,22 +58,20 @@ export {UUID}
63
58
  * @return {string|undefined}
64
59
  */
65
60
  function createWithRandom() {
66
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
67
- var r = random(0, 65000) * 16 | 0,
68
- v = ((c === 'x') ? r : (r & 0x3 | 0x8));
61
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
62
+ const r = (random(0, 65000) * 16) | 0;
63
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
69
64
  return v.toString(16)[0];
70
- })
65
+ });
71
66
  }
72
67
 
73
-
74
68
  /**
75
69
  * @private
76
70
  * @return {string|undefined}
77
71
  */
78
72
  function createWithCrypto() {
79
- const crypt = getGlobalObject('crypto');
73
+ const crypt = getGlobalObject("crypto");
80
74
  if (!isObject(crypt)) return;
81
- if (typeof crypt?.['randomUUID']) return;
75
+ if (typeof crypt?.["randomUUID"]) return;
82
76
  return crypt.randomUUID();
83
77
  }
84
-
@@ -15,8 +15,8 @@ import {
15
15
  isObject,
16
16
  isPrimitive,
17
17
  isString,
18
- isSymbol
19
- } from './is.mjs';
18
+ isSymbol,
19
+ } from "./is.mjs";
20
20
 
21
21
  export {
22
22
  validateIterable,
@@ -28,8 +28,8 @@ export {
28
28
  validateArray,
29
29
  validateSymbol,
30
30
  validateFunction,
31
- validateInteger
32
- }
31
+ validateInteger,
32
+ };
33
33
 
34
34
  /**
35
35
  * This method checks if the type matches the primitive type. this function is identical to isPrimitive() except that a TypeError is thrown.
@@ -55,9 +55,9 @@ export {
55
55
  */
56
56
  function validateIterable(value) {
57
57
  if (!isIterable(value)) {
58
- throw new TypeError('value is not iterable')
58
+ throw new TypeError("value is not iterable");
59
59
  }
60
- return value
60
+ return value;
61
61
  }
62
62
 
63
63
  /**
@@ -84,9 +84,9 @@ function validateIterable(value) {
84
84
  */
85
85
  function validatePrimitive(value) {
86
86
  if (!isPrimitive(value)) {
87
- throw new TypeError('value is not a primitive')
87
+ throw new TypeError("value is not a primitive");
88
88
  }
89
- return value
89
+ return value;
90
90
  }
91
91
 
92
92
  /**
@@ -112,9 +112,9 @@ function validatePrimitive(value) {
112
112
  */
113
113
  function validateBoolean(value) {
114
114
  if (!isBoolean(value)) {
115
- throw new TypeError('value is not a boolean')
115
+ throw new TypeError("value is not a boolean");
116
116
  }
117
- return value
117
+ return value;
118
118
  }
119
119
 
120
120
  /**
@@ -138,12 +138,11 @@ function validateBoolean(value) {
138
138
  */
139
139
  function validateString(value) {
140
140
  if (!isString(value)) {
141
- throw new TypeError('value is not a string')
141
+ throw new TypeError("value is not a string");
142
142
  }
143
- return value
143
+ return value;
144
144
  }
145
145
 
146
-
147
146
  /**
148
147
  * This method checks if the type matches the object type. this function is identical to isObject() except that a TypeError is thrown.
149
148
  *
@@ -166,9 +165,9 @@ function validateString(value) {
166
165
  */
167
166
  function validateObject(value) {
168
167
  if (!isObject(value)) {
169
- throw new TypeError('value is not a object')
168
+ throw new TypeError("value is not a object");
170
169
  }
171
- return value
170
+ return value;
172
171
  }
173
172
 
174
173
  /**
@@ -195,16 +194,16 @@ function validateInstance(value, instance) {
195
194
  if (!isInstance(value, instance)) {
196
195
  let n = "";
197
196
  if (isObject(instance) || isFunction(instance)) {
198
- n = instance?.['name']
197
+ n = instance?.["name"];
199
198
  }
200
199
 
201
200
  if (n) {
202
- n = " " + n;
201
+ n = ` ${n}`;
203
202
  }
204
203
 
205
- throw new TypeError('value is not an instance of' + n)
204
+ throw new TypeError(`value is not an instance of${n}`);
206
205
  }
207
- return value
206
+ return value;
208
207
  }
209
208
 
210
209
  /**
@@ -228,9 +227,9 @@ function validateInstance(value, instance) {
228
227
  */
229
228
  function validateArray(value) {
230
229
  if (!isArray(value)) {
231
- throw new TypeError('value is not an array')
230
+ throw new TypeError("value is not an array");
232
231
  }
233
- return value
232
+ return value;
234
233
  }
235
234
 
236
235
  /**
@@ -254,9 +253,9 @@ function validateArray(value) {
254
253
  */
255
254
  function validateSymbol(value) {
256
255
  if (!isSymbol(value)) {
257
- throw new TypeError('value is not an symbol')
256
+ throw new TypeError("value is not an symbol");
258
257
  }
259
- return value
258
+ return value;
260
259
  }
261
260
 
262
261
  /**
@@ -281,9 +280,9 @@ function validateSymbol(value) {
281
280
  */
282
281
  function validateFunction(value) {
283
282
  if (!isFunction(value)) {
284
- throw new TypeError('value is not a function')
283
+ throw new TypeError("value is not a function");
285
284
  }
286
- return value
285
+ return value;
287
286
  }
288
287
 
289
288
  /**
@@ -308,7 +307,7 @@ function validateFunction(value) {
308
307
  */
309
308
  function validateInteger(value) {
310
309
  if (!isInteger(value)) {
311
- throw new TypeError('value is not an integer')
310
+ throw new TypeError("value is not an integer");
312
311
  }
313
- return value
312
+ return value;
314
313
  }
@@ -5,11 +5,10 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {Base} from './base.mjs';
9
- import {instanceSymbol} from '../constants.mjs';
10
-
11
- export {Version, getMonsterVersion}
8
+ import { Base } from "./base.mjs";
9
+ import { instanceSymbol } from "../constants.mjs";
12
10
 
11
+ export { Version, getMonsterVersion };
13
12
 
14
13
  /**
15
14
  * The version object contains a semantic version number
@@ -23,7 +22,6 @@ export {Version, getMonsterVersion}
23
22
  * @summary The version object contains a sematic version number
24
23
  */
25
24
  class Version extends Base {
26
-
27
25
  /**
28
26
  *
29
27
  * @param major
@@ -36,16 +34,15 @@ class Version extends Base {
36
34
  constructor(major, minor, patch) {
37
35
  super();
38
36
 
39
- if (typeof major === 'string' && minor === undefined && patch === undefined) {
40
-
41
- let parts = major.toString().split('.');
37
+ if (typeof major === "string" && minor === undefined && patch === undefined) {
38
+ let parts = major.toString().split(".");
42
39
  major = parseInt(parts[0] || 0);
43
40
  minor = parseInt(parts[1] || 0);
44
41
  patch = parseInt(parts[2] || 0);
45
42
  }
46
43
 
47
44
  if (major === undefined) {
48
- throw new Error("major version is undefined");
45
+ throw new Error("major version is undefined");
49
46
  }
50
47
 
51
48
  if (minor === undefined) {
@@ -61,17 +58,16 @@ class Version extends Base {
61
58
  this.patch = parseInt(patch);
62
59
 
63
60
  if (isNaN(this.major)) {
64
- throw new Error("major is not a number");
61
+ throw new Error("major is not a number");
65
62
  }
66
63
 
67
64
  if (isNaN(this.minor)) {
68
- throw new Error("minor is not a number");
65
+ throw new Error("minor is not a number");
69
66
  }
70
67
 
71
68
  if (isNaN(this.patch)) {
72
- throw new Error("patch is not a number");
69
+ throw new Error("patch is not a number");
73
70
  }
74
-
75
71
  }
76
72
 
77
73
  /**
@@ -83,13 +79,12 @@ class Version extends Base {
83
79
  return Symbol.for("@schukai/monster/types/version");
84
80
  }
85
81
 
86
-
87
82
  /**
88
83
  *
89
84
  * @returns {string}
90
85
  */
91
86
  toString() {
92
- return this.major + '.' + this.minor + '.' + this.patch;
87
+ return `${this.major}.${this.minor}.${this.patch}`;
93
88
  }
94
89
 
95
90
  /**
@@ -100,13 +95,12 @@ class Version extends Base {
100
95
  * @returns {number}
101
96
  */
102
97
  compareTo(version) {
103
-
104
98
  if (version instanceof Version) {
105
99
  version = version.toString();
106
100
  }
107
101
 
108
- if (typeof version !== 'string') {
109
- throw new Error("type exception");
102
+ if (typeof version !== "string") {
103
+ throw new Error("type exception");
110
104
  }
111
105
 
112
106
  if (version === this.toString()) {
@@ -114,20 +108,19 @@ class Version extends Base {
114
108
  }
115
109
 
116
110
  let a = [this.major, this.minor, this.patch];
117
- let b = version.split('.');
111
+ let b = version.split(".");
118
112
  let len = Math.max(a.length, b.length);
119
113
 
120
114
  for (let i = 0; i < len; i += 1) {
121
- if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) {
115
+ if ((a[i] && !b[i] && parseInt(a[i]) > 0) || parseInt(a[i]) > parseInt(b[i])) {
122
116
  return 1;
123
- } else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) {
117
+ } else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || parseInt(a[i]) < parseInt(b[i])) {
124
118
  return -1;
125
119
  }
126
120
  }
127
121
 
128
122
  return 0;
129
- };
130
-
123
+ }
131
124
  }
132
125
 
133
126
  let monsterVersion;
@@ -149,8 +142,7 @@ function getMonsterVersion() {
149
142
  }
150
143
 
151
144
  /** don't touch, replaced by make with package.json version */
152
- monsterVersion = new Version('3.4.2')
145
+ monsterVersion = new Version("3.7.0");
153
146
 
154
147
  return monsterVersion;
155
-
156
148
  }