@schukai/monster 1.21.1 → 1.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/CHANGELOG +48 -1
  2. package/README.md +4 -4
  3. package/dist/modules/constants.js +2 -2
  4. package/dist/modules/constraints/abstract.js +1 -1
  5. package/dist/modules/constraints/abstractoperator.js +1 -1
  6. package/dist/modules/constraints/andoperator.js +1 -1
  7. package/dist/modules/constraints/invalid.js +1 -1
  8. package/dist/modules/constraints/isarray.js +1 -1
  9. package/dist/modules/constraints/isobject.js +1 -1
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +1 -1
  12. package/dist/modules/constraints/valid.js +1 -1
  13. package/dist/modules/data/buildmap.js +1 -1
  14. package/dist/modules/data/datasource/namespace.js +2 -0
  15. package/dist/modules/data/datasource/restapi/writeerror.js +2 -0
  16. package/dist/modules/data/datasource/restapi.js +2 -0
  17. package/dist/modules/data/datasource/storage/localstorage.js +2 -0
  18. package/dist/modules/data/datasource/storage/namespace.js +2 -0
  19. package/dist/modules/data/datasource/storage/sessionstorage.js +2 -0
  20. package/dist/modules/data/datasource/storage.js +2 -0
  21. package/dist/modules/data/datasource.js +2 -0
  22. package/dist/modules/data/diff.js +2 -2
  23. package/dist/modules/data/extend.js +1 -1
  24. package/dist/modules/data/namespace.js +1 -1
  25. package/dist/modules/data/pathfinder.js +2 -2
  26. package/dist/modules/data/pipe.js +1 -1
  27. package/dist/modules/data/transformer.js +2 -2
  28. package/dist/modules/dom/assembler.js +1 -1
  29. package/dist/modules/dom/attributes.js +1 -1
  30. package/dist/modules/dom/constants.js +2 -2
  31. package/dist/modules/dom/customcontrol.js +2 -2
  32. package/dist/modules/dom/customelement.js +2 -2
  33. package/dist/modules/dom/events.js +1 -1
  34. package/dist/modules/dom/focusmanager.js +2 -0
  35. package/dist/modules/dom/locale.js +1 -1
  36. package/dist/modules/dom/namespace.js +1 -1
  37. package/dist/modules/dom/resource/data.js +2 -0
  38. package/dist/modules/dom/resource/link/stylesheet.js +2 -0
  39. package/dist/modules/dom/resource/link.js +2 -0
  40. package/dist/modules/dom/resource/script.js +2 -0
  41. package/dist/modules/dom/resource.js +2 -0
  42. package/dist/modules/dom/resourcemanager.js +2 -0
  43. package/dist/modules/dom/template.js +1 -1
  44. package/dist/modules/dom/theme.js +1 -1
  45. package/dist/modules/dom/updater.js +2 -2
  46. package/dist/modules/dom/util.js +1 -1
  47. package/dist/modules/dom/worker/factory.js +2 -0
  48. package/dist/modules/i18n/locale.js +1 -1
  49. package/dist/modules/i18n/namespace.js +1 -1
  50. package/dist/modules/i18n/provider.js +1 -1
  51. package/dist/modules/i18n/providers/fetch.js +2 -2
  52. package/dist/modules/i18n/providers/namespace.js +1 -1
  53. package/dist/modules/i18n/translations.js +1 -1
  54. package/dist/modules/logging/handler/console.js +1 -1
  55. package/dist/modules/logging/handler/namespace.js +1 -1
  56. package/dist/modules/logging/handler.js +1 -1
  57. package/dist/modules/logging/logentry.js +1 -1
  58. package/dist/modules/logging/logger.js +1 -1
  59. package/dist/modules/logging/namespace.js +1 -1
  60. package/dist/modules/math/namespace.js +1 -1
  61. package/dist/modules/math/random.js +2 -2
  62. package/dist/modules/monster.js +1 -1
  63. package/dist/modules/namespace.js +1 -1
  64. package/dist/modules/text/formatter.js +2 -2
  65. package/dist/modules/text/namespace.js +1 -1
  66. package/dist/modules/types/base.js +1 -1
  67. package/dist/modules/types/basewithoptions.js +2 -2
  68. package/dist/modules/types/binary.js +1 -1
  69. package/dist/modules/types/dataurl.js +1 -1
  70. package/dist/modules/types/global.js +1 -1
  71. package/dist/modules/types/id.js +1 -1
  72. package/dist/modules/types/is.js +1 -1
  73. package/dist/modules/types/mediatype.js +1 -1
  74. package/dist/modules/types/namespace.js +1 -1
  75. package/dist/modules/types/observer.js +1 -1
  76. package/dist/modules/types/observerlist.js +2 -2
  77. package/dist/modules/types/proxyobserver.js +2 -2
  78. package/dist/modules/types/queue.js +1 -1
  79. package/dist/modules/types/randomid.js +1 -1
  80. package/dist/modules/types/stack.js +1 -1
  81. package/dist/modules/types/tokenlist.js +2 -2
  82. package/dist/modules/types/typeof.js +1 -1
  83. package/dist/modules/types/uniquequeue.js +1 -1
  84. package/dist/modules/types/uuid.js +2 -0
  85. package/dist/modules/types/validate.js +1 -1
  86. package/dist/modules/types/version.js +2 -2
  87. package/dist/modules/util/clone.js +2 -2
  88. package/dist/modules/util/comparator.js +2 -2
  89. package/dist/modules/util/freeze.js +1 -1
  90. package/dist/modules/util/namespace.js +1 -1
  91. package/dist/modules/util/processing.js +2 -2
  92. package/dist/modules/util/trimspaces.js +2 -0
  93. package/dist/monster.dev.js +1499 -732
  94. package/dist/monster.dev.js.map +1 -1
  95. package/dist/monster.js +2 -2
  96. package/package.json +1 -1
  97. package/source/constants.js +16 -7
  98. package/source/constraints/andoperator.js +5 -5
  99. package/source/constraints/invalid.js +3 -3
  100. package/source/constraints/isarray.js +3 -3
  101. package/source/constraints/isobject.js +3 -3
  102. package/source/constraints/oroperator.js +5 -5
  103. package/source/constraints/valid.js +3 -3
  104. package/source/data/buildmap.js +6 -6
  105. package/source/data/datasource/namespace.js +16 -0
  106. package/source/data/datasource/restapi/writeerror.js +49 -0
  107. package/source/data/datasource/restapi.js +266 -0
  108. package/source/data/datasource/storage/localstorage.js +64 -0
  109. package/source/data/datasource/storage/namespace.js +16 -0
  110. package/source/data/datasource/storage/sessionstorage.js +61 -0
  111. package/source/data/datasource/storage.js +131 -0
  112. package/source/data/datasource.js +246 -0
  113. package/source/data/diff.js +8 -8
  114. package/source/data/extend.js +5 -5
  115. package/source/data/pathfinder.js +12 -6
  116. package/source/data/pipe.js +6 -5
  117. package/source/data/transformer.js +131 -24
  118. package/source/dom/assembler.js +2 -2
  119. package/source/dom/attributes.js +24 -24
  120. package/source/dom/constants.js +305 -12
  121. package/source/dom/customcontrol.js +40 -19
  122. package/source/dom/customelement.js +182 -103
  123. package/source/dom/events.js +6 -6
  124. package/source/dom/focusmanager.js +251 -0
  125. package/source/dom/locale.js +4 -3
  126. package/source/dom/resource/data.js +170 -0
  127. package/source/dom/resource/link/stylesheet.js +54 -0
  128. package/source/dom/resource/link.js +125 -0
  129. package/source/dom/resource/script.js +112 -0
  130. package/source/dom/resource.js +268 -0
  131. package/source/dom/resourcemanager.js +214 -0
  132. package/source/dom/template.js +40 -10
  133. package/source/dom/theme.js +3 -3
  134. package/source/dom/updater.js +114 -58
  135. package/source/dom/util.js +6 -6
  136. package/source/dom/worker/factory.js +134 -0
  137. package/source/i18n/locale.js +8 -8
  138. package/source/i18n/provider.js +4 -4
  139. package/source/i18n/providers/fetch.js +8 -13
  140. package/source/i18n/translations.js +6 -5
  141. package/source/logging/handler/console.js +2 -2
  142. package/source/logging/handler.js +2 -2
  143. package/source/logging/logentry.js +2 -2
  144. package/source/logging/logger.js +4 -4
  145. package/source/math/random.js +11 -5
  146. package/source/namespace.js +1 -1
  147. package/source/text/formatter.js +82 -7
  148. package/source/types/base.js +4 -4
  149. package/source/types/basewithoptions.js +10 -15
  150. package/source/types/binary.js +8 -8
  151. package/source/types/dataurl.js +6 -6
  152. package/source/types/global.js +9 -7
  153. package/source/types/id.js +2 -2
  154. package/source/types/is.js +23 -23
  155. package/source/types/mediatype.js +4 -4
  156. package/source/types/observer.js +3 -3
  157. package/source/types/observerlist.js +3 -3
  158. package/source/types/proxyobserver.js +24 -7
  159. package/source/types/queue.js +5 -5
  160. package/source/types/randomid.js +2 -2
  161. package/source/types/stack.js +2 -2
  162. package/source/types/tokenlist.js +8 -9
  163. package/source/types/typeof.js +3 -3
  164. package/source/types/uniquequeue.js +4 -4
  165. package/source/types/uuid.js +102 -0
  166. package/source/types/validate.js +20 -20
  167. package/source/types/version.js +6 -6
  168. package/source/util/clone.js +5 -6
  169. package/source/util/comparator.js +5 -5
  170. package/source/util/freeze.js +5 -5
  171. package/source/util/processing.js +33 -36
  172. package/source/util/trimspaces.js +85 -0
  173. package/test/cases/data/datasource/restapi.js +89 -0
  174. package/test/cases/data/datasource/storage/localstorage.js +47 -0
  175. package/test/cases/data/datasource/storage/sessionstorage.js +47 -0
  176. package/test/cases/data/datasource.js +60 -0
  177. package/test/cases/data/diff.js +4 -4
  178. package/test/cases/data/pathfinder.js +18 -9
  179. package/test/cases/data/pipe.js +26 -2
  180. package/test/cases/data/transformer.js +41 -10
  181. package/test/cases/dom/customcontrol.js +6 -5
  182. package/test/cases/dom/customelement.js +25 -26
  183. package/test/cases/dom/focusmanager.js +111 -0
  184. package/test/cases/dom/locale.js +1 -4
  185. package/test/cases/dom/resource/data.js +129 -0
  186. package/test/cases/dom/resource/link/stylesheet.js +101 -0
  187. package/test/cases/dom/resource/link.js +101 -0
  188. package/test/cases/dom/resource/script.js +115 -0
  189. package/test/cases/dom/resourcemanager.js +118 -0
  190. package/test/cases/dom/updater.js +42 -19
  191. package/test/cases/dom/worker/factory.js +63 -0
  192. package/test/cases/monster.js +1 -1
  193. package/test/cases/text/formatter.js +38 -6
  194. package/test/cases/types/proxyobserver.js +55 -11
  195. package/test/cases/types/uuid.js +42 -0
  196. package/test/cases/util/freeze.js +30 -4
  197. package/test/cases/util/trimspaces.js +24 -0
  198. package/test/util/cleanupdom.js +48 -0
  199. package/test/util/jsdom.js +23 -9
  200. package/test/util/localstorage.js +81 -0
  201. package/test/web/import.js +13 -0
  202. package/test/web/monster-dev.html +3 -3
  203. package/test/web/monster.html +2 -2
  204. package/test/web/test.html +3 -3
  205. package/test/web/tests.js +7 -7
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- import {PROPERTY_KEY_INTERNALDATA} from "../../constants.js";
4
- import {extend} from "../../data/extend.js";
5
3
  /**
6
4
  * @author schukai GmbH
7
5
  */
6
+
7
+ import {internalSymbol} from "../../constants.js";
8
+ import {extend} from "../../data/extend.js";
8
9
  import {assignToNamespace, Monster} from '../../namespace.js';
9
10
  import {Formatter} from "../../text/formatter.js";
10
11
  import {getGlobalFunction} from "../../types/global.js";
@@ -14,12 +15,6 @@ import {parseLocale} from "../locale.js";
14
15
  import {Provider} from "../provider.js";
15
16
  import {Translations} from "../translations.js";
16
17
 
17
- /**
18
- * @private
19
- * @type {symbol}
20
- */
21
- const optionsSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
22
-
23
18
  /**
24
19
  * The fetch provider retrieves a JSON file from the given URL and returns a translation object.
25
20
  *
@@ -27,8 +22,8 @@ const optionsSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
27
22
  *
28
23
  * ```
29
24
  * <script type="module">
30
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/i18n/providers/fetch.js';
31
- * console.log(new Monster.I18n.Providers.Fetch())
25
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/i18n/providers/fetch.js';
26
+ * new Monster.I18n.Providers.Fetch()
32
27
  * </script>
33
28
  * ```
34
29
  *
@@ -36,8 +31,8 @@ const optionsSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
36
31
  *
37
32
  * ```
38
33
  * <script type="module">
39
- * import {Fetch} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/i18n/providers/fetch.js';
40
- * console.log(new Fetch())
34
+ * import {Fetch} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/i18n/providers/fetch.js';
35
+ * new Fetch()
41
36
  * </script>
42
37
  * ```
43
38
  *
@@ -77,7 +72,7 @@ class Fetch extends Provider {
77
72
  * @private
78
73
  * @property {Object} options
79
74
  */
80
- this[optionsSymbol] = extend({}, super.defaults, this.defaults, validateObject(options));
75
+ this[internalSymbol] = extend({}, super.defaults, this.defaults, validateObject(options));
81
76
 
82
77
  }
83
78
 
@@ -17,8 +17,8 @@ import {Locale, parseLocale} from "./locale.js";
17
17
  *
18
18
  * ```
19
19
  * <script type="module">
20
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/i18n/translations.js';
21
- * console.log(new Monster.I18n.Translations())
20
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/i18n/translations.js';
21
+ * new Monster.I18n.Translations()
22
22
  * </script>
23
23
  * ```
24
24
  *
@@ -26,13 +26,14 @@ import {Locale, parseLocale} from "./locale.js";
26
26
  *
27
27
  * ```
28
28
  * <script type="module">
29
- * import {Translations} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/i18n/translations.js';
30
- * console.log(new Translations())
29
+ * import {Translations} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/i18n/translations.js';
30
+ * new Translations()
31
31
  * </script>
32
32
  * ```
33
33
  *
34
34
  * @example
35
35
  *
36
+ * import {Translations} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/i18n/translations.js';
36
37
  * const translation = new Translations(parseLocale('en-GB'));
37
38
  *
38
39
  * translation.assignTranslations({
@@ -41,7 +42,7 @@ import {Locale, parseLocale} from "./locale.js";
41
42
  * });
42
43
  *
43
44
  * translation.getText('text1);
44
- * translation.getPluralRuleText('text1',2);
45
+ * translation.getPluralRuleText('text2',2);
45
46
  *
46
47
  * @since 1.13.0
47
48
  * @copyright schukai GmbH
@@ -15,7 +15,7 @@ import {LogEntry} from "../logentry.js";
15
15
  *
16
16
  * ```
17
17
  * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/logging/handler/console.js';
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/logging/handler/console.js';
19
19
  * console.log(new Monster.Logging.Handler.ConsoleHandler())
20
20
  * </script>
21
21
  * ```
@@ -24,7 +24,7 @@ import {LogEntry} from "../logentry.js";
24
24
  *
25
25
  * ```
26
26
  * <script type="module">
27
- * import {ConsoleHandler} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/logging/handler/console.js';
27
+ * import {ConsoleHandler} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/logging/handler/console.js';
28
28
  * console.log(new ConsoleHandler())
29
29
  * </script>
30
30
  * ```
@@ -15,7 +15,7 @@ import {ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN} from "./logger.js";
15
15
  *
16
16
  * ```
17
17
  * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/logging/handler.js';
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/logging/handler.js';
19
19
  * console.log(new Monster.Logging.Handler())
20
20
  * </script>
21
21
  * ```
@@ -24,7 +24,7 @@ import {ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN} from "./logger.js";
24
24
  *
25
25
  * ```
26
26
  * <script type="module">
27
- * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/logging/handler.js';
27
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/logging/handler.js';
28
28
  * console.log(new Handler())
29
29
  * </script>
30
30
  * ```
@@ -14,7 +14,7 @@ import {validateInteger} from '../types/validate.js';
14
14
  *
15
15
  * ```
16
16
  * <script type="module">
17
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/logging/logentry.js';
17
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/logging/logentry.js';
18
18
  * console.log(new Monster.Logging.LogEntry())
19
19
  * </script>
20
20
  * ```
@@ -23,7 +23,7 @@ import {validateInteger} from '../types/validate.js';
23
23
  *
24
24
  * ```
25
25
  * <script type="module">
26
- * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/logging/logentry.js';
26
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/logging/logentry.js';
27
27
  * console.log(new LogEntry())
28
28
  * </script>
29
29
  * ```
@@ -65,8 +65,8 @@ const OFF = 0;
65
65
  *
66
66
  * ```
67
67
  * <script type="module">
68
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/logging/logger.js';
69
- * console.log(new Monster.Logging.Logger())
68
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/logging/logger.js';
69
+ * new Monster.Logging.Logger()
70
70
  * </script>
71
71
  * ```
72
72
  *
@@ -74,8 +74,8 @@ const OFF = 0;
74
74
  *
75
75
  * ```
76
76
  * <script type="module">
77
- * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/logging/logger.js';
78
- * console.log(new Logger())
77
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/logging/logger.js';
78
+ * new Logger()
79
79
  * </script>
80
80
  * ```
81
81
  *
@@ -15,8 +15,9 @@ import {getGlobal} from '../types/global.js';
15
15
  *
16
16
  * ```
17
17
  * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/math/random.js';
19
- * console.log(Monster.Math.random(1,10)) // ↦ 5
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/math/random.js';
19
+ * Monster.Math.random(1,10)
20
+ * // ↦ 5
20
21
  * </script>
21
22
  * ```
22
23
  *
@@ -24,8 +25,9 @@ import {getGlobal} from '../types/global.js';
24
25
  *
25
26
  * ```
26
27
  * <script type="module">
27
- * import {random} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/math/random.js';
28
- * console.log(random(1,10)) // ↦ 5
28
+ * import {random} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/math/random.js';
29
+ * random(1,10)
30
+ * // ↦ 5
29
31
  * </script>
30
32
  * ```
31
33
  *
@@ -116,7 +118,11 @@ function create(min, max) {
116
118
  return create(min, max);
117
119
  }
118
120
 
119
- return min + rval;
121
+ if (rval < min) {
122
+ rval += min;
123
+ }
124
+
125
+ return rval;
120
126
 
121
127
  }
122
128
 
@@ -65,7 +65,7 @@ export const Monster = new Namespace("Monster");
65
65
  *
66
66
  * ```
67
67
  * <script type="module">
68
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/namespace.js';
68
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/namespace.js';
69
69
  * function hello() {
70
70
  * console.log('Hello World!');
71
71
  * }
@@ -18,8 +18,8 @@ import {validateObject, validateString} from "../types/validate.js";
18
18
  *
19
19
  * ```
20
20
  * <script type="module">
21
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/text/formatter.js';
22
- * console.log(new Monster.Text.Formatter())
21
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/text/formatter.js';
22
+ * new Monster.Text.Formatter()
23
23
  * </script>
24
24
  * ```
25
25
  *
@@ -27,13 +27,30 @@ import {validateObject, validateString} from "../types/validate.js";
27
27
  *
28
28
  * ```
29
29
  * <script type="module">
30
- * import {Formatter} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/text/formatter.js';
31
- * console.log(new Formatter())
30
+ * import {Formatter} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/text/formatter.js';
31
+ * new Formatter()
32
32
  * </script>
33
33
  * ```
34
34
  *
35
+ * ## Marker in marker
36
+ *
37
+ * Markers can be nested. Here, the inner marker is resolved first and then the outer marker.
38
+ *
39
+ * ```
40
+ *
41
+ * ```
42
+ *
43
+ * ## Marker with parameter
44
+ *
45
+ * A string can also bring its own values. These must then be separated from the key by a separator `::`.
46
+ * The values themselves must be specified in key/value pairs. The key must be separated from the value by a separator `=`.
47
+ *
48
+ * When using a pipe, you must pay attention to the separators.
49
+ *
35
50
  * @example
36
51
  *
52
+ * import {Formatter} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/text/formatter.js';
53
+ *
37
54
  * new Formatter({
38
55
  * a: {
39
56
  * b: {
@@ -59,9 +76,44 @@ class Formatter extends Base {
59
76
  */
60
77
  constructor(object) {
61
78
  super();
79
+ if (object === undefined) {
80
+ object = {};
81
+ }
62
82
  this.object = validateObject(object);
63
83
  this.openMarker = '${';
64
84
  this.closeMarker = '}';
85
+ this.parameterDelimiter = '::';
86
+ this.parameterAssignment = '=';
87
+ }
88
+
89
+ /**
90
+ * Set new Parameter Character
91
+ *
92
+ * Default values for the chars are `::` and `=`
93
+ *
94
+ * ```
95
+ * formatter.setParameterChars('#');
96
+ * formatter.setParameterChars('[',']');
97
+ * formatter.setParameterChars('i18n{','}');
98
+ * ```
99
+ *
100
+ * @param {string} delimiter
101
+ * @param {string} assignment
102
+ * @return {Formatter}
103
+ * @since 1.24.0
104
+ * @throws {TypeError} value is not a string
105
+ */
106
+ setParameterChars(delimiter, assignment) {
107
+
108
+ if (delimiter !== undefined) {
109
+ this.parameterDelimiter = validateString(delimiter);
110
+ }
111
+
112
+ if (assignment !== undefined) {
113
+ this.parameterAssignment = validateString(assignment);
114
+ }
115
+
116
+ return this;
65
117
  }
66
118
 
67
119
  /**
@@ -128,16 +180,39 @@ function tokenizer(text) {
128
180
  text = text.substring(startIndex)
129
181
  }
130
182
 
131
- let endIndex = text.substring(self.openMarker.length).indexOf(self.closeMarker) + self.openMarker.length;
183
+ let endIndex = text.substring(self.openMarker.length).indexOf(self.closeMarker);
184
+ if (endIndex !== -1) endIndex += self.openMarker.length;
185
+ let insideStartIndex = text.substring(self.openMarker.length).indexOf(self.openMarker);
186
+ if (insideStartIndex !== -1) {
187
+ insideStartIndex += self.openMarker.length;
188
+ if (insideStartIndex < endIndex) {
189
+ let sub = text.substring(insideStartIndex);
190
+ let result = tokenizer.call(self, text.substring(insideStartIndex));
191
+ text = text.substring(0, insideStartIndex) + result
192
+ endIndex = text.substring(self.openMarker.length).indexOf(self.closeMarker);
193
+ if (endIndex !== -1) endIndex += self.openMarker.length;
194
+ }
195
+ }
196
+
132
197
 
133
198
  if (endIndex === -1) {
134
199
  throw new Error("syntax error in formatter template")
135
200
  return;
136
201
  }
137
202
 
138
- let command = "path:" + text.substring(self.openMarker.length, endIndex);
203
+ let command = "path:";
204
+ let key = text.substring(self.openMarker.length, endIndex);
205
+ let parts = key.split(self.parameterDelimiter);
206
+ command += parts.shift();
207
+
208
+ const temp = self.object;
209
+
210
+ for (const kv of parts) {
211
+ const [k, v] = kv.split(self.parameterAssignment);
212
+ temp[k] = v;
213
+ }
139
214
 
140
- formatted.push(validateString(new Pipe(command).run(self.object)));
215
+ formatted.push(validateString(new Pipe(command).run(temp)));
141
216
 
142
217
  text = text.substring(endIndex + self.closeMarker.length);
143
218
 
@@ -13,8 +13,8 @@ import {assignToNamespace, Monster} from '../namespace.js';
13
13
  *
14
14
  * ```
15
15
  * <script type="module">
16
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/base.js';
17
- * console.log(new Monster.Types.Base())
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/base.js';
17
+ * new Monster.Types.Base()
18
18
  * </script>
19
19
  * ```
20
20
  *
@@ -22,8 +22,8 @@ import {assignToNamespace, Monster} from '../namespace.js';
22
22
  *
23
23
  * ```
24
24
  * <script type="module">
25
- * import {Base} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/base.js';
26
- * console.log(new Base())
25
+ * import {Base} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/base.js';
26
+ * new Base()
27
27
  * </script>
28
28
  * ```
29
29
  *
@@ -1,21 +1,16 @@
1
1
  'use strict';
2
2
 
3
- import {PROPERTY_KEY_INTERNALDATA} from "../constants.js";
4
- import {extend} from "../data/extend.js";
5
- import {Pathfinder} from "../data/pathfinder.js";
6
3
  /**
7
4
  * @author schukai GmbH
8
5
  */
6
+
7
+ import {internalSymbol} from "../constants.js";
8
+ import {extend} from "../data/extend.js";
9
+ import {Pathfinder} from "../data/pathfinder.js";
9
10
  import {assignToNamespace, Monster} from '../namespace.js';
10
11
  import {Base} from "./base.js";
11
12
  import {validateObject} from "./validate.js";
12
13
 
13
- /**
14
- * @private
15
- * @type {symbol}
16
- */
17
- const optionsSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
18
-
19
14
  /**
20
15
  * This is the base class with options from which some monster classes are derived.
21
16
  *
@@ -23,8 +18,8 @@ const optionsSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
23
18
  *
24
19
  * ```
25
20
  * <script type="module">
26
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/basewithoptions.js';
27
- * console.log(new Monster.Types.BaseWithOptions())
21
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/basewithoptions.js';
22
+ * new Monster.Types.BaseWithOptions()
28
23
  * </script>
29
24
  * ```
30
25
  *
@@ -32,8 +27,8 @@ const optionsSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
32
27
  *
33
28
  * ```
34
29
  * <script type="module">
35
- * import {BaseWithOptions} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/basewithoptions.js';
36
- * console.log(new BaseWithOptions())
30
+ * import {BaseWithOptions} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/basewithoptions.js';
31
+ * new BaseWithOptions()
37
32
  * </script>
38
33
  * ```
39
34
  *
@@ -56,7 +51,7 @@ class BaseWithOptions extends Base {
56
51
  options = {};
57
52
  }
58
53
 
59
- this[optionsSymbol] = extend({}, this.defaults, validateObject(options));
54
+ this[internalSymbol] = extend({}, this.defaults, validateObject(options));
60
55
 
61
56
  }
62
57
 
@@ -81,7 +76,7 @@ class BaseWithOptions extends Base {
81
76
  let value;
82
77
 
83
78
  try {
84
- value = new Pathfinder(this[optionsSymbol]).getVia(path);
79
+ value = new Pathfinder(this[internalSymbol]).getVia(path);
85
80
  } catch (e) {
86
81
 
87
82
  }
@@ -13,8 +13,8 @@ import {Monster, validateString} from "./validate.js";
13
13
  *
14
14
  * ```
15
15
  * <script type="module">
16
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/binary.js';
17
- * console.log(Monster.Types.toBinary())
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/binary.js';
17
+ * Monster.Types.toBinary()
18
18
  * </script>
19
19
  * ```
20
20
  *
@@ -22,8 +22,8 @@ import {Monster, validateString} from "./validate.js";
22
22
  *
23
23
  * ```
24
24
  * <script type="module">
25
- * import {toBinary} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/binary.js';
26
- * console.log(toBinary())
25
+ * import {toBinary} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/binary.js';
26
+ * toBinary()
27
27
  * </script>
28
28
  * ```
29
29
  *
@@ -54,8 +54,8 @@ function toBinary(string) {
54
54
  *
55
55
  * ```
56
56
  * <script type="module">
57
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/binary.js';
58
- * console.log(Monster.Types.fromBinary())
57
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/binary.js';
58
+ * Monster.Types.fromBinary()
59
59
  * </script>
60
60
  * ```
61
61
  *
@@ -63,8 +63,8 @@ function toBinary(string) {
63
63
  *
64
64
  * ```
65
65
  * <script type="module">
66
- * import {fromBinary} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/binary.js';
67
- * console.log(fromBinary())
66
+ * import {fromBinary} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/binary.js';
67
+ * fromBinary()
68
68
  * </script>
69
69
  * ```
70
70
  *
@@ -20,8 +20,8 @@ const internal = Symbol('internal');
20
20
  *
21
21
  * ```
22
22
  * <script type="module">
23
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/dataurl.js';
24
- * console.log(new Monster.Types.DataUrl())
23
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/dataurl.js';
24
+ * new Monster.Types.DataUrl()
25
25
  * </script>
26
26
  * ```
27
27
  *
@@ -29,8 +29,8 @@ const internal = Symbol('internal');
29
29
  *
30
30
  * ```
31
31
  * <script type="module">
32
- * import {DataUrl} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/dataurl.js';
33
- * console.log(new DataUrl())
32
+ * import {DataUrl} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/dataurl.js';
33
+ * new DataUrl()
34
34
  * </script>
35
35
  * ```
36
36
  *
@@ -98,7 +98,7 @@ class DataUrl extends Base {
98
98
  *
99
99
  * ```
100
100
  * <script type="module">
101
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/dataurl.js';
101
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/dataurl.js';
102
102
  * console.log(Monster.Types.parseDataURL())
103
103
  * </script>
104
104
  * ```
@@ -107,7 +107,7 @@ class DataUrl extends Base {
107
107
  *
108
108
  * ```
109
109
  * <script type="module">
110
- * import {parseDataURL} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/dataurl.js';
110
+ * import {parseDataURL} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/dataurl.js';
111
111
  * console.log(parseDataURL())
112
112
  * </script>
113
113
  * ```
@@ -78,8 +78,9 @@ function getGlobal() {
78
78
  *
79
79
  * ```
80
80
  * <script type="module">
81
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/global.js';
82
- * console.log(Monster.Types.getGlobalObject('document')) // ↦ { }
81
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/global.js';
82
+ * Monster.Types.getGlobalObject('document')
83
+ * // ↦ { }
83
84
  * </script>
84
85
  * ```
85
86
  *
@@ -87,8 +88,9 @@ function getGlobal() {
87
88
  *
88
89
  * ```
89
90
  * <script type="module">
90
- * import {getGlobalObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/global.js';
91
- * console.log(getGlobalObject('document')) // ↦ { }
91
+ * import {getGlobalObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/global.js';
92
+ * getGlobalObject('document')
93
+ * // ↦ { }
92
94
  * </script>
93
95
  * ```
94
96
  *
@@ -115,7 +117,7 @@ function getGlobalObject(name) {
115
117
  *
116
118
  * ```
117
119
  * <script type="module">
118
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/global.js';
120
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/global.js';
119
121
  * console.log(Monster.Types.getGlobalFunction('parseInt')) // ↦ f parseInt() { }
120
122
  * </script>
121
123
  * ```
@@ -124,7 +126,7 @@ function getGlobalObject(name) {
124
126
  *
125
127
  * ```
126
128
  * <script type="module">
127
- * import {getGlobalFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/global.js';
129
+ * import {getGlobalFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/global.js';
128
130
  * console.log(getGlobalFunction('parseInt')) // ↦ f parseInt() { }
129
131
  * </script>
130
132
  * ```
@@ -132,7 +134,7 @@ function getGlobalObject(name) {
132
134
  * @since 1.6.0
133
135
  * @memberOf Monster.Types
134
136
  * @param {string} name
135
- * @returns {objec}
137
+ * @return {objec}
136
138
  * @throws {TypeError} value is not a function
137
139
  * @throws {Error} the function is not defined
138
140
  * @throws {TypeError} value is not a string
@@ -24,7 +24,7 @@ let internalCounter = new Map;
24
24
  *
25
25
  * ```
26
26
  * <script type="module">
27
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/id.js';
27
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/id.js';
28
28
  * console.log(new Monster.Types.ID())
29
29
  * </script>
30
30
  * ```
@@ -33,7 +33,7 @@ let internalCounter = new Map;
33
33
  *
34
34
  * ```
35
35
  * <script type="module">
36
- * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.21.1/dist/modules/types/id.js';
36
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/types/id.js';
37
37
  * console.log(new ID())
38
38
  * </script>
39
39
  * ```