@schukai/monster 1.24.0 → 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. package/CHANGELOG +47 -0
  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 +2 -2
  14. package/dist/modules/data/buildtree.js +2 -0
  15. package/dist/modules/data/datasource/namespace.js +1 -1
  16. package/dist/modules/data/datasource/restapi/writeerror.js +1 -1
  17. package/dist/modules/data/datasource/restapi.js +1 -1
  18. package/dist/modules/data/datasource/storage/localstorage.js +1 -1
  19. package/dist/modules/data/datasource/storage/namespace.js +1 -1
  20. package/dist/modules/data/datasource/storage/sessionstorage.js +1 -1
  21. package/dist/modules/data/datasource/storage.js +1 -1
  22. package/dist/modules/data/datasource.js +1 -1
  23. package/dist/modules/data/diff.js +1 -1
  24. package/dist/modules/data/extend.js +1 -1
  25. package/dist/modules/data/namespace.js +1 -1
  26. package/dist/modules/data/pathfinder.js +1 -1
  27. package/dist/modules/data/pipe.js +1 -1
  28. package/dist/modules/data/transformer.js +2 -2
  29. package/dist/modules/dom/assembler.js +1 -1
  30. package/dist/modules/dom/attributes.js +2 -2
  31. package/dist/modules/dom/constants.js +2 -2
  32. package/dist/modules/dom/customcontrol.js +1 -1
  33. package/dist/modules/dom/customelement.js +1 -1
  34. package/dist/modules/dom/events.js +1 -1
  35. package/dist/modules/dom/focusmanager.js +2 -0
  36. package/dist/modules/dom/locale.js +1 -1
  37. package/dist/modules/dom/namespace.js +1 -1
  38. package/dist/modules/dom/resource/data.js +2 -0
  39. package/dist/modules/dom/resource/link/stylesheet.js +2 -0
  40. package/dist/modules/dom/resource/link.js +2 -0
  41. package/dist/modules/dom/resource/script.js +2 -0
  42. package/dist/modules/dom/resource.js +2 -0
  43. package/dist/modules/dom/resourcemanager.js +2 -0
  44. package/dist/modules/dom/template.js +2 -2
  45. package/dist/modules/dom/theme.js +1 -1
  46. package/dist/modules/dom/updater.js +2 -2
  47. package/dist/modules/dom/util.js +1 -1
  48. package/dist/modules/dom/worker/factory.js +2 -0
  49. package/dist/modules/i18n/formatter.js +2 -0
  50. package/dist/modules/i18n/locale.js +1 -1
  51. package/dist/modules/i18n/namespace.js +1 -1
  52. package/dist/modules/i18n/provider.js +1 -1
  53. package/dist/modules/i18n/providers/fetch.js +1 -1
  54. package/dist/modules/i18n/providers/namespace.js +1 -1
  55. package/dist/modules/i18n/translations.js +1 -1
  56. package/dist/modules/logging/handler/console.js +1 -1
  57. package/dist/modules/logging/handler/namespace.js +1 -1
  58. package/dist/modules/logging/handler.js +1 -1
  59. package/dist/modules/logging/logentry.js +1 -1
  60. package/dist/modules/logging/logger.js +1 -1
  61. package/dist/modules/logging/namespace.js +1 -1
  62. package/dist/modules/math/namespace.js +1 -1
  63. package/dist/modules/math/random.js +2 -2
  64. package/dist/modules/monster.js +1 -1
  65. package/dist/modules/namespace.js +1 -1
  66. package/dist/modules/text/formatter.js +2 -2
  67. package/dist/modules/text/namespace.js +1 -1
  68. package/dist/modules/types/base.js +1 -1
  69. package/dist/modules/types/basewithoptions.js +1 -1
  70. package/dist/modules/types/binary.js +1 -1
  71. package/dist/modules/types/dataurl.js +1 -1
  72. package/dist/modules/types/global.js +1 -1
  73. package/dist/modules/types/id.js +1 -1
  74. package/dist/modules/types/is.js +2 -2
  75. package/dist/modules/types/mediatype.js +1 -1
  76. package/dist/modules/types/namespace.js +1 -1
  77. package/dist/modules/types/node.js +2 -0
  78. package/dist/modules/types/nodelist.js +2 -0
  79. package/dist/modules/types/noderecursiveiterator.js +2 -0
  80. package/dist/modules/types/observer.js +1 -1
  81. package/dist/modules/types/observerlist.js +1 -1
  82. package/dist/modules/types/proxyobserver.js +1 -1
  83. package/dist/modules/types/queue.js +1 -1
  84. package/dist/modules/types/randomid.js +1 -1
  85. package/dist/modules/types/regex.js +2 -0
  86. package/dist/modules/types/stack.js +1 -1
  87. package/dist/modules/types/tokenlist.js +1 -1
  88. package/dist/modules/types/typeof.js +1 -1
  89. package/dist/modules/types/uniquequeue.js +1 -1
  90. package/dist/modules/types/uuid.js +2 -0
  91. package/dist/modules/types/validate.js +1 -1
  92. package/dist/modules/types/version.js +2 -2
  93. package/dist/modules/util/clone.js +1 -1
  94. package/dist/modules/util/comparator.js +1 -1
  95. package/dist/modules/util/freeze.js +1 -1
  96. package/dist/modules/util/namespace.js +1 -1
  97. package/dist/modules/util/processing.js +1 -1
  98. package/dist/modules/util/trimspaces.js +1 -1
  99. package/dist/monster.dev.js +1528 -770
  100. package/dist/monster.dev.js.map +1 -1
  101. package/dist/monster.js +2 -2
  102. package/package.json +13 -2
  103. package/source/constants.js +11 -2
  104. package/source/constraints/abstract.js +5 -0
  105. package/source/constraints/abstractoperator.js +5 -0
  106. package/source/constraints/andoperator.js +10 -5
  107. package/source/constraints/invalid.js +8 -3
  108. package/source/constraints/isarray.js +9 -4
  109. package/source/constraints/isobject.js +8 -3
  110. package/source/constraints/oroperator.js +10 -5
  111. package/source/constraints/valid.js +8 -3
  112. package/source/data/buildmap.js +25 -9
  113. package/source/data/buildtree.js +95 -0
  114. package/source/data/datasource/restapi.js +3 -3
  115. package/source/data/datasource/storage/localstorage.js +2 -2
  116. package/source/data/datasource/storage/sessionstorage.js +2 -2
  117. package/source/data/datasource/storage.js +3 -3
  118. package/source/data/datasource.js +3 -3
  119. package/source/data/diff.js +3 -3
  120. package/source/data/extend.js +2 -2
  121. package/source/data/pathfinder.js +4 -4
  122. package/source/data/pipe.js +3 -3
  123. package/source/data/transformer.js +7 -5
  124. package/source/dom/assembler.js +2 -2
  125. package/source/dom/attributes.js +111 -28
  126. package/source/dom/constants.js +287 -10
  127. package/source/dom/customcontrol.js +1 -1
  128. package/source/dom/customelement.js +1 -1
  129. package/source/dom/events.js +6 -7
  130. package/source/dom/focusmanager.js +250 -0
  131. package/source/dom/locale.js +10 -5
  132. package/source/dom/resource/data.js +170 -0
  133. package/source/dom/resource/link/stylesheet.js +54 -0
  134. package/source/dom/resource/link.js +125 -0
  135. package/source/dom/resource/script.js +112 -0
  136. package/source/dom/resource.js +268 -0
  137. package/source/dom/resourcemanager.js +214 -0
  138. package/source/dom/template.js +86 -16
  139. package/source/dom/theme.js +3 -3
  140. package/source/dom/updater.js +138 -90
  141. package/source/dom/util.js +6 -6
  142. package/source/dom/worker/factory.js +134 -0
  143. package/source/i18n/formatter.js +140 -0
  144. package/source/i18n/locale.js +6 -4
  145. package/source/i18n/provider.js +2 -2
  146. package/source/i18n/providers/fetch.js +18 -3
  147. package/source/i18n/translations.js +18 -9
  148. package/source/logging/handler/console.js +2 -2
  149. package/source/logging/handler.js +2 -2
  150. package/source/logging/logentry.js +2 -2
  151. package/source/logging/logger.js +2 -2
  152. package/source/math/random.js +9 -5
  153. package/source/namespace.js +1 -1
  154. package/source/text/formatter.js +190 -48
  155. package/source/types/base.js +4 -4
  156. package/source/types/basewithoptions.js +2 -2
  157. package/source/types/binary.js +4 -4
  158. package/source/types/dataurl.js +4 -4
  159. package/source/types/global.js +4 -4
  160. package/source/types/id.js +6 -3
  161. package/source/types/is.js +103 -85
  162. package/source/types/mediatype.js +4 -4
  163. package/source/types/node.js +179 -0
  164. package/source/types/nodelist.js +125 -0
  165. package/source/types/noderecursiveiterator.js +126 -0
  166. package/source/types/observer.js +3 -3
  167. package/source/types/observerlist.js +2 -2
  168. package/source/types/proxyobserver.js +5 -5
  169. package/source/types/queue.js +4 -4
  170. package/source/types/randomid.js +2 -2
  171. package/source/types/regex.js +49 -0
  172. package/source/types/stack.js +2 -2
  173. package/source/types/tokenlist.js +2 -2
  174. package/source/types/typeof.js +3 -3
  175. package/source/types/uniquequeue.js +2 -2
  176. package/source/types/uuid.js +102 -0
  177. package/source/types/validate.js +20 -20
  178. package/source/types/version.js +6 -6
  179. package/source/util/clone.js +2 -2
  180. package/source/util/comparator.js +4 -4
  181. package/source/util/freeze.js +5 -5
  182. package/source/util/processing.js +3 -3
  183. package/source/util/trimspaces.js +3 -3
  184. package/test/cases/data/buildtree.js +149 -0
  185. package/test/cases/data/datasource/restapi.js +1 -1
  186. package/test/cases/data/transformer.js +2 -0
  187. package/test/cases/dom/attributes.js +46 -19
  188. package/test/cases/dom/customelement.js +0 -3
  189. package/test/cases/dom/focusmanager.js +111 -0
  190. package/test/cases/dom/locale.js +1 -4
  191. package/test/cases/dom/resource/data.js +129 -0
  192. package/test/cases/dom/resource/link/stylesheet.js +101 -0
  193. package/test/cases/dom/resource/link.js +101 -0
  194. package/test/cases/dom/resource/script.js +115 -0
  195. package/test/cases/dom/resourcemanager.js +118 -0
  196. package/test/cases/dom/template.js +72 -14
  197. package/test/cases/dom/updater.js +102 -75
  198. package/test/cases/dom/worker/factory.js +63 -0
  199. package/test/cases/i18n/formatter.js +66 -0
  200. package/test/cases/monster.js +1 -1
  201. package/test/cases/text/formatter.js +36 -5
  202. package/test/cases/types/node.js +196 -0
  203. package/test/cases/types/nodelist.js +64 -0
  204. package/test/cases/types/noderecursiveiterator.js +54 -0
  205. package/test/cases/types/regex.js +32 -0
  206. package/test/cases/types/uuid.js +42 -0
  207. package/test/cases/util/freeze.js +30 -4
  208. package/test/util/cleanupdom.js +48 -0
  209. package/test/util/jsdom.js +22 -9
  210. package/test/web/import.js +14 -0
  211. package/test/web/monster-dev.html +3 -3
  212. package/test/web/monster.html +2 -2
  213. package/test/web/test.html +3 -3
  214. package/test/web/tests.js +7 -7
@@ -7,16 +7,18 @@
7
7
  import {assignToNamespace, Monster} from '../namespace.js';
8
8
 
9
9
  /**
10
- * With this function you can check if a value is iterable
10
+ * With this function you can check if a value is iterable.
11
+ *
12
+ * This method is used in the library to have consistent names.
11
13
  *
12
14
  * You can call the method via the monster namespace `Monster.Types.isPrimitive()`.
13
15
  *
14
16
  * ```
15
17
  * <script type="module">
16
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
17
- * console.log(Monster.Types.isIterable(null)) // ↦ false
18
- * console.log(Monster.Types.isIterable('hello')) // ↦ true
19
- * console.log(Monster.Types.isIterable([])) // ↦ true
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
19
+ * Monster.Types.isIterable(null) // ↦ false
20
+ * Monster.Types.isIterable('hello') // ↦ true
21
+ * Monster.Types.isIterable([]) // ↦ true
20
22
  * </script>
21
23
  * ```
22
24
  *
@@ -24,10 +26,10 @@ import {assignToNamespace, Monster} from '../namespace.js';
24
26
  *
25
27
  * ```
26
28
  * <script type="module">
27
- * import {isIterable} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
28
- * console.log(isIterable(null)) // ↦ false
29
- * console.log(isIterable('hello')) // ↦ true
30
- * console.log(isIterable([])) // ↦ true
29
+ * import {isIterable} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
30
+ * isIterable(null) // ↦ false
31
+ * isIterable('hello') // ↦ true
32
+ * isIterable([]) // ↦ true
31
33
  * </script>
32
34
  * ```
33
35
  *
@@ -46,14 +48,16 @@ function isIterable(value) {
46
48
 
47
49
  /**
48
50
  * Checks whether the value passed is a primitive (string, number, boolean, NaN, undefined, null or symbol)
51
+ *
52
+ * This method is used in the library to have consistent names.
49
53
  *
50
54
  * You can call the method via the monster namespace `Monster.Types.isPrimitive()`.
51
55
  *
52
56
  * ```
53
57
  * <script type="module">
54
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
55
- * console.log(Monster.Types.isPrimitive('2')) // ↦ false
56
- * console.log(Monster.Types.isPrimitive([])) // ↦ true
58
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
59
+ * Monster.Types.isPrimitive('2') // ↦ false
60
+ * Monster.Types.isPrimitive([]) // ↦ true
57
61
  * </script>
58
62
  * ```
59
63
  *
@@ -61,9 +65,9 @@ function isIterable(value) {
61
65
  *
62
66
  * ```
63
67
  * <script type="module">
64
- * import {isPrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
65
- * console.log(isPrimitive('2')) // ↦ true
66
- * console.log(isPrimitive([])) // ↦ false
68
+ * import {isPrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
69
+ * isPrimitive('2')) // ↦ true
70
+ * isPrimitive([])) // ↦ false
67
71
  * </script>
68
72
  * ```
69
73
  *
@@ -91,14 +95,16 @@ function isPrimitive(value) {
91
95
 
92
96
  /**
93
97
  * Checks whether the value passed is a symbol
98
+ *
99
+ * This method is used in the library to have consistent names.
94
100
  *
95
101
  * You can call the method via the monster namespace `Monster.Types.isSymbol()`.
96
102
  *
97
103
  * ```
98
104
  * <script type="module">
99
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
100
- * console.log(Monster.Types.isSymbol('2')) // ↦ false
101
- * console.log(Monster.Types.isSymbol(Symbol('test')) // ↦ true
105
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
106
+ * Monster.Types.isSymbol('2') // ↦ false
107
+ * Monster.Types.isSymbol(Symbol('test') // ↦ true
102
108
  * </script>
103
109
  * ```
104
110
  *
@@ -106,9 +112,9 @@ function isPrimitive(value) {
106
112
  *
107
113
  * ```
108
114
  * <script type="module">
109
- * import {isSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
110
- * console.log(isSymbol(Symbol('a'))) // ↦ true
111
- * console.log(isSymbol([]) // ↦ false
115
+ * import {isSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
116
+ * isSymbol(Symbol('a'))) // ↦ true
117
+ * isSymbol([]) // ↦ false
112
118
  * </script>
113
119
  * ```
114
120
  *
@@ -123,16 +129,18 @@ function isSymbol(value) {
123
129
  }
124
130
 
125
131
  /**
126
- * Checks whether the value passed is a boolean
132
+ * Checks whether the value passed is a boolean.
133
+ *
134
+ * This method is used in the library to have consistent names.
127
135
  *
128
136
  * You can call the method via the monster namespace `Monster.Types.isBoolean()`.
129
137
  *
130
138
  * ```
131
139
  * <script type="module">
132
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
133
- * console.log(Monster.Types.isBoolean('2')) // ↦ false
134
- * console.log(Monster.Types.isBoolean([])) // ↦ false
135
- * console.log(Monster.Types.isBoolean(true)) // ↦ true
140
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
141
+ * Monster.Types.isBoolean('2') // ↦ false
142
+ * Monster.Types.isBoolean([]) // ↦ false
143
+ * Monster.Types.isBoolean(true) // ↦ true
136
144
  * </script>
137
145
  * ```
138
146
  *
@@ -140,10 +148,10 @@ function isSymbol(value) {
140
148
  *
141
149
  * ```
142
150
  * <script type="module">
143
- * import {isBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
144
- * console.log(isBoolean('2')) // ↦ false
145
- * console.log(isBoolean([])) // ↦ false
146
- * console.log(isBoolean(2>4)) // ↦ true
151
+ * import {isBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
152
+ * isBoolean('2')) // ↦ false
153
+ * isBoolean([])) // ↦ false
154
+ * isBoolean(2>4)) // ↦ true
147
155
  * </script>
148
156
  * ```
149
157
  *
@@ -163,15 +171,17 @@ function isBoolean(value) {
163
171
  }
164
172
 
165
173
  /**
166
- * checks whether the value passed is a string
174
+ * Checks whether the value passed is a string
175
+ *
176
+ * This method is used in the library to have consistent names.
167
177
  *
168
- * you can call the method via the monster namespace `Monster.Types.isString()`.
178
+ * You can call the method via the monster namespace `Monster.Types.isString()`.
169
179
  *
170
180
  * ```
171
181
  * <script type="module">
172
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
173
- * console.log(Monster.Types.isString('2')) // ↦ true
174
- * console.log(Monster.Types.isString([])) // ↦ false
182
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
183
+ * Monster.Types.isString('2') // ↦ true
184
+ * Monster.Types.isString([]) // ↦ false
175
185
  * </script>
176
186
  * ```
177
187
  *
@@ -179,9 +189,9 @@ function isBoolean(value) {
179
189
  *
180
190
  * ```
181
191
  * <script type="module">
182
- * import {isString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
183
- * console.log(isString('2')) // ↦ true
184
- * console.log(isString([])) // ↦ false
192
+ * import {isString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
193
+ * isString('2')) // ↦ true
194
+ * isString([])) // ↦ false
185
195
  * </script>
186
196
  * ```
187
197
  *
@@ -199,16 +209,18 @@ function isString(value) {
199
209
  }
200
210
 
201
211
  /**
202
- * checks whether the value passed is a object
212
+ * Checks whether the value passed is a object
213
+ *
214
+ * This method is used in the library to have consistent names.
203
215
  *
204
- * you can call the method via the monster namespace `Monster.Types.isObject()`.
216
+ * You can call the method via the monster namespace `Monster.Types.isObject()`.
205
217
  *
206
218
  * ```
207
219
  * <script type="module">
208
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
209
- * console.log(Monster.Types.isObject('2')) // ↦ false
210
- * console.log(Monster.Types.isObject([])) // ↦ false
211
- * console.log(Monster.Types.isObject({})) // ↦ true
220
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
221
+ * Monster.Types.isObject('2') // ↦ false
222
+ * Monster.Types.isObject([]) // ↦ false
223
+ * Monster.Types.isObject({}) // ↦ true
212
224
  * </script>
213
225
  * ```
214
226
  *
@@ -216,9 +228,9 @@ function isString(value) {
216
228
  *
217
229
  * ```
218
230
  * <script type="module">
219
- * import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
220
- * console.log(isObject('2')) // ↦ false
221
- * console.log(isObject([])) // ↦ false
231
+ * import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
232
+ * isObject('2')) // ↦ false
233
+ * isObject([])) // ↦ false
222
234
  * </script>
223
235
  * ```
224
236
  *
@@ -241,16 +253,18 @@ function isObject(value) {
241
253
  }
242
254
 
243
255
  /**
244
- * checks whether the value passed is a object and instance of instance
256
+ * Checks whether the value passed is a object and instance of instance.
257
+ *
258
+ * This method is used in the library to have consistent names.
245
259
  *
246
260
  * you can call the method via the monster namespace `Monster.Types.isInstance()`.
247
261
  *
248
262
  * ```
249
263
  * <script type="module">
250
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
251
- * console.log(Monster.Types.isInstance('2')) // ↦ false
252
- * console.log(Monster.Types.isInstance([])) // ↦ false
253
- * console.log(Monster.Types.isInstance({})) // ↦ true
264
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
265
+ * Monster.Types.isInstance('2') // ↦ false
266
+ * Monster.Types.isInstance([]) // ↦ false
267
+ * Monster.Types.isInstance({}) // ↦ true
254
268
  * </script>
255
269
  * ```
256
270
  *
@@ -258,9 +272,9 @@ function isObject(value) {
258
272
  *
259
273
  * ```
260
274
  * <script type="module">
261
- * import {isInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
262
- * console.log(isInstance('2')) // ↦ false
263
- * console.log(isInstance([])) // ↦ false
275
+ * import {isInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
276
+ * isInstance('2')) // ↦ false
277
+ * isInstance([])) // ↦ false
264
278
  * </script>
265
279
  * ```
266
280
  *
@@ -281,15 +295,17 @@ function isInstance(value, instance) {
281
295
  }
282
296
 
283
297
  /**
284
- * checks whether the value passed is a array
298
+ * Checks whether the value passed is a array
299
+ *
300
+ * This method is used in the library to have consistent names.
285
301
  *
286
302
  * you can call the method via the monster namespace `Monster.Types.isArray()`.
287
303
  *
288
304
  * ```
289
305
  * <script type="module">
290
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
291
- * console.log(Monster.Types.isArray('2')) // ↦ false
292
- * console.log(Monster.Types.isArray([])) // ↦ true
306
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
307
+ * Monster.Types.isArray('2') // ↦ false
308
+ * Monster.Types.isArray([]) // ↦ true
293
309
  * </script>
294
310
  * ```
295
311
  *
@@ -297,9 +313,9 @@ function isInstance(value, instance) {
297
313
  *
298
314
  * ```
299
315
  * <script type="module">
300
- * import {isArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
301
- * console.log(isArray('2')) // ↦ false
302
- * console.log(isArray([])) // ↦ true
316
+ * import {isArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
317
+ * isArray('2')) // ↦ false
318
+ * isArray([])) // ↦ true
303
319
  * </script>
304
320
  * ```
305
321
  *
@@ -308,25 +324,25 @@ function isInstance(value, instance) {
308
324
  * @since 1.0.0
309
325
  * @copyright schukai GmbH
310
326
  * @memberOf Monster.Types
327
+ * @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
311
328
  */
312
329
  function isArray(value) {
313
- if (Array.isArray(value)) {
314
- return true;
315
- }
316
- return false;
330
+ return Array.isArray(value);
317
331
  }
318
332
 
319
333
  /**
320
- * checks whether the value passed is a function
334
+ * Checks whether the value passed is a function
335
+ *
336
+ * This method is used in the library to have consistent names.
321
337
  *
322
338
  * you can call the method via the monster namespace `Monster.Types.isFunction()`.
323
339
  *
324
340
  * ```
325
341
  * <script type="module">
326
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
327
- * console.log(Monster.Types.isFunction(()=>{})) // ↦ true
328
- * console.log(Monster.Types.isFunction('2')) // ↦ false
329
- * console.log(Monster.Types.isFunction([])) // ↦ false
342
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
343
+ * Monster.Types.isFunction(()=>{}) // ↦ true
344
+ * Monster.Types.isFunction('2') // ↦ false
345
+ * Monster.Types.isFunction([]) // ↦ false
330
346
  * </script>
331
347
  * ```
332
348
  *
@@ -334,10 +350,10 @@ function isArray(value) {
334
350
  *
335
351
  * ```
336
352
  * <script type="module">
337
- * import {isFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
338
- * console.log(isFunction(()=>{})) // ↦ true
339
- * console.log(isFunction('2')) // ↦ false
340
- * console.log(isFunction([])) // ↦ false
353
+ * import {isFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
354
+ * isFunction(()=>{}) // ↦ true
355
+ * isFunction('2')) // ↦ false
356
+ * isFunction([])) // ↦ false
341
357
  * </script>
342
358
  * ```
343
359
  *
@@ -360,16 +376,18 @@ function isFunction(value) {
360
376
  }
361
377
 
362
378
  /**
363
- * checks whether the value passed is an integer
379
+ * Checks whether the value passed is an integer.
380
+ *
381
+ * This method is used in the library to have consistent names.
364
382
  *
365
- * you can call the method via the monster namespace `Monster.Types.isFunction()`.
383
+ * You can call the method via the monster namespace `Monster.Types.isFunction()`.
366
384
  *
367
385
  * ```
368
386
  * <script type="module">
369
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
370
- * console.log(Monster.Types.isInteger(()=>{})) // ↦ true
371
- * console.log(Monster.Types.isInteger('2')) // ↦ false
372
- * console.log(Monster.Types.isInteger(2)) // ↦ true
387
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
388
+ * Monster.Types.isInteger(()=>{}) // ↦ true
389
+ * Monster.Types.isInteger('2') // ↦ false
390
+ * Monster.Types.isInteger(2) // ↦ true
373
391
  * </script>
374
392
  * ```
375
393
  *
@@ -377,10 +395,10 @@ function isFunction(value) {
377
395
  *
378
396
  * ```
379
397
  * <script type="module">
380
- * import {isInteger} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/is.js';
381
- * console.log(isInteger(()=>{})) // ↦ true
382
- * console.log(isInteger('2')) // ↦ false
383
- * console.log(isInteger(2)) // ↦ true
398
+ * import {isInteger} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/is.js';
399
+ * isInteger(()=>{}) // ↦ true
400
+ * isInteger('2')) // ↦ false
401
+ * isInteger(2)) // ↦ true
384
402
  * </script>
385
403
  * ```
386
404
  *
@@ -28,7 +28,7 @@ const internal = Symbol('internal');
28
28
  *
29
29
  * ```
30
30
  * <script type="module">
31
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/mediatype.js';
31
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
32
32
  * console.log(new Monster.Types.MediaType())
33
33
  * </script>
34
34
  * ```
@@ -37,7 +37,7 @@ const internal = Symbol('internal');
37
37
  *
38
38
  * ```
39
39
  * <script type="module">
40
- * import {MediaType} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/mediatype.js';
40
+ * import {MediaType} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/mediatype.js';
41
41
  * console.log(new MediaType())
42
42
  * </script>
43
43
  * ```
@@ -137,7 +137,7 @@ class MediaType extends Base {
137
137
  *
138
138
  * ```
139
139
  * <script type="module">
140
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/dataurl.js';
140
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
141
141
  * console.log(Monster.Types.parseMediaType())
142
142
  * </script>
143
143
  * ```
@@ -146,7 +146,7 @@ class MediaType extends Base {
146
146
  *
147
147
  * ```
148
148
  * <script type="module">
149
- * import {parseMediaType} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.24.0/dist/modules/types/dataurl.js';
149
+ * import {parseMediaType} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/dataurl.js';
150
150
  * console.log(parseMediaType())
151
151
  * </script>
152
152
  * ```
@@ -0,0 +1,179 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @author schukai GmbH
5
+ */
6
+
7
+
8
+ import {assignToNamespace, Monster} from '../namespace.js';
9
+ import {Base} from './base.js';
10
+ import {NodeList} from './nodelist.js';
11
+ import {validateInstance} from './validate.js';
12
+
13
+ /**
14
+ * @private
15
+ * @type {symbol}
16
+ */
17
+ const internalValueSymbol = Symbol('internalData');
18
+
19
+ /**
20
+ * @private
21
+ * @type {symbol}
22
+ */
23
+ const treeStructureSymbol = Symbol('treeStructure');
24
+
25
+
26
+ /**
27
+ * You can create the instance via the monster namespace `new Monster.Types.Node()`.
28
+ *
29
+ * ```
30
+ * <script type="module">
31
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/monster.js';
32
+ * new Monster.Types.Node()
33
+ * </script>
34
+ * ```
35
+ *
36
+ * Alternatively, you can also integrate this function individually.
37
+ *
38
+ * ```
39
+ * <script type="module">
40
+ * import {Node} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.27.0/dist/modules/types/node.js';
41
+ * new Node()
42
+ * </script>
43
+ * ```
44
+ *
45
+ * @since 1.26.0
46
+ * @copyright schukai GmbH
47
+ * @memberOf Monster.Types
48
+ * @summary A Node Class
49
+ * @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Iteration_protocols
50
+ */
51
+ class Node extends Base {
52
+
53
+ /**
54
+ * @param {*} [value]
55
+ */
56
+ constructor(value) {
57
+ super();
58
+ this[internalValueSymbol] = value;
59
+
60
+ this[treeStructureSymbol] = {
61
+ parent: null,
62
+ childNodes: new NodeList,
63
+ level: 0
64
+ }
65
+
66
+ }
67
+
68
+ /**
69
+ * @property {*}
70
+ */
71
+ get value() {
72
+ return this[internalValueSymbol];
73
+ }
74
+
75
+ /**
76
+ * @property {*}
77
+ */
78
+ set value(value) {
79
+ this[internalValueSymbol] = value;
80
+ }
81
+
82
+ /**
83
+ * @property {Monster.Types.Node|null}
84
+ */
85
+ get parent() {
86
+ return this[treeStructureSymbol].parent;
87
+ }
88
+
89
+ /**
90
+ * @property {integer}
91
+ */
92
+ get level() {
93
+ return this[treeStructureSymbol].level;
94
+ }
95
+
96
+ /**
97
+ *
98
+ * @property {NodeList}
99
+ */
100
+ get childNodes() {
101
+ return this[treeStructureSymbol].childNodes;
102
+ }
103
+
104
+ /**
105
+ *
106
+ * @property {NodeList}
107
+ */
108
+ set childNodes(childNodes) {
109
+ this[treeStructureSymbol].childNodes = validateInstance(childNodes, NodeList);
110
+ setChildLevelAndParent.call(this, this, 1);
111
+ }
112
+
113
+ /**
114
+ * @return {Monster.Types.Node}
115
+ * @param {Node} node
116
+ */
117
+ appendChild(node) {
118
+ this[treeStructureSymbol].childNodes.add(validateInstance(node, Node));
119
+ node[treeStructureSymbol].parent = this;
120
+
121
+ node[treeStructureSymbol].level = this.level + 1;
122
+ setChildLevelAndParent.call(this, node, 1);
123
+ return this;
124
+ }
125
+
126
+ /**
127
+ * @return {Monster.Types.Node}
128
+ * @param {Node} node
129
+ */
130
+ removeChild(node) {
131
+ this[treeStructureSymbol].childNodes.remove(validateInstance(node, Node));
132
+ node[treeStructureSymbol].parent = null;
133
+
134
+ node[treeStructureSymbol].level = 0;
135
+ setChildLevelAndParent.call(this, node, -1);
136
+ return this;
137
+ }
138
+
139
+ /**
140
+ *
141
+ * @return {boolean}
142
+ */
143
+ hasChildNodes() {
144
+ return this[treeStructureSymbol].childNodes.length > 0;
145
+ }
146
+
147
+ /**
148
+ * @return {Monster.Types.Node}
149
+ * @param {Node} node
150
+ */
151
+ hasChild(node) {
152
+ return this[treeStructureSymbol].childNodes.has(validateInstance(node, Node));
153
+ }
154
+
155
+ }
156
+
157
+ /**
158
+ * @private
159
+ * @param {Node} node
160
+ * @param {int} operand
161
+ * @return {setChildLevelAndParent}
162
+ */
163
+ function setChildLevelAndParent(node, operand) {
164
+ const self = this;
165
+
166
+ if (node !== this) {
167
+ node[treeStructureSymbol].parent = this
168
+ }
169
+
170
+ node[treeStructureSymbol].childNodes.forEach(function (child) {
171
+ child[treeStructureSymbol].parent = node;
172
+ child[treeStructureSymbol].level = node[treeStructureSymbol].level + operand;
173
+ setChildLevelAndParent.call(self, child, operand);
174
+ });
175
+ return this;
176
+ }
177
+
178
+ assignToNamespace('Monster.Types', Node);
179
+ export {Monster, Node}