@schukai/monster 1.14.0 → 1.15.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +38 -0
- package/README.md +5 -5
- package/dist/modules/constants.js +2 -2
- package/dist/modules/constraints/abstract.js +2 -2
- package/dist/modules/constraints/abstractoperator.js +2 -2
- package/dist/modules/constraints/andoperator.js +2 -2
- package/dist/modules/constraints/invalid.js +2 -2
- package/dist/modules/constraints/isarray.js +2 -2
- package/dist/modules/constraints/isobject.js +2 -2
- package/dist/modules/constraints/namespace.js +1 -1
- package/dist/modules/constraints/oroperator.js +2 -2
- package/dist/modules/constraints/valid.js +2 -2
- package/dist/modules/data/buildmap.js +2 -2
- package/dist/modules/data/diff.js +2 -2
- package/dist/modules/data/extend.js +2 -2
- package/dist/modules/data/namespace.js +1 -1
- package/dist/modules/data/pathfinder.js +2 -2
- package/dist/modules/data/pipe.js +2 -2
- package/dist/modules/data/transformer.js +2 -2
- package/dist/modules/dom/assembler.js +2 -2
- package/dist/modules/dom/attributes.js +2 -2
- package/dist/modules/dom/constants.js +1 -1
- package/dist/modules/dom/customcontrol.js +2 -2
- package/dist/modules/dom/customelement.js +2 -2
- package/dist/modules/dom/events.js +2 -2
- package/dist/modules/dom/locale.js +2 -2
- package/dist/modules/dom/namespace.js +1 -1
- package/dist/modules/dom/template.js +2 -2
- package/dist/modules/dom/theme.js +2 -2
- package/dist/modules/dom/updater.js +2 -2
- package/dist/modules/dom/util.js +2 -2
- package/dist/modules/i18n/locale.js +2 -2
- package/dist/modules/i18n/namespace.js +1 -1
- package/dist/modules/i18n/provider.js +2 -2
- package/dist/modules/i18n/providers/fetch.js +2 -2
- package/dist/modules/i18n/providers/namespace.js +1 -1
- package/dist/modules/i18n/translations.js +2 -2
- package/dist/modules/logging/handler/console.js +2 -2
- package/dist/modules/logging/handler/namespace.js +1 -1
- package/dist/modules/logging/handler.js +2 -2
- package/dist/modules/logging/logentry.js +2 -2
- package/dist/modules/logging/logger.js +2 -2
- package/dist/modules/logging/namespace.js +1 -1
- package/dist/modules/math/namespace.js +1 -1
- package/dist/modules/math/random.js +2 -2
- package/dist/modules/monster.js +2 -2
- package/dist/modules/namespace.js +2 -2
- package/dist/modules/text/formatter.js +2 -2
- package/dist/modules/text/namespace.js +1 -1
- package/dist/modules/types/base.js +2 -2
- package/dist/modules/types/basewithoptions.js +2 -2
- package/dist/modules/types/global.js +2 -2
- package/dist/modules/types/id.js +2 -2
- package/dist/modules/types/is.js +2 -2
- package/dist/modules/types/namespace.js +1 -1
- package/dist/modules/types/observer.js +2 -2
- package/dist/modules/types/observerlist.js +2 -2
- package/dist/modules/types/proxyobserver.js +2 -2
- package/dist/modules/types/queue.js +2 -2
- package/dist/modules/types/randomid.js +2 -2
- package/dist/modules/types/stack.js +2 -2
- package/dist/modules/types/tokenlist.js +2 -2
- package/dist/modules/types/typeof.js +2 -2
- package/dist/modules/types/uniquequeue.js +2 -2
- package/dist/modules/types/validate.js +2 -2
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +2 -2
- package/dist/modules/util/comparator.js +2 -2
- package/dist/modules/util/freeze.js +2 -2
- package/dist/modules/util/namespace.js +1 -1
- package/dist/monster.dev.js +8263 -7501
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -9
- package/package.json +1 -1
- package/source/constants.js +6 -5
- package/source/constraints/abstract.js +2 -2
- package/source/constraints/abstractoperator.js +4 -4
- package/source/constraints/andoperator.js +8 -8
- package/source/constraints/invalid.js +6 -6
- package/source/constraints/isarray.js +7 -7
- package/source/constraints/isobject.js +7 -7
- package/source/constraints/namespace.js +2 -2
- package/source/constraints/oroperator.js +8 -8
- package/source/constraints/valid.js +7 -7
- package/source/data/buildmap.js +15 -15
- package/source/data/diff.js +9 -9
- package/source/data/extend.js +55 -13
- package/source/data/namespace.js +2 -2
- package/source/data/pathfinder.js +13 -14
- package/source/data/pipe.js +8 -8
- package/source/data/transformer.js +10 -11
- package/source/dom/assembler.js +7 -7
- package/source/dom/attributes.js +27 -28
- package/source/dom/constants.js +1 -2
- package/source/dom/customcontrol.js +90 -128
- package/source/dom/customelement.js +166 -71
- package/source/dom/events.js +9 -9
- package/source/dom/locale.js +5 -5
- package/source/dom/namespace.js +2 -2
- package/source/dom/template.js +30 -19
- package/source/dom/theme.js +8 -9
- package/source/dom/updater.js +43 -26
- package/source/dom/util.js +11 -11
- package/source/i18n/locale.js +7 -7
- package/source/i18n/namespace.js +1 -1
- package/source/i18n/provider.js +6 -6
- package/source/i18n/providers/fetch.js +10 -10
- package/source/i18n/translations.js +5 -5
- package/source/logging/handler/console.js +5 -5
- package/source/logging/handler/namespace.js +1 -1
- package/source/logging/handler.js +8 -8
- package/source/logging/logentry.js +5 -5
- package/source/logging/logger.js +5 -5
- package/source/logging/namespace.js +2 -2
- package/source/math/namespace.js +2 -2
- package/source/math/random.js +5 -5
- package/source/monster.js +48 -44
- package/source/namespace.js +2 -2
- package/source/text/formatter.js +6 -7
- package/source/text/namespace.js +1 -1
- package/source/types/base.js +4 -5
- package/source/types/basewithoptions.js +10 -9
- package/source/types/global.js +7 -7
- package/source/types/id.js +7 -7
- package/source/types/is.js +22 -22
- package/source/types/namespace.js +2 -2
- package/source/types/observer.js +7 -7
- package/source/types/observerlist.js +4 -4
- package/source/types/proxyobserver.js +32 -26
- package/source/types/queue.js +13 -7
- package/source/types/randomid.js +6 -6
- package/source/types/stack.js +11 -4
- package/source/types/tokenlist.js +9 -9
- package/source/types/typeof.js +5 -5
- package/source/types/uniquequeue.js +14 -7
- package/source/types/validate.js +27 -27
- package/source/types/version.js +9 -9
- package/source/util/clone.js +6 -6
- package/source/util/comparator.js +7 -7
- package/source/util/freeze.js +7 -7
- package/source/util/namespace.js +2 -2
- package/test/cases/data/extend.js +66 -13
- package/test/cases/dom/customcontrol.js +17 -3
- package/test/cases/dom/customelement.js +65 -7
- package/test/cases/dom/template.js +40 -1
- package/test/cases/monster.js +1 -1
- package/test/cases/types/proxyobserver.js +9 -0
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +2 -2
- package/test/web/test.html +3 -3
- package/test/web/tests.js +3 -3
package/source/types/global.js
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
6
|
|
7
|
-
import {Monster} from '../namespace.js';
|
8
|
-
import {validateFunction,
|
7
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
8
|
+
import {validateFunction, validateObject, validateString} from "./validate.js";
|
9
9
|
|
10
10
|
/**
|
11
11
|
* @type {objec}
|
@@ -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.
|
81
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
90
|
+
* import {getGlobalObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
118
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
127
|
+
* import {getGlobalFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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
|
-
|
149
|
+
assignToNamespace('Monster.Types', getGlobal, getGlobalObject, getGlobalFunction);
|
150
150
|
export {Monster, getGlobal, getGlobalObject, getGlobalFunction}
|
package/source/types/id.js
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
|
-
*/
|
6
|
-
|
7
|
-
import {
|
5
|
+
*/
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {Base} from './base.js';
|
8
8
|
import {validateString} from "./validate.js";
|
9
9
|
|
10
10
|
/**
|
@@ -23,8 +23,8 @@ let internalCounter = new Map;
|
|
23
23
|
* You can call the method via the monster namespace `new Monster.Types.ID()`.
|
24
24
|
*
|
25
25
|
* ```
|
26
|
-
* <script type="module">
|
27
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
26
|
+
* <script type="module">
|
27
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
36
|
+
* import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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
|
-
|
80
|
+
assignToNamespace('Monster.Types', ID);
|
81
81
|
export {Monster, ID}
|
package/source/types/is.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
6
|
|
7
|
-
import {Monster} from '../namespace.js';
|
7
|
+
import {assignToNamespace, Monster} 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.
|
16
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
27
|
+
* import {isIterable} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
54
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
64
|
+
* import {isPrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
99
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
109
|
+
* import {isSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
132
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
143
|
+
* import {isBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
172
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
182
|
+
* import {isString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
208
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
219
|
+
* import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
250
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
261
|
+
* import {isInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
290
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
300
|
+
* import {isArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
326
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
337
|
+
* import {isFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
369
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
380
|
+
* import {isInteger} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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
|
-
|
398
|
+
assignToNamespace('Monster.Types', isPrimitive, isBoolean, isString, isObject, isArray, isFunction, isIterable, isInteger, isSymbol);
|
399
399
|
export {
|
400
400
|
Monster,
|
401
401
|
isPrimitive,
|
package/source/types/observer.js
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
6
|
|
7
|
-
import {Monster} from '../namespace.js';
|
8
|
-
import {TokenList} from './tokenlist.js';
|
9
|
-
import {isObject} from './is.js';
|
7
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
10
8
|
import {Base} from './base.js';
|
9
|
+
import {isObject} from './is.js';
|
10
|
+
import {TokenList} from './tokenlist.js';
|
11
11
|
import {UniqueQueue} from './uniquequeue.js';
|
12
12
|
|
13
13
|
/**
|
@@ -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.
|
20
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
29
|
+
* import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
63
|
+
* import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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
|
-
|
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 {assignToNamespace, Monster} 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.
|
19
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
29
|
+
* import {ObserverList} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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
|
-
|
117
|
+
assignToNamespace('Monster.Types', ObserverList);
|
118
118
|
export {Monster, ObserverList}
|
@@ -3,30 +3,30 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import {ObserverList} from "./observerlist.js";
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {Base} from './base.js';
|
8
|
+
import {isArray, isObject, isPrimitive} from "./is.js";
|
10
9
|
import {Observer} from "./observer.js";
|
11
|
-
import {
|
10
|
+
import {ObserverList} from "./observerlist.js";
|
11
|
+
import {validateObject} from "./validate.js";
|
12
12
|
|
13
13
|
/**
|
14
14
|
* An observer manages a callback function
|
15
15
|
*
|
16
|
-
* You can call the
|
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.
|
20
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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
|
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.
|
29
|
+
* import {ProxyObserver} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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.
|
41
|
-
* import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
42
|
-
* import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
40
|
+
* import {ProxyObserver} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/types/proxyobserver.js';
|
41
|
+
* import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/types/observer.js';
|
42
|
+
* import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/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
|
-
|
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 {
|
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
|
-
|
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
|
-
|
199
|
-
|
204
|
+
if (proxy.proxyMap.has(value)) {
|
205
|
+
value = proxy.proxyMap.get(value);
|
206
|
+
}
|
200
207
|
|
208
|
+
if (proxy.proxyMap.has(target)) {
|
209
|
+
target = proxy.proxyMap.get(target);
|
210
|
+
}
|
201
211
|
|
202
212
|
let current = Reflect.get(target, key, receiver);
|
213
|
+
if (proxy.proxyMap.has(current)) {
|
214
|
+
current = proxy.proxyMap.get(current);
|
215
|
+
}
|
203
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) {
|
package/source/types/queue.js
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
-
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @author schukai GmbH
|
5
|
+
*/
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {Base} from './base.js';
|
2
8
|
|
3
9
|
/**
|
4
10
|
* You can call the method via the monster namespace `new Monster.Types.Queue()`.
|
5
11
|
*
|
6
12
|
* ```
|
7
13
|
* <script type="module">
|
8
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
14
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/types/queue.js';
|
9
15
|
* console.log(new Monster.Types.Queue())
|
10
16
|
* </script>
|
11
17
|
* ```
|
@@ -14,14 +20,14 @@ import {Monster, Base} from './base.js';
|
|
14
20
|
*
|
15
21
|
* ```
|
16
22
|
* <script type="module">
|
17
|
-
* import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
23
|
+
* import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/types/queue.js';
|
18
24
|
* console.log(new Queue())
|
19
25
|
* </script>
|
20
26
|
* ```
|
21
|
-
*
|
27
|
+
*
|
22
28
|
* @example
|
23
29
|
*
|
24
|
-
* import {Queue} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
30
|
+
* import {Queue} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/types/queue.js';
|
25
31
|
*
|
26
32
|
* const queue = new Queue;
|
27
33
|
*
|
@@ -46,7 +52,7 @@ import {Monster, Base} from './base.js';
|
|
46
52
|
* @copyright schukai GmbH
|
47
53
|
* @memberOf Monster/Types
|
48
54
|
*/
|
49
|
-
class Queue extends Base {
|
55
|
+
class Queue extends Base {
|
50
56
|
|
51
57
|
/**
|
52
58
|
*
|
@@ -114,5 +120,5 @@ class Queue extends Base {
|
|
114
120
|
|
115
121
|
}
|
116
122
|
|
117
|
-
|
123
|
+
assignToNamespace('Monster.Types', Queue);
|
118
124
|
export {Monster, Queue}
|
package/source/types/randomid.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
import {random} from "../math/random.js";
|
3
4
|
/**
|
4
5
|
* @author schukai GmbH
|
5
6
|
*/
|
6
|
-
|
7
|
-
import {Monster, ID} from "./id.js";
|
7
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
8
8
|
import {getGlobal} from "./global.js";
|
9
|
-
import {
|
9
|
+
import {ID} from "./id.js";
|
10
10
|
|
11
11
|
/**
|
12
12
|
* @private
|
@@ -19,7 +19,7 @@ let internalCounter = 0;
|
|
19
19
|
*
|
20
20
|
* ```
|
21
21
|
* <script type="module">
|
22
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
22
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/types/randomid.js';
|
23
23
|
* console.log(new Monster.Types.RandomID())
|
24
24
|
* </script>
|
25
25
|
* ```
|
@@ -28,7 +28,7 @@ let internalCounter = 0;
|
|
28
28
|
*
|
29
29
|
* ```
|
30
30
|
* <script type="module">
|
31
|
-
* import {RandomID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
31
|
+
* import {RandomID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/types/randomid.js';
|
32
32
|
* console.log(new RandomID())
|
33
33
|
* </script>
|
34
34
|
* ```
|
@@ -55,5 +55,5 @@ class RandomID extends ID {
|
|
55
55
|
|
56
56
|
}
|
57
57
|
|
58
|
-
|
58
|
+
assignToNamespace('Monster.Types', RandomID);
|
59
59
|
export {Monster, RandomID}
|