@schukai/monster 1.17.1 → 1.20.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +32 -0
- package/README.md +4 -4
- package/dist/modules/constants.js +1 -1
- package/dist/modules/constraints/abstract.js +1 -1
- package/dist/modules/constraints/abstractoperator.js +1 -1
- package/dist/modules/constraints/andoperator.js +1 -1
- package/dist/modules/constraints/invalid.js +1 -1
- package/dist/modules/constraints/isarray.js +1 -1
- package/dist/modules/constraints/isobject.js +1 -1
- package/dist/modules/constraints/namespace.js +1 -1
- package/dist/modules/constraints/oroperator.js +1 -1
- package/dist/modules/constraints/valid.js +1 -1
- package/dist/modules/data/buildmap.js +1 -1
- package/dist/modules/data/diff.js +2 -2
- package/dist/modules/data/extend.js +1 -1
- package/dist/modules/data/namespace.js +1 -1
- package/dist/modules/data/pathfinder.js +1 -1
- package/dist/modules/data/pipe.js +1 -1
- package/dist/modules/data/transformer.js +1 -1
- package/dist/modules/dom/assembler.js +1 -1
- package/dist/modules/dom/attributes.js +1 -1
- package/dist/modules/dom/constants.js +1 -1
- package/dist/modules/dom/customcontrol.js +1 -1
- package/dist/modules/dom/customelement.js +2 -2
- package/dist/modules/dom/events.js +2 -2
- package/dist/modules/dom/locale.js +1 -1
- package/dist/modules/dom/namespace.js +1 -1
- package/dist/modules/dom/template.js +1 -1
- package/dist/modules/dom/theme.js +1 -1
- package/dist/modules/dom/updater.js +1 -1
- package/dist/modules/dom/util.js +1 -1
- package/dist/modules/i18n/locale.js +1 -1
- package/dist/modules/i18n/namespace.js +1 -1
- package/dist/modules/i18n/provider.js +1 -1
- package/dist/modules/i18n/providers/fetch.js +1 -1
- package/dist/modules/i18n/providers/namespace.js +1 -1
- package/dist/modules/i18n/translations.js +1 -1
- package/dist/modules/logging/handler/console.js +1 -1
- package/dist/modules/logging/handler/namespace.js +1 -1
- package/dist/modules/logging/handler.js +1 -1
- package/dist/modules/logging/logentry.js +1 -1
- package/dist/modules/logging/logger.js +1 -1
- package/dist/modules/logging/namespace.js +1 -1
- package/dist/modules/math/namespace.js +1 -1
- package/dist/modules/math/random.js +1 -1
- package/dist/modules/monster.js +1 -1
- package/dist/modules/namespace.js +1 -1
- package/dist/modules/text/formatter.js +1 -1
- package/dist/modules/text/namespace.js +1 -1
- package/dist/modules/types/base.js +1 -1
- package/dist/modules/types/basewithoptions.js +1 -1
- package/dist/modules/types/binary.js +2 -0
- package/dist/modules/types/dataurl.js +2 -0
- package/dist/modules/types/global.js +1 -1
- package/dist/modules/types/id.js +1 -1
- package/dist/modules/types/is.js +2 -2
- package/dist/modules/types/mediatype.js +2 -0
- package/dist/modules/types/namespace.js +1 -1
- package/dist/modules/types/observer.js +1 -1
- package/dist/modules/types/observerlist.js +1 -1
- package/dist/modules/types/proxyobserver.js +1 -1
- package/dist/modules/types/queue.js +1 -1
- package/dist/modules/types/randomid.js +1 -1
- package/dist/modules/types/stack.js +1 -1
- package/dist/modules/types/tokenlist.js +1 -1
- package/dist/modules/types/typeof.js +1 -1
- package/dist/modules/types/uniquequeue.js +1 -1
- package/dist/modules/types/validate.js +1 -1
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +1 -1
- package/dist/modules/util/comparator.js +1 -1
- package/dist/modules/util/freeze.js +1 -1
- package/dist/modules/util/namespace.js +1 -1
- package/dist/monster.dev.js +1018 -341
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -2
- package/package.json +6 -1
- package/source/constraints/andoperator.js +5 -5
- package/source/constraints/invalid.js +3 -3
- package/source/constraints/isarray.js +3 -3
- package/source/constraints/isobject.js +3 -3
- package/source/constraints/oroperator.js +5 -5
- package/source/constraints/valid.js +3 -3
- package/source/data/buildmap.js +6 -6
- package/source/data/diff.js +4 -4
- package/source/data/extend.js +2 -2
- package/source/data/pathfinder.js +4 -4
- package/source/data/pipe.js +3 -3
- package/source/data/transformer.js +3 -3
- package/source/dom/assembler.js +3 -2
- package/source/dom/attributes.js +27 -27
- package/source/dom/customcontrol.js +22 -13
- package/source/dom/customelement.js +126 -6
- package/source/dom/events.js +21 -9
- package/source/dom/locale.js +3 -2
- package/source/dom/template.js +18 -6
- package/source/dom/theme.js +4 -3
- package/source/dom/updater.js +9 -6
- package/source/dom/util.js +6 -6
- package/source/i18n/locale.js +4 -4
- package/source/i18n/provider.js +3 -3
- package/source/i18n/providers/fetch.js +5 -5
- package/source/i18n/translations.js +2 -2
- package/source/logging/handler/console.js +2 -2
- package/source/logging/handler.js +2 -2
- package/source/logging/logentry.js +2 -2
- package/source/logging/logger.js +2 -2
- package/source/math/random.js +2 -2
- package/source/namespace.js +1 -1
- package/source/text/formatter.js +2 -2
- package/source/types/base.js +2 -2
- package/source/types/basewithoptions.js +2 -2
- package/source/types/binary.js +92 -0
- package/source/types/dataurl.js +176 -0
- package/source/types/global.js +4 -4
- package/source/types/id.js +2 -2
- package/source/types/is.js +21 -21
- package/source/types/mediatype.js +236 -0
- package/source/types/observer.js +3 -3
- package/source/types/observerlist.js +2 -2
- package/source/types/package.d.ts +1 -0
- package/source/types/proxyobserver.js +5 -5
- package/source/types/queue.js +4 -3
- package/source/types/randomid.js +3 -2
- package/source/types/stack.js +2 -2
- package/source/types/tokenlist.js +2 -2
- package/source/types/typeof.js +3 -3
- package/source/types/uniquequeue.js +3 -2
- package/source/types/validate.js +20 -20
- package/source/types/version.js +7 -6
- package/source/util/clone.js +2 -2
- package/source/util/comparator.js +3 -3
- package/source/util/freeze.js +2 -2
- package/test/cases/data/diff.js +29 -2
- package/test/cases/dom/customelement.js +85 -12
- package/test/cases/dom/events.js +5 -3
- package/test/cases/monster.js +1 -1
- package/test/cases/types/binary.js +27 -0
- package/test/cases/types/dataurl.js +58 -0
- package/test/cases/types/mediatype.js +60 -0
- package/test/web/import.js +3 -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/is.js
CHANGED
@@ -13,7 +13,7 @@ import {assignToNamespace, Monster} from '../namespace.js';
|
|
13
13
|
*
|
14
14
|
* ```
|
15
15
|
* <script type="module">
|
16
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
16
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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 {assignToNamespace, 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.20.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.
|
54
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
64
|
+
* import {isPrimitive} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/is.js';
|
65
65
|
* console.log(isPrimitive('2')) // ↦ true
|
66
66
|
* console.log(isPrimitive([])) // ↦ false
|
67
67
|
* </script>
|
@@ -76,7 +76,7 @@ function isIterable(value) {
|
|
76
76
|
function isPrimitive(value) {
|
77
77
|
var type;
|
78
78
|
|
79
|
-
if (value === undefined || value === null
|
79
|
+
if (value === undefined || value === null) {
|
80
80
|
return true;
|
81
81
|
}
|
82
82
|
|
@@ -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.20.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.
|
109
|
+
* import {isSymbol} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
132
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
143
|
+
* import {isBoolean} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
172
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
182
|
+
* import {isString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
208
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
219
|
+
* import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
250
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
261
|
+
* import {isInstance} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
290
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
300
|
+
* import {isArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
326
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
337
|
+
* import {isFunction} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
369
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
380
|
+
* import {isInteger} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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
|
@@ -0,0 +1,236 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import {assignToNamespace} from "../namespace.js";
|
4
|
+
/**
|
5
|
+
* @author schukai GmbH
|
6
|
+
*/
|
7
|
+
import {Base, Monster} from "./base.js";
|
8
|
+
import {isString} from "./is.js";
|
9
|
+
import {validateArray, validateString} from "./validate.js";
|
10
|
+
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @private
|
14
|
+
* @type {symbol}
|
15
|
+
*/
|
16
|
+
const internal = Symbol('internal');
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @typedef {Object} Parameter
|
20
|
+
* @property {string} key
|
21
|
+
* @property {string} value
|
22
|
+
* @memberOf Monster.Types
|
23
|
+
*/
|
24
|
+
|
25
|
+
|
26
|
+
/**
|
27
|
+
* You can create an object via the monster namespace `new Monster.Types.MediaType()`.
|
28
|
+
*
|
29
|
+
* ```
|
30
|
+
* <script type="module">
|
31
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/mediatype.js';
|
32
|
+
* console.log(new Monster.Types.MediaType())
|
33
|
+
* </script>
|
34
|
+
* ```
|
35
|
+
*
|
36
|
+
* Alternatively, you can also integrate this function individually.
|
37
|
+
*
|
38
|
+
* ```
|
39
|
+
* <script type="module">
|
40
|
+
* import {MediaType} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/mediatype.js';
|
41
|
+
* console.log(new MediaType())
|
42
|
+
* </script>
|
43
|
+
* ```
|
44
|
+
*
|
45
|
+
* @since 1.8.0
|
46
|
+
* @copyright schukai GmbH
|
47
|
+
* @memberOf Monster.Types
|
48
|
+
*/
|
49
|
+
class MediaType extends Base {
|
50
|
+
|
51
|
+
/**
|
52
|
+
*
|
53
|
+
* @param {String} type
|
54
|
+
* @param {String} subtype
|
55
|
+
* @param {Monster.Types.Parameter[]} parameter
|
56
|
+
*/
|
57
|
+
constructor(type, subtype, parameter) {
|
58
|
+
super();
|
59
|
+
|
60
|
+
this[internal] = {
|
61
|
+
type: validateString(type).toLowerCase(),
|
62
|
+
subtype: validateString(subtype).toLowerCase(),
|
63
|
+
parameter: []
|
64
|
+
}
|
65
|
+
|
66
|
+
if (parameter !== undefined) {
|
67
|
+
this[internal]['parameter'] = validateArray(parameter);
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* @return {String}
|
75
|
+
*/
|
76
|
+
get type() {
|
77
|
+
return this[internal].type;
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @return {String}
|
82
|
+
*/
|
83
|
+
get subtype() {
|
84
|
+
return this[internal].subtype;
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* @return {Monster.Types.Parameter[]}
|
89
|
+
*/
|
90
|
+
get parameter() {
|
91
|
+
return this[internal].parameter;
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
*
|
96
|
+
*
|
97
|
+
* @return {Map}
|
98
|
+
*/
|
99
|
+
get parameter() {
|
100
|
+
|
101
|
+
const result = new Map
|
102
|
+
|
103
|
+
this[internal]['parameter'].forEach(p => {
|
104
|
+
|
105
|
+
let value = p.value;
|
106
|
+
|
107
|
+
// internally special values are partly stored with quotes, this function removes them.
|
108
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
109
|
+
value = value.substring(1, value.length - 1);
|
110
|
+
}
|
111
|
+
|
112
|
+
result.set(p.key, value);
|
113
|
+
})
|
114
|
+
|
115
|
+
|
116
|
+
return result;
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
*
|
121
|
+
* @return {string}
|
122
|
+
*/
|
123
|
+
toString() {
|
124
|
+
|
125
|
+
let parameter = [];
|
126
|
+
for (let a of this[internal].parameter) {
|
127
|
+
parameter.push(a.key + '=' + a.value);
|
128
|
+
}
|
129
|
+
|
130
|
+
return this[internal].type + '/' + this[internal].subtype + (parameter.length > 0 ? ';' + parameter.join(';') : '');
|
131
|
+
}
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
* You can call the function via the monster namespace `Monster.Types.parseMediaType()`.
|
137
|
+
*
|
138
|
+
* ```
|
139
|
+
* <script type="module">
|
140
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/dataurl.js';
|
141
|
+
* console.log(Monster.Types.parseMediaType())
|
142
|
+
* </script>
|
143
|
+
* ```
|
144
|
+
*
|
145
|
+
* Alternatively, you can also integrate this function individually.
|
146
|
+
*
|
147
|
+
* ```
|
148
|
+
* <script type="module">
|
149
|
+
* import {parseMediaType} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/dataurl.js';
|
150
|
+
* console.log(parseMediaType())
|
151
|
+
* </script>
|
152
|
+
* ```
|
153
|
+
*
|
154
|
+
* Specification:
|
155
|
+
*
|
156
|
+
* ```
|
157
|
+
* dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
|
158
|
+
* mediatype := [ type "/" subtype ] *( ";" parameter )
|
159
|
+
* data := *urlchar
|
160
|
+
* parameter := attribute "=" value
|
161
|
+
* ```
|
162
|
+
*
|
163
|
+
* @param {String} mediatype
|
164
|
+
* @return {Monster.Types.MediaType}
|
165
|
+
* @see https://datatracker.ietf.org/doc/html/rfc2045#section-5.1
|
166
|
+
* @throws {TypeError} the mimetype can not be parsed
|
167
|
+
* @throws {TypeError} blank value is not allowed
|
168
|
+
* @throws {TypeError} malformed data url
|
169
|
+
* @memberOf Monster.Types
|
170
|
+
*/
|
171
|
+
function parseMediaType(mediatype) {
|
172
|
+
|
173
|
+
const regex = /(?<type>[A-Za-z]+|\*)\/(?<subtype>([a-zA-Z0-9.\+_\-]+)|\*|)(?<parameter>\s*;\s*([a-zA-Z0-9]+)\s*(=\s*("?[A-Za-z0-9_\-]+"?))?)*/g;
|
174
|
+
const result = regex.exec(validateString(mediatype));
|
175
|
+
|
176
|
+
const groups = result?.['groups'];
|
177
|
+
if (groups === undefined) {
|
178
|
+
throw new TypeError('the mimetype can not be parsed')
|
179
|
+
}
|
180
|
+
|
181
|
+
const type = groups?.['type'];
|
182
|
+
const subtype = groups?.['subtype'];
|
183
|
+
const parameter = groups?.['parameter'];
|
184
|
+
|
185
|
+
if (subtype === "" || type === "") {
|
186
|
+
throw new TypeError('blank value is not allowed');
|
187
|
+
}
|
188
|
+
|
189
|
+
return new MediaType(type, subtype, parseParameter(parameter));
|
190
|
+
|
191
|
+
|
192
|
+
}
|
193
|
+
|
194
|
+
/**
|
195
|
+
* @private
|
196
|
+
* @since 1.18.0
|
197
|
+
* @param {String} parameter
|
198
|
+
* @return {Monster.Types.Parameter[]|undefined}
|
199
|
+
* @memberOf Monster.Types
|
200
|
+
*/
|
201
|
+
function parseParameter(parameter) {
|
202
|
+
|
203
|
+
if (!isString(parameter)) {
|
204
|
+
return undefined;
|
205
|
+
}
|
206
|
+
|
207
|
+
let result = [];
|
208
|
+
|
209
|
+
parameter.split(';').forEach((entry) => {
|
210
|
+
|
211
|
+
entry = entry.trim();
|
212
|
+
if (entry === "") {
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
|
216
|
+
const kv = entry.split('=')
|
217
|
+
|
218
|
+
let key = validateString(kv?.[0]).trim();
|
219
|
+
let value = validateString(kv?.[1]).trim();
|
220
|
+
|
221
|
+
// if values are quoted, they remain so internally
|
222
|
+
result.push({
|
223
|
+
key: key,
|
224
|
+
value: value
|
225
|
+
})
|
226
|
+
|
227
|
+
|
228
|
+
})
|
229
|
+
|
230
|
+
return result;
|
231
|
+
|
232
|
+
}
|
233
|
+
|
234
|
+
|
235
|
+
assignToNamespace('Monster.Types', parseMediaType, MediaType);
|
236
|
+
export {Monster, parseMediaType, MediaType};
|
package/source/types/observer.js
CHANGED
@@ -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.20.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.
|
29
|
+
* import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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.
|
63
|
+
* import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.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
|
@@ -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.20.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.
|
29
|
+
* import {ObserverList} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/observerlist.js';
|
30
30
|
* console.log(ObserverList())
|
31
31
|
* console.log(ObserverList())
|
32
32
|
* </script>
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare let Monster: Object;
|
@@ -17,7 +17,7 @@ import {validateObject} from "./validate.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.20.0/dist/modules/types/proxyobserver.js';
|
21
21
|
* console.log(new Monster.Types.ProxyObserver())
|
22
22
|
* </script>
|
23
23
|
* ```
|
@@ -26,7 +26,7 @@ import {validateObject} from "./validate.js";
|
|
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.20.0/dist/modules/types/proxyobserver.js';
|
30
30
|
* console.log(new ProxyObserver())
|
31
31
|
* </script>
|
32
32
|
* ```
|
@@ -37,9 +37,9 @@ import {validateObject} from "./validate.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.20.0/dist/modules/types/proxyobserver.js';
|
41
|
+
* import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/observer.js';
|
42
|
+
* import {isObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/is.js';
|
43
43
|
*
|
44
44
|
* const o = new Observer(function () {
|
45
45
|
* if (isObject(this) && this instanceof ProxyObserver) {
|
package/source/types/queue.js
CHANGED
@@ -11,7 +11,7 @@ import {Base} from './base.js';
|
|
11
11
|
*
|
12
12
|
* ```
|
13
13
|
* <script type="module">
|
14
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
14
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/queue.js';
|
15
15
|
* console.log(new Monster.Types.Queue())
|
16
16
|
* </script>
|
17
17
|
* ```
|
@@ -20,14 +20,14 @@ import {Base} from './base.js';
|
|
20
20
|
*
|
21
21
|
* ```
|
22
22
|
* <script type="module">
|
23
|
-
* import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
23
|
+
* import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/queue.js';
|
24
24
|
* console.log(new Queue())
|
25
25
|
* </script>
|
26
26
|
* ```
|
27
27
|
*
|
28
28
|
* @example
|
29
29
|
*
|
30
|
-
* import {Queue} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
30
|
+
* import {Queue} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/queue.js';
|
31
31
|
*
|
32
32
|
* const queue = new Queue;
|
33
33
|
*
|
@@ -51,6 +51,7 @@ import {Base} from './base.js';
|
|
51
51
|
* @since 1.4.0
|
52
52
|
* @copyright schukai GmbH
|
53
53
|
* @memberOf Monster.Types
|
54
|
+
* @summary A Queue (Fifo)
|
54
55
|
*/
|
55
56
|
class Queue extends Base {
|
56
57
|
|
package/source/types/randomid.js
CHANGED
@@ -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.20.0/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.20.0/dist/modules/types/randomid.js';
|
32
32
|
* console.log(new RandomID())
|
33
33
|
* </script>
|
34
34
|
* ```
|
@@ -36,6 +36,7 @@ let internalCounter = 0;
|
|
36
36
|
* @since 1.6.0
|
37
37
|
* @copyright schukai GmbH
|
38
38
|
* @memberOf Monster.Types
|
39
|
+
* @summary class to generate random numbers
|
39
40
|
*/
|
40
41
|
class RandomID extends ID {
|
41
42
|
|
package/source/types/stack.js
CHANGED
@@ -12,7 +12,7 @@ import {Base} from './base.js';
|
|
12
12
|
*
|
13
13
|
* ```
|
14
14
|
* <script type="module">
|
15
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
15
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/stack.js';
|
16
16
|
* console.log(new Monster.Types.Stack())
|
17
17
|
* </script>
|
18
18
|
* ```
|
@@ -21,7 +21,7 @@ import {Base} from './base.js';
|
|
21
21
|
*
|
22
22
|
* ```
|
23
23
|
* <script type="module">
|
24
|
-
* import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
24
|
+
* import {ID} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/stack.js';
|
25
25
|
* console.log(new Stack())
|
26
26
|
* </script>
|
27
27
|
* ```
|
@@ -18,7 +18,7 @@ import {Base} from './base.js';
|
|
18
18
|
*
|
19
19
|
* ```
|
20
20
|
* <script type="module">
|
21
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
21
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/tokenlist.js';
|
22
22
|
* console.log(new Monster.Types.TokenList("myclass row"))
|
23
23
|
* console.log(new Monster.Types.TokenList("myclass row"))
|
24
24
|
* </script>
|
@@ -28,7 +28,7 @@ import {Base} from './base.js';
|
|
28
28
|
*
|
29
29
|
* ```
|
30
30
|
* <script type="module">
|
31
|
-
* import {TokenList} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
31
|
+
* import {TokenList} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/tokenlist.js';
|
32
32
|
* console.log(new TokenList("myclass row"))
|
33
33
|
* console.log(new TokenList("myclass row"))
|
34
34
|
* </script>
|
package/source/types/typeof.js
CHANGED
@@ -14,7 +14,7 @@ import {assignToNamespace, Monster} from '../namespace.js';
|
|
14
14
|
*
|
15
15
|
* ```
|
16
16
|
* <script type="module">
|
17
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
17
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/typeof.js';
|
18
18
|
* console.log(Monster.Types.typeOf())
|
19
19
|
* </script>
|
20
20
|
* ```
|
@@ -23,14 +23,14 @@ import {assignToNamespace, Monster} from '../namespace.js';
|
|
23
23
|
*
|
24
24
|
* ```
|
25
25
|
* <script type="module">
|
26
|
-
* import {typeOf} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
26
|
+
* import {typeOf} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/typeof.js';
|
27
27
|
* console.log(typeOf())
|
28
28
|
* </script>
|
29
29
|
* ```
|
30
30
|
*
|
31
31
|
* @example
|
32
32
|
*
|
33
|
-
* import {typeOf} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
33
|
+
* import {typeOf} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/typeof.js';
|
34
34
|
*
|
35
35
|
* console.log(typeOf(undefined)); // ↦ undefined
|
36
36
|
* console.log(typeOf("")); // ↦ string
|
@@ -13,7 +13,7 @@ import {validateObject} from "./validate.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.20.0/dist/modules/types/uniquequeue.js';
|
17
17
|
* console.log(new Monster.Types.UniqueQueue())
|
18
18
|
* </script>
|
19
19
|
* ```
|
@@ -22,7 +22,7 @@ import {validateObject} from "./validate.js";
|
|
22
22
|
*
|
23
23
|
* ```
|
24
24
|
* <script type="module">
|
25
|
-
* import {UniqueQueue} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
25
|
+
* import {UniqueQueue} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.20.0/dist/modules/types/uniquequeue.js';
|
26
26
|
* console.log(new UniqueQueue())
|
27
27
|
* </script>
|
28
28
|
* ```
|
@@ -30,6 +30,7 @@ import {validateObject} from "./validate.js";
|
|
30
30
|
* @since 1.4.0
|
31
31
|
* @copyright schukai GmbH
|
32
32
|
* @memberOf Monster.Types
|
33
|
+
* @summary A queue for unique values
|
33
34
|
*/
|
34
35
|
class UniqueQueue extends Queue {
|
35
36
|
|