@schukai/monster 1.12.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. package/CHANGELOG +40 -1
  2. package/README.md +5 -5
  3. package/dist/modules/constants.js +2 -0
  4. package/dist/modules/constraints/abstract.js +2 -2
  5. package/dist/modules/constraints/abstractoperator.js +2 -2
  6. package/dist/modules/constraints/andoperator.js +2 -2
  7. package/dist/modules/constraints/invalid.js +2 -2
  8. package/dist/modules/constraints/isarray.js +2 -2
  9. package/dist/modules/constraints/isobject.js +2 -2
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +2 -2
  12. package/dist/modules/constraints/valid.js +2 -2
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/diff.js +2 -2
  15. package/dist/modules/data/extend.js +2 -2
  16. package/dist/modules/data/namespace.js +1 -1
  17. package/dist/modules/data/pathfinder.js +2 -2
  18. package/dist/modules/data/pipe.js +2 -2
  19. package/dist/modules/data/transformer.js +2 -2
  20. package/dist/modules/dom/assembler.js +2 -2
  21. package/dist/modules/dom/attributes.js +2 -2
  22. package/dist/modules/dom/constants.js +2 -2
  23. package/dist/modules/dom/customcontrol.js +2 -0
  24. package/dist/modules/dom/customelement.js +2 -2
  25. package/dist/modules/dom/events.js +2 -2
  26. package/dist/modules/dom/locale.js +2 -0
  27. package/dist/modules/dom/namespace.js +1 -1
  28. package/dist/modules/dom/template.js +2 -2
  29. package/dist/modules/dom/theme.js +2 -2
  30. package/dist/modules/dom/updater.js +2 -2
  31. package/dist/modules/dom/util.js +2 -2
  32. package/dist/modules/i18n/locale.js +2 -0
  33. package/dist/modules/i18n/namespace.js +2 -0
  34. package/dist/modules/i18n/provider.js +2 -0
  35. package/dist/modules/i18n/providers/fetch.js +2 -0
  36. package/dist/modules/i18n/providers/namespace.js +2 -0
  37. package/dist/modules/i18n/translations.js +2 -0
  38. package/dist/modules/logging/handler/console.js +2 -2
  39. package/dist/modules/logging/handler/namespace.js +1 -1
  40. package/dist/modules/logging/handler.js +2 -2
  41. package/dist/modules/logging/logentry.js +2 -2
  42. package/dist/modules/logging/logger.js +2 -2
  43. package/dist/modules/logging/namespace.js +1 -1
  44. package/dist/modules/math/namespace.js +1 -1
  45. package/dist/modules/math/random.js +2 -2
  46. package/dist/modules/monster.js +2 -2
  47. package/dist/modules/namespace.js +1 -1
  48. package/dist/modules/text/formatter.js +2 -2
  49. package/dist/modules/text/namespace.js +1 -1
  50. package/dist/modules/types/base.js +2 -2
  51. package/dist/modules/types/basewithoptions.js +2 -0
  52. package/dist/modules/types/global.js +2 -2
  53. package/dist/modules/types/id.js +2 -2
  54. package/dist/modules/types/is.js +2 -2
  55. package/dist/modules/types/namespace.js +1 -1
  56. package/dist/modules/types/observer.js +2 -2
  57. package/dist/modules/types/observerlist.js +2 -2
  58. package/dist/modules/types/proxyobserver.js +2 -2
  59. package/dist/modules/types/queue.js +2 -2
  60. package/dist/modules/types/randomid.js +2 -2
  61. package/dist/modules/types/stack.js +2 -2
  62. package/dist/modules/types/tokenlist.js +2 -2
  63. package/dist/modules/types/typeof.js +2 -2
  64. package/dist/modules/types/uniquequeue.js +2 -2
  65. package/dist/modules/types/validate.js +2 -2
  66. package/dist/modules/types/version.js +2 -2
  67. package/dist/modules/util/clone.js +2 -2
  68. package/dist/modules/util/comparator.js +2 -2
  69. package/dist/modules/util/freeze.js +2 -2
  70. package/dist/modules/util/namespace.js +1 -1
  71. package/dist/monster.dev.js +8692 -6669
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +3 -3
  74. package/package.json +1 -1
  75. package/source/constants.js +22 -0
  76. package/source/constraints/abstract.js +2 -2
  77. package/source/constraints/abstractoperator.js +3 -3
  78. package/source/constraints/andoperator.js +7 -7
  79. package/source/constraints/invalid.js +6 -6
  80. package/source/constraints/isarray.js +6 -6
  81. package/source/constraints/isobject.js +6 -6
  82. package/source/constraints/namespace.js +2 -0
  83. package/source/constraints/oroperator.js +8 -8
  84. package/source/constraints/valid.js +6 -6
  85. package/source/data/buildmap.js +15 -15
  86. package/source/data/diff.js +6 -6
  87. package/source/data/extend.js +55 -13
  88. package/source/data/namespace.js +2 -0
  89. package/source/data/pathfinder.js +6 -7
  90. package/source/data/pipe.js +5 -5
  91. package/source/data/transformer.js +6 -6
  92. package/source/dom/assembler.js +5 -5
  93. package/source/dom/attributes.js +89 -45
  94. package/source/dom/constants.js +8 -9
  95. package/source/dom/customcontrol.js +301 -0
  96. package/source/dom/customelement.js +149 -31
  97. package/source/dom/events.js +58 -8
  98. package/source/dom/locale.js +59 -0
  99. package/source/dom/namespace.js +2 -0
  100. package/source/dom/template.js +7 -7
  101. package/source/dom/theme.js +6 -6
  102. package/source/dom/updater.js +38 -11
  103. package/source/dom/util.js +10 -10
  104. package/source/i18n/locale.js +322 -0
  105. package/source/i18n/namespace.js +15 -0
  106. package/source/i18n/provider.js +58 -0
  107. package/source/i18n/providers/fetch.js +121 -0
  108. package/source/i18n/providers/namespace.js +15 -0
  109. package/source/i18n/translations.js +209 -0
  110. package/source/logging/handler/console.js +4 -4
  111. package/source/logging/handler.js +4 -4
  112. package/source/logging/logentry.js +4 -4
  113. package/source/logging/logger.js +4 -4
  114. package/source/logging/namespace.js +2 -0
  115. package/source/math/namespace.js +2 -0
  116. package/source/math/random.js +5 -5
  117. package/source/monster.js +26 -16
  118. package/source/namespace.js +10 -8
  119. package/source/text/formatter.js +4 -5
  120. package/source/text/namespace.js +1 -1
  121. package/source/types/base.js +4 -7
  122. package/source/types/basewithoptions.js +97 -0
  123. package/source/types/global.js +6 -6
  124. package/source/types/id.js +6 -6
  125. package/source/types/is.js +22 -22
  126. package/source/types/namespace.js +3 -1
  127. package/source/types/observer.js +5 -5
  128. package/source/types/observerlist.js +4 -4
  129. package/source/types/proxyobserver.js +32 -26
  130. package/source/types/queue.js +13 -7
  131. package/source/types/randomid.js +5 -5
  132. package/source/types/stack.js +11 -4
  133. package/source/types/tokenlist.js +4 -4
  134. package/source/types/typeof.js +5 -5
  135. package/source/types/uniquequeue.js +11 -4
  136. package/source/types/validate.js +22 -22
  137. package/source/types/version.js +9 -9
  138. package/source/util/clone.js +4 -4
  139. package/source/util/comparator.js +6 -6
  140. package/source/util/freeze.js +4 -4
  141. package/source/util/namespace.js +2 -0
  142. package/test/cases/data/extend.js +66 -13
  143. package/test/cases/dom/attributes.js +56 -1
  144. package/test/cases/dom/customcontrol.js +264 -0
  145. package/test/cases/dom/customelement.js +112 -51
  146. package/test/cases/dom/events.js +32 -14
  147. package/test/cases/dom/locale.js +44 -0
  148. package/test/cases/i18n/locale.js +80 -0
  149. package/test/cases/i18n/provider.js +15 -0
  150. package/test/cases/i18n/providers/fetch.js +65 -0
  151. package/test/cases/i18n/translations.js +57 -0
  152. package/test/cases/monster.js +3 -1
  153. package/test/cases/{util → text}/formatter.js +2 -0
  154. package/test/cases/types/basewithoptions.js +25 -0
  155. package/test/cases/types/proxyobserver.js +9 -0
  156. package/test/cases/{text → util}/clone.js +0 -0
  157. package/test/cases/{text → util}/comparator.js +0 -0
  158. package/test/util/jsdom.js +4 -0
  159. package/test/web/import.js +10 -3
  160. package/test/web/monster-dev.html +3 -3
  161. package/test/web/monster.html +3 -3
  162. package/test/web/test.html +3 -3
  163. package/test/web/tests.js +3 -3
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @author schukai GmbH
5
+ */
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import {Pathfinder} from "../data/pathfinder.js";
8
+ import {Base} from "./base.js";
9
+ import {validateObject} from "./validate.js";
10
+ import {PROPERTY_KEY_INTERNALDATA} from "../constants.js";
11
+ import {extend} from "../data/extend.js";
12
+
13
+ /**
14
+ * @private
15
+ * @type {symbol}
16
+ */
17
+ const optionsSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
18
+
19
+ /**
20
+ * This is the base class with options from which some monster classes are derived.
21
+ *
22
+ * You can call the method via the monster namespace `new Monster.Types.BaseWithOptions()`.
23
+ *
24
+ * ```
25
+ * <script type="module">
26
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/basewithoptions.js';
27
+ * console.log(new Monster.Types.BaseWithOptions())
28
+ * </script>
29
+ * ```
30
+ *
31
+ * Alternatively, you can also integrate this function individually.
32
+ *
33
+ * ```
34
+ * <script type="module">
35
+ * import {BaseWithOptions} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/basewithoptions.js';
36
+ * console.log(new BaseWithOptions())
37
+ * </script>
38
+ * ```
39
+ *
40
+ * The class was formerly called Object.
41
+ *
42
+ * @since 1.13.0
43
+ * @copyright schukai GmbH
44
+ * @memberOf Monster/Types
45
+ */
46
+ class BaseWithOptions extends Base {
47
+
48
+ /**
49
+ *
50
+ * @param {object} options
51
+ */
52
+ constructor(options) {
53
+ super();
54
+
55
+ if (options === undefined) {
56
+ options = {};
57
+ }
58
+
59
+ this[optionsSymbol] = extend({}, this.defaults, validateObject(options));
60
+
61
+ }
62
+
63
+ /**
64
+ * can be overridden by child class values
65
+ *
66
+ * @return {object}
67
+ */
68
+ get defaults() {
69
+ return {}
70
+ }
71
+
72
+ /**
73
+ * nested options can be specified by path `a.b.c`
74
+ *
75
+ * @param {string} path
76
+ * @param {*} defaultValue
77
+ * @return {*}
78
+ * @since 1.10.0
79
+ */
80
+ getOption(path, defaultValue) {
81
+ let value;
82
+
83
+ try {
84
+ value = new Pathfinder(this[optionsSymbol]).getVia(path);
85
+ } catch (e) {
86
+
87
+ }
88
+
89
+ if (value === undefined) return defaultValue;
90
+ return value;
91
+ }
92
+
93
+
94
+ }
95
+
96
+ assignToNamespace('Monster.Types', BaseWithOptions);
97
+ export {Monster, BaseWithOptions}
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {validateFunction, validateString, validateObject} from "./validate.js";
9
9
 
10
10
  /**
@@ -78,7 +78,7 @@ function getGlobal() {
78
78
  *
79
79
  * ```
80
80
  * <script type="module">
81
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/global.js';
81
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/global.js';
82
82
  * console.log(Monster.Types.getGlobalObject('document')) // ↦ { }
83
83
  * </script>
84
84
  * ```
@@ -87,7 +87,7 @@ function getGlobal() {
87
87
  *
88
88
  * ```
89
89
  * <script type="module">
90
- * import {getGlobalObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/global.js';
90
+ * import {getGlobalObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/global.js';
91
91
  * console.log(getGlobalObject('document')) // ↦ { }
92
92
  * </script>
93
93
  * ```
@@ -115,7 +115,7 @@ function getGlobalObject(name) {
115
115
  *
116
116
  * ```
117
117
  * <script type="module">
118
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/global.js';
118
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/global.js';
119
119
  * console.log(Monster.Types.getGlobalFunction('parseInt')) // ↦ f parseInt() { }
120
120
  * </script>
121
121
  * ```
@@ -124,7 +124,7 @@ function getGlobalObject(name) {
124
124
  *
125
125
  * ```
126
126
  * <script type="module">
127
- * import {getGlobalFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/global.js';
127
+ * import {getGlobalFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/global.js';
128
128
  * console.log(getGlobalFunction('parseInt')) // ↦ f parseInt() { }
129
129
  * </script>
130
130
  * ```
@@ -146,5 +146,5 @@ function getGlobalFunction(name) {
146
146
  }
147
147
 
148
148
 
149
- Monster.assignToNamespace('Monster.Types', getGlobal, getGlobalObject, getGlobalFunction);
149
+ assignToNamespace('Monster.Types', getGlobal, getGlobalObject, getGlobalFunction);
150
150
  export {Monster, getGlobal, getGlobalObject, getGlobalFunction}
@@ -2,9 +2,9 @@
2
2
 
3
3
  /**
4
4
  * @author schukai GmbH
5
- */
6
-
7
- import {Monster, Base} from './base.js';
5
+ */
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import { Base} from './base.js';
8
8
  import {validateString} from "./validate.js";
9
9
 
10
10
  /**
@@ -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.12.0/dist/modules/types/id.js';
27
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.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.12.0/dist/modules/types/id.js';
36
+ * import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/id.js';
37
37
  * console.log(new ID())
38
38
  * </script>
39
39
  * ```
@@ -77,5 +77,5 @@ class ID extends Base {
77
77
 
78
78
  }
79
79
 
80
- Monster.assignToNamespace('Monster.Types', ID);
80
+ assignToNamespace('Monster.Types', ID);
81
81
  export {Monster, ID}
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
 
9
9
  /**
10
10
  * With this function you can check if a value is iterable
@@ -13,7 +13,7 @@ import {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.12.0/dist/modules/types/is.js';
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
17
17
  * console.log(Monster.Types.isIterable(null)) // ↦ false
18
18
  * console.log(Monster.Types.isIterable('hello')) // ↦ true
19
19
  * console.log(Monster.Types.isIterable([])) // ↦ true
@@ -24,7 +24,7 @@ import {Monster} from '../namespace.js';
24
24
  *
25
25
  * ```
26
26
  * <script type="module">
27
- * import {isIterable} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
27
+ * import {isIterable} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
28
28
  * console.log(isIterable(null)) // ↦ false
29
29
  * console.log(isIterable('hello')) // ↦ true
30
30
  * console.log(isIterable([])) // ↦ true
@@ -51,7 +51,7 @@ function isIterable(value) {
51
51
  *
52
52
  * ```
53
53
  * <script type="module">
54
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
54
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
55
55
  * console.log(Monster.Types.isPrimitive('2')) // ↦ false
56
56
  * console.log(Monster.Types.isPrimitive([])) // ↦ true
57
57
  * </script>
@@ -61,7 +61,7 @@ function isIterable(value) {
61
61
  *
62
62
  * ```
63
63
  * <script type="module">
64
- * import {isPrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
64
+ * import {isPrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
65
65
  * console.log(isPrimitive('2')) // ↦ true
66
66
  * console.log(isPrimitive([])) // ↦ false
67
67
  * </script>
@@ -96,7 +96,7 @@ function isPrimitive(value) {
96
96
  *
97
97
  * ```
98
98
  * <script type="module">
99
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
99
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
100
100
  * console.log(Monster.Types.isSymbol('2')) // ↦ false
101
101
  * console.log(Monster.Types.isSymbol(Symbol('test')) // ↦ true
102
102
  * </script>
@@ -106,7 +106,7 @@ function isPrimitive(value) {
106
106
  *
107
107
  * ```
108
108
  * <script type="module">
109
- * import {isSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
109
+ * import {isSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
110
110
  * console.log(isSymbol(Symbol('a'))) // ↦ true
111
111
  * console.log(isSymbol([]) // ↦ false
112
112
  * </script>
@@ -129,7 +129,7 @@ function isSymbol(value) {
129
129
  *
130
130
  * ```
131
131
  * <script type="module">
132
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
132
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
133
133
  * console.log(Monster.Types.isBoolean('2')) // ↦ false
134
134
  * console.log(Monster.Types.isBoolean([])) // ↦ false
135
135
  * console.log(Monster.Types.isBoolean(true)) // ↦ true
@@ -140,7 +140,7 @@ function isSymbol(value) {
140
140
  *
141
141
  * ```
142
142
  * <script type="module">
143
- * import {isBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
143
+ * import {isBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
144
144
  * console.log(isBoolean('2')) // ↦ false
145
145
  * console.log(isBoolean([])) // ↦ false
146
146
  * console.log(isBoolean(2>4)) // ↦ true
@@ -169,7 +169,7 @@ function isBoolean(value) {
169
169
  *
170
170
  * ```
171
171
  * <script type="module">
172
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
172
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
173
173
  * console.log(Monster.Types.isString('2')) // ↦ true
174
174
  * console.log(Monster.Types.isString([])) // ↦ false
175
175
  * </script>
@@ -179,7 +179,7 @@ function isBoolean(value) {
179
179
  *
180
180
  * ```
181
181
  * <script type="module">
182
- * import {isString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
182
+ * import {isString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
183
183
  * console.log(isString('2')) // ↦ true
184
184
  * console.log(isString([])) // ↦ false
185
185
  * </script>
@@ -205,7 +205,7 @@ function isString(value) {
205
205
  *
206
206
  * ```
207
207
  * <script type="module">
208
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
208
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
209
209
  * console.log(Monster.Types.isObject('2')) // ↦ false
210
210
  * console.log(Monster.Types.isObject([])) // ↦ false
211
211
  * console.log(Monster.Types.isObject({})) // ↦ true
@@ -216,7 +216,7 @@ function isString(value) {
216
216
  *
217
217
  * ```
218
218
  * <script type="module">
219
- * import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
219
+ * import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
220
220
  * console.log(isObject('2')) // ↦ false
221
221
  * console.log(isObject([])) // ↦ false
222
222
  * </script>
@@ -247,7 +247,7 @@ function isObject(value) {
247
247
  *
248
248
  * ```
249
249
  * <script type="module">
250
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
250
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
251
251
  * console.log(Monster.Types.isInstance('2')) // ↦ false
252
252
  * console.log(Monster.Types.isInstance([])) // ↦ false
253
253
  * console.log(Monster.Types.isInstance({})) // ↦ true
@@ -258,7 +258,7 @@ function isObject(value) {
258
258
  *
259
259
  * ```
260
260
  * <script type="module">
261
- * import {isInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
261
+ * import {isInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
262
262
  * console.log(isInstance('2')) // ↦ false
263
263
  * console.log(isInstance([])) // ↦ false
264
264
  * </script>
@@ -287,7 +287,7 @@ function isInstance(value, instance) {
287
287
  *
288
288
  * ```
289
289
  * <script type="module">
290
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
290
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
291
291
  * console.log(Monster.Types.isArray('2')) // ↦ false
292
292
  * console.log(Monster.Types.isArray([])) // ↦ true
293
293
  * </script>
@@ -297,7 +297,7 @@ function isInstance(value, instance) {
297
297
  *
298
298
  * ```
299
299
  * <script type="module">
300
- * import {isArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
300
+ * import {isArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
301
301
  * console.log(isArray('2')) // ↦ false
302
302
  * console.log(isArray([])) // ↦ true
303
303
  * </script>
@@ -323,7 +323,7 @@ function isArray(value) {
323
323
  *
324
324
  * ```
325
325
  * <script type="module">
326
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
326
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
327
327
  * console.log(Monster.Types.isFunction(()=>{})) // ↦ true
328
328
  * console.log(Monster.Types.isFunction('2')) // ↦ false
329
329
  * console.log(Monster.Types.isFunction([])) // ↦ false
@@ -334,7 +334,7 @@ function isArray(value) {
334
334
  *
335
335
  * ```
336
336
  * <script type="module">
337
- * import {isFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
337
+ * import {isFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
338
338
  * console.log(isFunction(()=>{})) // ↦ true
339
339
  * console.log(isFunction('2')) // ↦ false
340
340
  * console.log(isFunction([])) // ↦ false
@@ -366,7 +366,7 @@ function isFunction(value) {
366
366
  *
367
367
  * ```
368
368
  * <script type="module">
369
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
369
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
370
370
  * console.log(Monster.Types.isInteger(()=>{})) // ↦ true
371
371
  * console.log(Monster.Types.isInteger('2')) // ↦ false
372
372
  * console.log(Monster.Types.isInteger(2)) // ↦ true
@@ -377,7 +377,7 @@ function isFunction(value) {
377
377
  *
378
378
  * ```
379
379
  * <script type="module">
380
- * import {isInteger} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
380
+ * import {isInteger} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
381
381
  * console.log(isInteger(()=>{})) // ↦ true
382
382
  * console.log(isInteger('2')) // ↦ false
383
383
  * console.log(isInteger(2)) // ↦ true
@@ -395,7 +395,7 @@ function isInteger(value) {
395
395
  }
396
396
 
397
397
 
398
- Monster.assignToNamespace('Monster.Types', isPrimitive, isBoolean, isString, isObject, isArray, isFunction, isIterable, isInteger, isSymbol);
398
+ assignToNamespace('Monster.Types', isPrimitive, isBoolean, isString, isObject, isArray, isFunction, isIterable, isInteger, isSymbol);
399
399
  export {
400
400
  Monster,
401
401
  isPrimitive,
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
+ * Namespace for types.
5
+ *
4
6
  * @namespace Monster/Types
5
7
  * @author schukai GmbH
6
8
  */
@@ -10,4 +12,4 @@
10
12
  * @private
11
13
  * @type {string}
12
14
  */
13
- const namespace="Monster.Types";
15
+ const namespace="Monster.Types";
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {TokenList} from './tokenlist.js';
9
9
  import {isObject} from './is.js';
10
10
  import {Base} from './base.js';
@@ -17,7 +17,7 @@ import {UniqueQueue} from './uniquequeue.js';
17
17
  *
18
18
  * ```
19
19
  * <script type="module">
20
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/observer.js';
20
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/observer.js';
21
21
  * console.log(new Monster.Types.Observer())
22
22
  * </script>
23
23
  * ```
@@ -26,7 +26,7 @@ import {UniqueQueue} from './uniquequeue.js';
26
26
  *
27
27
  * ```
28
28
  * <script type="module">
29
- * import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/observer.js';
29
+ * import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/observer.js';
30
30
  * console.log(new Observer())
31
31
  * </script>
32
32
  * ```
@@ -60,7 +60,7 @@ import {UniqueQueue} from './uniquequeue.js';
60
60
  *
61
61
  * @example
62
62
  *
63
- * import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/observer.js';
63
+ * import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/observer.js';
64
64
  *
65
65
  * const observer = new Observer(function(a, b, c) {
66
66
  * console.log(this, a, b, c); // ↦ "a", 2, true
@@ -177,7 +177,7 @@ class Observer extends Base {
177
177
 
178
178
  }
179
179
 
180
- Monster.assignToNamespace('Monster.Types', Observer);
180
+ assignToNamespace('Monster.Types', Observer);
181
181
  export {Monster, Observer}
182
182
 
183
183
 
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {Base} from './base.js';
9
9
  import {Observer} from "./observer.js";
10
10
  import {validateInstance} from "./validate.js";
@@ -16,7 +16,7 @@ import {validateInstance} from "./validate.js";
16
16
  *
17
17
  * ```
18
18
  * <script type="module">
19
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/observerlist.js';
19
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/observerlist.js';
20
20
  * console.log(new Monster.Types.ObserverList())
21
21
  * console.log(new Monster.Types.ObserverList())
22
22
  * </script>
@@ -26,7 +26,7 @@ import {validateInstance} from "./validate.js";
26
26
  *
27
27
  * ```
28
28
  * <script type="module">
29
- * import {ObserverList} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/observerlist.js';
29
+ * import {ObserverList} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/observerlist.js';
30
30
  * console.log(ObserverList())
31
31
  * console.log(ObserverList())
32
32
  * </script>
@@ -114,5 +114,5 @@ class ObserverList extends Base {
114
114
 
115
115
  }
116
116
 
117
- Monster.assignToNamespace('Monster.Types', ObserverList);
117
+ assignToNamespace('Monster.Types', ObserverList);
118
118
  export {Monster, ObserverList}
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, Base} from './base.js';
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import { Base} from './base.js';
8
8
  import {validateObject} from "./validate.js";
9
9
  import {ObserverList} from "./observerlist.js";
10
10
  import {Observer} from "./observer.js";
@@ -13,20 +13,20 @@ import {isObject, isArray, isPrimitive} from "./is.js";
13
13
  /**
14
14
  * An observer manages a callback function
15
15
  *
16
- * You can call the method via the monster namespace `new Monster.Types.ProxyObserver()`.
16
+ * You can call create the class via the monster namespace `new Monster.Types.ProxyObserver()`.
17
17
  *
18
18
  * ```
19
19
  * <script type="module">
20
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/proxyobserver.js';
20
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/proxyobserver.js';
21
21
  * console.log(new Monster.Types.ProxyObserver())
22
22
  * </script>
23
23
  * ```
24
24
  *
25
- * Alternatively, you can also integrate this function individually.
25
+ * Alternatively, you can also integrate this class individually.
26
26
  *
27
27
  * ```
28
28
  * <script type="module">
29
- * import {ProxyObserver} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/proxyobserver.js';
29
+ * import {ProxyObserver} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/proxyobserver.js';
30
30
  * console.log(new ProxyObserver())
31
31
  * </script>
32
32
  * ```
@@ -37,9 +37,9 @@ import {isObject, isArray, isPrimitive} from "./is.js";
37
37
  *
38
38
  * @example
39
39
  *
40
- * import {ProxyObserver} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/proxyobserver.js';
41
- * import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/observer.js';
42
- * import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/types/is.js';
40
+ * import {ProxyObserver} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/proxyobserver.js';
41
+ * import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/observer.js';
42
+ * import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/is.js';
43
43
  *
44
44
  * const o = new Observer(function () {
45
45
  * if (isObject(this) && this instanceof ProxyObserver) {
@@ -76,13 +76,16 @@ class ProxyObserver extends Base {
76
76
  */
77
77
  constructor(object) {
78
78
  super();
79
- validateObject(object);
80
- this.realSubject = object
79
+
80
+ this.realSubject = validateObject(object);
81
81
  this.subject = new Proxy(object, getHandler.call(this));
82
82
 
83
83
  this.objectMap = new WeakMap();
84
84
  this.objectMap.set(this.realSubject, this.subject);
85
85
 
86
+ this.proxyMap = new WeakMap();
87
+ this.proxyMap.set(this.subject, this.realSubject);
88
+
86
89
  this.observers = new ObserverList;
87
90
  }
88
91
 
@@ -139,7 +142,7 @@ class ProxyObserver extends Base {
139
142
 
140
143
  /**
141
144
  * @param {Observer} observer
142
- * @returns {ProxyObserver}
145
+ * @returns {boolean}
143
146
  */
144
147
  containsObserver(observer) {
145
148
  return this.observers.contains(observer)
@@ -147,7 +150,7 @@ class ProxyObserver extends Base {
147
150
 
148
151
  }
149
152
 
150
- Monster.assignToNamespace('Monster.Types', ProxyObserver);
153
+ assignToNamespace('Monster.Types', ProxyObserver);
151
154
  export {Monster, ProxyObserver}
152
155
 
153
156
  /**
@@ -180,9 +183,12 @@ function getHandler() {
180
183
  if ((isArray(value) || isObject(value))) {
181
184
  if (proxy.objectMap.has(value)) {
182
185
  return proxy.objectMap.get(value);
186
+ } else if (proxy.proxyMap.has(value)) {
187
+ return value;
183
188
  } else {
184
189
  let p = new Proxy(value, handler);
185
190
  proxy.objectMap.set(value, p);
191
+ proxy.proxyMap.set(p, value);
186
192
  return p;
187
193
  }
188
194
 
@@ -195,18 +201,24 @@ function getHandler() {
195
201
  // https://262.ecma-international.org/9.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver
196
202
  set: function (target, key, value, receiver) {
197
203
 
198
- // let descriptor2 = Reflect.getOwnPropertyDescriptor(target, key);
199
- // console.log(descriptor2, 'descriptor2');
200
-
201
-
204
+ if(proxy.proxyMap.has(value)) {
205
+ value= proxy.proxyMap.get(value);
206
+ }
207
+
208
+ if(proxy.proxyMap.has(target)) {
209
+ target= proxy.proxyMap.get(target);
210
+ }
211
+
202
212
  let current = Reflect.get(target, key, receiver);
203
-
213
+ if(proxy.proxyMap.has(current)) {
214
+ current= proxy.proxyMap.get(current);
215
+ }
216
+
204
217
  if (current === value) {
205
218
  return true;
206
219
  }
207
220
 
208
221
  let result;
209
- //if (value === undefined) {
210
222
  let descriptor = Reflect.getOwnPropertyDescriptor(target, key);
211
223
 
212
224
  if (descriptor === undefined) {
@@ -217,15 +229,8 @@ function getHandler() {
217
229
  }
218
230
  }
219
231
 
220
- //delete target[key];
221
232
  descriptor['value'] = value;
222
233
  result = Reflect.defineProperty(target, key, descriptor);
223
- // } else {
224
- // result = Reflect.set(target, key, value, receiver);
225
- // }
226
-
227
- // let descriptor3 = Reflect.getOwnPropertyDescriptor(target, key);
228
- // console.log(descriptor3, 'descriptor3');
229
234
 
230
235
  if (typeof key !== "symbol") {
231
236
  proxy.observers.notify(proxy);
@@ -234,6 +239,7 @@ function getHandler() {
234
239
  return result;
235
240
  },
236
241
 
242
+
237
243
  // https://262.ecma-international.org/9.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-p
238
244
  deleteProperty: function (target, key) {
239
245
  if (key in target) {