@schukai/monster 3.5.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/package.json +1 -1
  2. package/source/constants.mjs +4 -9
  3. package/source/constraints/abstract.mjs +4 -6
  4. package/source/constraints/abstractoperator.mjs +6 -12
  5. package/source/constraints/andoperator.mjs +3 -6
  6. package/source/constraints/invalid.mjs +3 -6
  7. package/source/constraints/isarray.mjs +6 -9
  8. package/source/constraints/isobject.mjs +4 -7
  9. package/source/constraints/namespace.mjs +1 -3
  10. package/source/constraints/oroperator.mjs +26 -25
  11. package/source/constraints/valid.mjs +3 -6
  12. package/source/data/buildmap.mjs +20 -36
  13. package/source/data/buildtree.mjs +29 -29
  14. package/source/data/datasource/namespace.mjs +1 -1
  15. package/source/data/datasource/server/restapi/writeerror.mjs +6 -6
  16. package/source/data/datasource/server/restapi.mjs +51 -65
  17. package/source/data/datasource/server/webconnect.mjs +26 -35
  18. package/source/data/datasource/server.mjs +16 -20
  19. package/source/data/datasource/storage/localstorage.mjs +8 -11
  20. package/source/data/datasource/storage/sessionstorage.mjs +8 -10
  21. package/source/data/datasource/storage.mjs +18 -22
  22. package/source/data/datasource.mjs +27 -43
  23. package/source/data/diff.mjs +20 -32
  24. package/source/data/extend.mjs +20 -14
  25. package/source/data/namespace.mjs +1 -3
  26. package/source/data/pathfinder.mjs +105 -87
  27. package/source/data/pipe.mjs +6 -10
  28. package/source/data/transformer.mjs +141 -157
  29. package/source/dom/assembler.mjs +6 -9
  30. package/source/dom/attributes.mjs +36 -48
  31. package/source/dom/constants.mjs +55 -71
  32. package/source/dom/customcontrol.mjs +16 -21
  33. package/source/dom/customelement.mjs +140 -164
  34. package/source/dom/events.mjs +17 -24
  35. package/source/dom/focusmanager.mjs +31 -49
  36. package/source/dom/locale.mjs +18 -20
  37. package/source/dom/namespace.mjs +1 -1
  38. package/source/dom/ready.mjs +7 -10
  39. package/source/dom/resource/data.mjs +38 -46
  40. package/source/dom/resource/link/namespace.mjs +1 -3
  41. package/source/dom/resource/link/stylesheet.mjs +7 -11
  42. package/source/dom/resource/link.mjs +36 -17
  43. package/source/dom/resource/namespace.mjs +1 -1
  44. package/source/dom/resource/script.mjs +23 -13
  45. package/source/dom/resource.mjs +47 -60
  46. package/source/dom/resourcemanager.mjs +36 -43
  47. package/source/dom/template.mjs +17 -24
  48. package/source/dom/theme.mjs +8 -12
  49. package/source/dom/updater.mjs +150 -196
  50. package/source/dom/util.mjs +11 -12
  51. package/source/dom/worker/factory.mjs +21 -25
  52. package/source/dom/worker/namespace.mjs +1 -1
  53. package/source/i18n/formatter.mjs +20 -24
  54. package/source/i18n/locale.mjs +42 -55
  55. package/source/i18n/namespace.mjs +1 -1
  56. package/source/i18n/provider.mjs +4 -7
  57. package/source/i18n/providers/embed.mjs +16 -26
  58. package/source/i18n/providers/fetch.mjs +30 -36
  59. package/source/i18n/translations.mjs +17 -24
  60. package/source/logging/handler/console.mjs +6 -10
  61. package/source/logging/handler.mjs +15 -18
  62. package/source/logging/logentry.mjs +8 -9
  63. package/source/logging/logger.mjs +73 -55
  64. package/source/logging/namespace.mjs +1 -1
  65. package/source/math/namespace.mjs +1 -1
  66. package/source/math/random.mjs +13 -14
  67. package/source/monster.mjs +132 -100
  68. package/source/net/namespace.mjs +1 -3
  69. package/source/net/webconnect/message.mjs +6 -8
  70. package/source/net/webconnect/namespace.mjs +1 -3
  71. package/source/net/webconnect.mjs +28 -39
  72. package/source/text/formatter.mjs +44 -55
  73. package/source/types/base.mjs +16 -26
  74. package/source/types/basewithoptions.mjs +8 -14
  75. package/source/types/binary.mjs +4 -5
  76. package/source/types/dataurl.mjs +19 -27
  77. package/source/types/global.mjs +14 -26
  78. package/source/types/id.mjs +4 -6
  79. package/source/types/is.mjs +11 -16
  80. package/source/types/mediatype.mjs +29 -44
  81. package/source/types/namespace.mjs +0 -1
  82. package/source/types/node.mjs +16 -22
  83. package/source/types/nodelist.mjs +10 -14
  84. package/source/types/noderecursiveiterator.mjs +11 -14
  85. package/source/types/observablequeue.mjs +13 -16
  86. package/source/types/observer.mjs +16 -23
  87. package/source/types/observerlist.mjs +18 -21
  88. package/source/types/proxyobserver.mjs +24 -37
  89. package/source/types/queue.mjs +8 -13
  90. package/source/types/randomid.mjs +10 -10
  91. package/source/types/regex.mjs +3 -5
  92. package/source/types/stack.mjs +4 -8
  93. package/source/types/tokenlist.mjs +24 -31
  94. package/source/types/typeof.mjs +5 -7
  95. package/source/types/uniquequeue.mjs +8 -13
  96. package/source/types/uuid.mjs +18 -25
  97. package/source/types/validate.mjs +26 -27
  98. package/source/types/version.mjs +17 -25
  99. package/source/util/clone.mjs +23 -32
  100. package/source/util/comparator.mjs +7 -15
  101. package/source/util/deadmansswitch.mjs +16 -23
  102. package/source/util/freeze.mjs +5 -7
  103. package/source/util/namespace.mjs +1 -1
  104. package/source/util/processing.mjs +33 -39
  105. package/source/util/trimspaces.mjs +17 -24
  106. package/test/cases/monster.mjs +1 -1
@@ -5,21 +5,21 @@
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 {extend} from "../../data/extend.mjs";
10
- import {Formatter} from "../../text/formatter.mjs";
11
- import {getGlobalFunction} from "../../types/global.mjs";
12
- import {isInstance, isString} from "../../types/is.mjs";
13
- import {validateObject, validateString} from "../../types/validate.mjs";
14
- import {parseLocale} from "../locale.mjs";
15
- import {Provider} from "../provider.mjs";
16
- import {Translations} from "../translations.mjs";
17
-
18
- export {Fetch}
8
+ import { internalSymbol } from "../../constants.mjs";
9
+ import { extend } from "../../data/extend.mjs";
10
+ import { Formatter } from "../../text/formatter.mjs";
11
+ import { getGlobalFunction } from "../../types/global.mjs";
12
+ import { isInstance, isString } from "../../types/is.mjs";
13
+ import { validateObject, validateString } from "../../types/validate.mjs";
14
+ import { parseLocale } from "../locale.mjs";
15
+ import { Provider } from "../provider.mjs";
16
+ import { Translations } from "../translations.mjs";
17
+
18
+ export { Fetch };
19
19
 
20
20
  /**
21
21
  * The fetch provider retrieves a JSON file from the given URL and returns a translation object.
22
- *
22
+ *
23
23
  * @externalExample ../../../example/i18n/providers/fetch.mjs
24
24
  * @license AGPLv3
25
25
  * @since 1.13.0
@@ -28,17 +28,16 @@ export {Fetch}
28
28
  * @see {@link https://datatracker.ietf.org/doc/html/rfc3066}
29
29
  * @tutorial i18n-locale-and-formatter
30
30
  */
31
- class Fetch extends Provider {
32
-
31
+ class Fetch extends Provider {
33
32
  /**
34
33
  * As options the key `fetch` can be passed. This config object is passed to the fetch method as init.
35
- *
34
+ *
36
35
  * The url may contain placeholders (language, script, region, variants, extlang, privateUse), so you can specify one url for all translations.
37
- *
36
+ *
38
37
  * ```
39
38
  * new Fetch('https://www.example.com/assets/${language}.json')
40
39
  * ```
41
- *
40
+ *
42
41
  * @param {string|URL} url
43
42
  * @param {Object} options see {@link Monster.I18n.Providers.Fetch#defaults}
44
43
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
@@ -66,7 +65,6 @@ export {Fetch}
66
65
  * @property {Object} options
67
66
  */
68
67
  this[internalSymbol] = extend({}, super.defaults, this.defaults, validateObject(options));
69
-
70
68
  }
71
69
 
72
70
  /**
@@ -83,19 +81,19 @@ export {Fetch}
83
81
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API}
84
82
  */
85
83
  get defaults() {
86
-
87
84
  return extend(
88
85
  {
89
86
  fetch: {
90
- method: 'GET', // *GET, POST, PUT, DELETE, etc.
91
- mode: 'cors', // no-cors, *cors, same-origin
92
- cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
93
- credentials: 'omit', // include, *same-origin, omit
94
- redirect: 'follow', // manual, *follow, error
95
- referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
96
- }
97
- }, super.defaults);
98
-
87
+ method: "GET", // *GET, POST, PUT, DELETE, etc.
88
+ mode: "cors", // no-cors, *cors, same-origin
89
+ cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
90
+ credentials: "omit", // include, *same-origin, omit
91
+ redirect: "follow", // manual, *follow, error
92
+ referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
93
+ },
94
+ },
95
+ super.defaults,
96
+ );
99
97
  }
100
98
 
101
99
  /**
@@ -104,20 +102,16 @@ export {Fetch}
104
102
  * @return {Promise}
105
103
  */
106
104
  getTranslations(locale) {
107
-
108
105
  if (isString(locale)) {
109
106
  locale = parseLocale(locale);
110
107
  }
111
108
 
112
- let formatter = new Formatter(locale.getMap())
109
+ let formatter = new Formatter(locale.getMap());
113
110
 
114
- return getGlobalFunction('fetch')(formatter.format(this.url), this.getOption('fetch', {}))
115
- .then((response) => response.json()).then(data => {
111
+ return getGlobalFunction("fetch")(formatter.format(this.url), this.getOption("fetch", {}))
112
+ .then((response) => response.json())
113
+ .then((data) => {
116
114
  return new Translations(locale).assignTranslations(data);
117
115
  });
118
-
119
116
  }
120
-
121
-
122
117
  }
123
-
@@ -5,12 +5,12 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {Base} from "../types/base.mjs";
9
- import {isObject, isString} from "../types/is.mjs";
10
- import {validateInstance, validateInteger, validateObject, validateString} from "../types/validate.mjs";
11
- import {Locale, parseLocale} from "./locale.mjs";
8
+ import { Base } from "../types/base.mjs";
9
+ import { isObject, isString } from "../types/is.mjs";
10
+ import { validateInstance, validateInteger, validateObject, validateString } from "../types/validate.mjs";
11
+ import { Locale, parseLocale } from "./locale.mjs";
12
12
 
13
- export {Translations}
13
+ export { Translations };
14
14
 
15
15
  /**
16
16
  * With this class you can manage translations and access the keys.
@@ -23,7 +23,6 @@ export {Translations}
23
23
  * @see https://datatracker.ietf.org/doc/html/rfc3066
24
24
  */
25
25
  class Translations extends Base {
26
-
27
26
  /**
28
27
  *
29
28
  * @param {Locale} locale
@@ -37,10 +36,8 @@ class Translations extends Base {
37
36
 
38
37
  this.locale = validateInstance(locale, Locale);
39
38
  this.storage = new Map();
40
-
41
39
  }
42
40
 
43
-
44
41
  /**
45
42
  * Fetches a text using the specified key.
46
43
  * If no suitable key is found, `defaultText` is taken.
@@ -53,7 +50,7 @@ class Translations extends Base {
53
50
  getText(key, defaultText) {
54
51
  if (!this.storage.has(key)) {
55
52
  if (defaultText === undefined) {
56
- throw new Error('key ' + key + ' not found');
53
+ throw new Error(`key ${key} not found`);
57
54
  }
58
55
 
59
56
  return validateString(defaultText);
@@ -61,7 +58,7 @@ class Translations extends Base {
61
58
 
62
59
  let r = this.storage.get(key);
63
60
  if (isObject(r)) {
64
- return this.getPluralRuleText(key, 'other', defaultText);
61
+ return this.getPluralRuleText(key, "other", defaultText);
65
62
  }
66
63
 
67
64
  return this.storage.get(key);
@@ -92,8 +89,8 @@ class Translations extends Base {
92
89
  count = validateInteger(count);
93
90
  if (count === 0) {
94
91
  // special handlig for zero count
95
- if (r.hasOwnProperty('zero')) {
96
- return validateString(r['zero']);
92
+ if (r.hasOwnProperty("zero")) {
93
+ return validateString(r["zero"]);
97
94
  }
98
95
  }
99
96
 
@@ -115,9 +112,9 @@ class Translations extends Base {
115
112
  * Set a text for a key
116
113
  *
117
114
  * ```
118
- * translations.setText("text1": "Make my day!");
115
+ * translations.setText("text1", "Make my day!");
119
116
  * // plural rules
120
- * translations.setText("text6": {
117
+ * translations.setText("text6", {
121
118
  * "zero": "There are no files on Disk.",
122
119
  * "one": "There is one file on Disk.",
123
120
  * "other": "There are files on Disk."
@@ -131,26 +128,24 @@ class Translations extends Base {
131
128
  * @throws {TypeError} value is not a string or object
132
129
  */
133
130
  setText(key, text) {
134
-
135
131
  if (isString(text) || isObject(text)) {
136
132
  this.storage.set(validateString(key), text);
137
133
  return this;
138
134
  }
139
135
 
140
- throw new TypeError('value is not a string or object');
141
-
136
+ throw new TypeError("value is not a string or object");
142
137
  }
143
138
 
144
139
  /**
145
- * This method can be used to transfer overlays from an object. The keys are transferred, and the values are entered
140
+ * This method can be used to transfer overlays from an object. The keys are transferred, and the values are entered
146
141
  * as text.
147
- *
142
+ *
148
143
  * The values can either be character strings or, in the case of texts with plural forms, objects. The plural forms
149
144
  * must be stored as text via a standard key "zero", "one", "two", "few", "many" and "other".
150
- *
145
+ *
151
146
  * Additionally, the key default can be specified, which will be used if no other key fits.
152
- *
153
- * In some languages, like for example in German, there is no own more number at the value 0. In these languages,
147
+ *
148
+ * In some languages, like for example in German, there is no own more number at the value 0. In these languages,
154
149
  * the function applies additionally zero.
155
150
  *
156
151
  * ```
@@ -176,7 +171,5 @@ class Translations extends Base {
176
171
  }
177
172
 
178
173
  return this;
179
-
180
174
  }
181
-
182
175
  }
@@ -5,12 +5,12 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {getGlobalObject} from "../../types/global.mjs";
9
- import {Handler} from '../handler.mjs';
10
- import {LogEntry} from "../logentry.mjs";
11
- import {TRACE, WARN, DEBUG, ERROR, FATAL, INFO} from "../logger.mjs";
8
+ import { getGlobalObject } from "../../types/global.mjs";
9
+ import { Handler } from "../handler.mjs";
10
+ import { LogEntry } from "../logentry.mjs";
11
+ import { TRACE, WARN, DEBUG, ERROR, FATAL, INFO } from "../logger.mjs";
12
12
 
13
- export {ConsoleHandler}
13
+ export { ConsoleHandler };
14
14
 
15
15
  /**
16
16
  * You can create an object of the class simply by using the namespace `new Monster.Logging.Handler.ConsoleHandler()`.
@@ -36,7 +36,7 @@ class ConsoleHandler extends Handler {
36
36
  */
37
37
  log(entry) {
38
38
  if (super.log(entry)) {
39
- let console = getGlobalObject('console');
39
+ let console = getGlobalObject("console");
40
40
  if (!console) return false;
41
41
 
42
42
  if (!console.error) console.error = console.log;
@@ -58,7 +58,6 @@ class ConsoleHandler extends Handler {
58
58
  default:
59
59
  console.log(entry.toString());
60
60
  break;
61
-
62
61
  }
63
62
 
64
63
  return true;
@@ -66,7 +65,4 @@ class ConsoleHandler extends Handler {
66
65
 
67
66
  return false;
68
67
  }
69
-
70
68
  }
71
-
72
-
@@ -5,12 +5,12 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {Base} from '../types/base.mjs';
9
- import {validateInstance, validateInteger} from "../types/validate.mjs";
10
- import {LogEntry} from "./logentry.mjs";
11
- import {ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN} from "./logger.mjs";
8
+ import { Base } from "../types/base.mjs";
9
+ import { validateInstance, validateInteger } from "../types/validate.mjs";
10
+ import { LogEntry } from "./logentry.mjs";
11
+ import { ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN } from "./logger.mjs";
12
12
 
13
- export {Handler}
13
+ export { Handler };
14
14
 
15
15
  /**
16
16
  * The log handler is the interface between the log entries and the log listeners.
@@ -20,7 +20,7 @@ export {Handler}
20
20
  * @copyright schukai GmbH
21
21
  * @memberOf Monster.Logging
22
22
  */
23
- class Handler extends Base {
23
+ class Handler extends Base {
24
24
  constructor() {
25
25
  super();
26
26
 
@@ -59,7 +59,7 @@ export {Handler}
59
59
  * @since 1.5.0
60
60
  */
61
61
  setLogLevel(loglevel) {
62
- validateInteger(loglevel)
62
+ validateInteger(loglevel);
63
63
  this.loglevel = loglevel;
64
64
  return this;
65
65
  }
@@ -83,7 +83,7 @@ export {Handler}
83
83
  setAll() {
84
84
  this.setLogLevel(ALL);
85
85
  return this;
86
- };
86
+ }
87
87
 
88
88
  /**
89
89
  * Set log level to Trace
@@ -94,7 +94,7 @@ export {Handler}
94
94
  setTrace() {
95
95
  this.setLogLevel(TRACE);
96
96
  return this;
97
- };
97
+ }
98
98
 
99
99
  /**
100
100
  * Set log level to Debug
@@ -105,7 +105,7 @@ export {Handler}
105
105
  setDebug() {
106
106
  this.setLogLevel(DEBUG);
107
107
  return this;
108
- };
108
+ }
109
109
 
110
110
  /**
111
111
  * Set log level to Info
@@ -116,7 +116,7 @@ export {Handler}
116
116
  setInfo() {
117
117
  this.setLogLevel(INFO);
118
118
  return this;
119
- };
119
+ }
120
120
 
121
121
  /**
122
122
  * Set log level to Warn
@@ -127,7 +127,7 @@ export {Handler}
127
127
  setWarn() {
128
128
  this.setLogLevel(WARN);
129
129
  return this;
130
- };
130
+ }
131
131
 
132
132
  /**
133
133
  * Set log level to Error
@@ -138,7 +138,7 @@ export {Handler}
138
138
  setError() {
139
139
  this.setLogLevel(ERROR);
140
140
  return this;
141
- };
141
+ }
142
142
 
143
143
  /**
144
144
  * Set log level to Fatal
@@ -149,8 +149,7 @@ export {Handler}
149
149
  setFatal() {
150
150
  this.setLogLevel(FATAL);
151
151
  return this;
152
- };
153
-
152
+ }
154
153
 
155
154
  /**
156
155
  * Set log level to Off
@@ -161,7 +160,5 @@ export {Handler}
161
160
  setOff() {
162
161
  this.setLogLevel(OFF);
163
162
  return this;
164
- };
165
-
166
-
163
+ }
167
164
  }
@@ -5,10 +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 '../types/base.mjs';
9
- import {validateInteger} from '../types/validate.mjs';
8
+ import { Base } from "../types/base.mjs";
9
+ import { validateInteger } from "../types/validate.mjs";
10
10
 
11
- export {LogEntry}
11
+ export { LogEntry };
12
12
 
13
13
  /**
14
14
  * A log entry for the logger
@@ -18,7 +18,7 @@ export {LogEntry}
18
18
  * @copyright schukai GmbH
19
19
  * @memberOf Monster.Logging
20
20
  */
21
- class LogEntry extends Base {
21
+ class LogEntry extends Base {
22
22
  /**
23
23
  *
24
24
  * @param {Integer} loglevel
@@ -28,8 +28,8 @@ export {LogEntry}
28
28
  super();
29
29
  validateInteger(loglevel);
30
30
 
31
- this.loglevel = loglevel
32
- this.arguments = args
31
+ this.loglevel = loglevel;
32
+ this.arguments = args;
33
33
  }
34
34
 
35
35
  /**
@@ -37,7 +37,7 @@ export {LogEntry}
37
37
  * @returns {integerr}
38
38
  */
39
39
  getLogLevel() {
40
- return this.loglevel
40
+ return this.loglevel;
41
41
  }
42
42
 
43
43
  /**
@@ -45,7 +45,6 @@ export {LogEntry}
45
45
  * @returns {array}
46
46
  */
47
47
  getArguments() {
48
- return this.arguments
48
+ return this.arguments;
49
49
  }
50
-
51
50
  }
@@ -5,13 +5,13 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {Handler} from '../logging/handler.mjs';
9
- import {LogEntry} from '../logging/logentry.mjs';
8
+ import { Handler } from "../logging/handler.mjs";
9
+ import { LogEntry } from "../logging/logentry.mjs";
10
10
 
11
- import {Base} from '../types/base.mjs';
12
- import {validateInteger, validateObject, validateString} from '../types/validate.mjs';
11
+ import { Base } from "../types/base.mjs";
12
+ import { validateInteger, validateObject, validateString } from "../types/validate.mjs";
13
13
 
14
- export {Logger, ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF};
14
+ export { Logger, ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF };
15
15
 
16
16
  /**
17
17
  * ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
@@ -71,13 +71,12 @@ const OFF = 0;
71
71
  * @memberOf Monster.Logging
72
72
  */
73
73
  class Logger extends Base {
74
-
75
74
  /**
76
75
  *
77
76
  */
78
77
  constructor() {
79
78
  super();
80
- this.handler = new Set;
79
+ this.handler = new Set();
81
80
  }
82
81
 
83
82
  /**
@@ -87,12 +86,12 @@ class Logger extends Base {
87
86
  * @throws {Error} the handler must be an instance of Handler
88
87
  */
89
88
  addHandler(handler) {
90
- validateObject(handler)
89
+ validateObject(handler);
91
90
  if (!(handler instanceof Handler)) {
92
- throw new Error("the handler must be an instance of Handler")
91
+ throw new Error("the handler must be an instance of Handler");
93
92
  }
94
93
 
95
- this.handler.add(handler)
94
+ this.handler.add(handler);
96
95
  return this;
97
96
  }
98
97
 
@@ -103,9 +102,9 @@ class Logger extends Base {
103
102
  * @throws {Error} the handler must be an instance of Handler
104
103
  */
105
104
  removeHandler(handler) {
106
- validateObject(handler)
105
+ validateObject(handler);
107
106
  if (!(handler instanceof Handler)) {
108
- throw new Error("the handler must be an instance of Handler")
107
+ throw new Error("the handler must be an instance of Handler");
109
108
  }
110
109
 
111
110
  this.handler.delete(handler);
@@ -121,10 +120,14 @@ class Logger extends Base {
121
120
  * @returns {Logger}
122
121
  * @since 1.5.0
123
122
  */
124
- logTrace() {
125
- triggerLog.apply(this, [TRACE, ...arguments]);
123
+ logTrace(...args) {
124
+ if (typeof args !== "object" || args[0] === null) {
125
+ throw new Error("the first argument must be an object");
126
+ }
127
+
128
+ triggerLog.apply(this, [TRACE, ...args]);
126
129
  return this;
127
- };
130
+ }
128
131
 
129
132
  /**
130
133
  * log Debug message
@@ -135,10 +138,14 @@ class Logger extends Base {
135
138
  * @returns {Logger}
136
139
  * @since 1.5.0
137
140
  */
138
- logDebug() {
139
- triggerLog.apply(this, [DEBUG, ...arguments]);
141
+ logDebug(...args) {
142
+ if (typeof args !== "object" || args[0] === null) {
143
+ throw new Error("the first argument must be an object");
144
+ }
145
+
146
+ triggerLog.apply(this, [DEBUG, ...args]);
140
147
  return this;
141
- };
148
+ }
142
149
 
143
150
  /**
144
151
  * log Info message
@@ -150,10 +157,14 @@ class Logger extends Base {
150
157
  * @returns {Logger}
151
158
  * @since 1.5.0
152
159
  */
153
- logInfo() {
154
- triggerLog.apply(this, [INFO, ...arguments]);
160
+ logInfo(...args) {
161
+ if (typeof args !== "object" || args[0] === null) {
162
+ throw new Error("the first argument must be an object");
163
+ }
164
+
165
+ triggerLog.apply(this, [INFO, ...args]);
155
166
  return this;
156
- };
167
+ }
157
168
 
158
169
  /**
159
170
  * log Warn message
@@ -164,10 +175,14 @@ class Logger extends Base {
164
175
  * @returns {Logger}
165
176
  * @since 1.5.0
166
177
  */
167
- logWarn() {
168
- triggerLog.apply(this, [WARN, ...arguments]);
178
+ logWarn(...args) {
179
+ if (typeof args !== "object" || args[0] === null) {
180
+ throw new Error("the first argument must be an object");
181
+ }
182
+
183
+ triggerLog.apply(this, [WARN, ...args]);
169
184
  return this;
170
- };
185
+ }
171
186
 
172
187
  /**
173
188
  * log Error message
@@ -178,10 +193,14 @@ class Logger extends Base {
178
193
  * @returns {Logger}
179
194
  * @since 1.5.0
180
195
  */
181
- logError() {
182
- triggerLog.apply(this, [ERROR, ...arguments]);
196
+ logError(...args) {
197
+ if (typeof args !== "object" || args[0] === null) {
198
+ throw new Error("the first argument must be an object");
199
+ }
200
+
201
+ triggerLog.apply(this, [ERROR, ...args]);
183
202
  return this;
184
- };
203
+ }
185
204
 
186
205
  /**
187
206
  * log Fatal message
@@ -192,11 +211,14 @@ class Logger extends Base {
192
211
  * @returns {Logger}
193
212
  * @since 1.5.0
194
213
  */
195
- logFatal() {
196
- triggerLog.apply(this, [FATAL, ...arguments]);
197
- return this;
198
- };
214
+ logFatal(...args) {
215
+ if (typeof args !== "object" || args[0] === null) {
216
+ throw new Error("the first argument must be an object");
217
+ }
199
218
 
219
+ triggerLog.apply(this, [FATAL, ...args]);
220
+ return this;
221
+ }
200
222
 
201
223
  /**
202
224
  * Labels
@@ -207,17 +229,17 @@ class Logger extends Base {
207
229
  getLabel(level) {
208
230
  validateInteger(level);
209
231
 
210
- if (level === ALL) return 'ALL';
211
- if (level === TRACE) return 'TRACE';
212
- if (level === DEBUG) return 'DEBUG';
213
- if (level === INFO) return 'INFO';
214
- if (level === WARN) return 'WARN';
215
- if (level === ERROR) return 'ERROR';
216
- if (level === FATAL) return 'FATAL';
217
- if (level === OFF) return 'OFF';
232
+ if (level === ALL) return "ALL";
233
+ if (level === TRACE) return "TRACE";
234
+ if (level === DEBUG) return "DEBUG";
235
+ if (level === INFO) return "INFO";
236
+ if (level === WARN) return "WARN";
237
+ if (level === ERROR) return "ERROR";
238
+ if (level === FATAL) return "FATAL";
239
+ if (level === OFF) return "OFF";
218
240
 
219
- return 'unknown';
220
- };
241
+ return "unknown";
242
+ }
221
243
 
222
244
  /**
223
245
  * Level
@@ -228,22 +250,19 @@ class Logger extends Base {
228
250
  getLevel(label) {
229
251
  validateString(label);
230
252
 
231
- if (label === 'ALL') return ALL;
232
- if (label === 'TRACE') return TRACE;
233
- if (label === 'DEBUG') return DEBUG;
234
- if (label === 'INFO') return INFO;
235
- if (label === 'WARN') return WARN;
236
- if (label === 'ERROR') return ERROR;
237
- if (label === 'FATAL') return FATAL;
238
- if (label === 'OFF') return OFF;
253
+ if (label === "ALL") return ALL;
254
+ if (label === "TRACE") return TRACE;
255
+ if (label === "DEBUG") return DEBUG;
256
+ if (label === "INFO") return INFO;
257
+ if (label === "WARN") return WARN;
258
+ if (label === "ERROR") return ERROR;
259
+ if (label === "FATAL") return FATAL;
260
+ if (label === "OFF") return OFF;
239
261
 
240
262
  return 0;
241
- };
242
-
243
-
263
+ }
244
264
  }
245
265
 
246
-
247
266
  /**
248
267
  * Log triggern
249
268
  *
@@ -256,9 +275,8 @@ function triggerLog(loglevel, ...args) {
256
275
  var logger = this;
257
276
 
258
277
  for (let handler of logger.handler) {
259
- handler.log(new LogEntry(loglevel, args))
278
+ handler.log(new LogEntry(loglevel, args));
260
279
  }
261
280
 
262
281
  return logger;
263
-
264
282
  }
@@ -10,4 +10,4 @@
10
10
  * @memberOf Monster
11
11
  * @author schukai GmbH
12
12
  */
13
- const ns = {};
13
+ const ns = {};