@schukai/monster 1.12.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +40 -1
- package/README.md +5 -5
- package/dist/modules/constants.js +2 -0
- 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 +2 -2
- package/dist/modules/dom/customcontrol.js +2 -0
- package/dist/modules/dom/customelement.js +2 -2
- package/dist/modules/dom/events.js +2 -2
- package/dist/modules/dom/locale.js +2 -0
- 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 -0
- package/dist/modules/i18n/namespace.js +2 -0
- package/dist/modules/i18n/provider.js +2 -0
- package/dist/modules/i18n/providers/fetch.js +2 -0
- package/dist/modules/i18n/providers/namespace.js +2 -0
- package/dist/modules/i18n/translations.js +2 -0
- 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 +1 -1
- 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 -0
- 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 +8692 -6669
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +3 -3
- package/package.json +1 -1
- package/source/constants.js +22 -0
- package/source/constraints/abstract.js +2 -2
- package/source/constraints/abstractoperator.js +3 -3
- package/source/constraints/andoperator.js +7 -7
- package/source/constraints/invalid.js +6 -6
- package/source/constraints/isarray.js +6 -6
- package/source/constraints/isobject.js +6 -6
- package/source/constraints/namespace.js +2 -0
- package/source/constraints/oroperator.js +8 -8
- package/source/constraints/valid.js +6 -6
- package/source/data/buildmap.js +15 -15
- package/source/data/diff.js +6 -6
- package/source/data/extend.js +55 -13
- package/source/data/namespace.js +2 -0
- package/source/data/pathfinder.js +6 -7
- package/source/data/pipe.js +5 -5
- package/source/data/transformer.js +6 -6
- package/source/dom/assembler.js +5 -5
- package/source/dom/attributes.js +89 -45
- package/source/dom/constants.js +8 -9
- package/source/dom/customcontrol.js +301 -0
- package/source/dom/customelement.js +149 -31
- package/source/dom/events.js +58 -8
- package/source/dom/locale.js +59 -0
- package/source/dom/namespace.js +2 -0
- package/source/dom/template.js +7 -7
- package/source/dom/theme.js +6 -6
- package/source/dom/updater.js +38 -11
- package/source/dom/util.js +10 -10
- package/source/i18n/locale.js +322 -0
- package/source/i18n/namespace.js +15 -0
- package/source/i18n/provider.js +58 -0
- package/source/i18n/providers/fetch.js +121 -0
- package/source/i18n/providers/namespace.js +15 -0
- package/source/i18n/translations.js +209 -0
- package/source/logging/handler/console.js +4 -4
- package/source/logging/handler.js +4 -4
- package/source/logging/logentry.js +4 -4
- package/source/logging/logger.js +4 -4
- package/source/logging/namespace.js +2 -0
- package/source/math/namespace.js +2 -0
- package/source/math/random.js +5 -5
- package/source/monster.js +26 -16
- package/source/namespace.js +10 -8
- package/source/text/formatter.js +4 -5
- package/source/text/namespace.js +1 -1
- package/source/types/base.js +4 -7
- package/source/types/basewithoptions.js +97 -0
- package/source/types/global.js +6 -6
- package/source/types/id.js +6 -6
- package/source/types/is.js +22 -22
- package/source/types/namespace.js +3 -1
- package/source/types/observer.js +5 -5
- 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 +5 -5
- package/source/types/stack.js +11 -4
- package/source/types/tokenlist.js +4 -4
- package/source/types/typeof.js +5 -5
- package/source/types/uniquequeue.js +11 -4
- package/source/types/validate.js +22 -22
- package/source/types/version.js +9 -9
- package/source/util/clone.js +4 -4
- package/source/util/comparator.js +6 -6
- package/source/util/freeze.js +4 -4
- package/source/util/namespace.js +2 -0
- package/test/cases/data/extend.js +66 -13
- package/test/cases/dom/attributes.js +56 -1
- package/test/cases/dom/customcontrol.js +264 -0
- package/test/cases/dom/customelement.js +112 -51
- package/test/cases/dom/events.js +32 -14
- package/test/cases/dom/locale.js +44 -0
- package/test/cases/i18n/locale.js +80 -0
- package/test/cases/i18n/provider.js +15 -0
- package/test/cases/i18n/providers/fetch.js +65 -0
- package/test/cases/i18n/translations.js +57 -0
- package/test/cases/monster.js +3 -1
- package/test/cases/{util → text}/formatter.js +2 -0
- package/test/cases/types/basewithoptions.js +25 -0
- package/test/cases/types/proxyobserver.js +9 -0
- package/test/cases/{text → util}/clone.js +0 -0
- package/test/cases/{text → util}/comparator.js +0 -0
- package/test/util/jsdom.js +4 -0
- package/test/web/import.js +10 -3
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +3 -3
- package/test/web/test.html +3 -3
- package/test/web/tests.js +3 -3
package/package.json
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import {Monster} from './namespace.js';
|
4
|
+
/**
|
5
|
+
* Property-Keys
|
6
|
+
* @author schukai GmbH
|
7
|
+
*/
|
8
|
+
|
9
|
+
/**
|
10
|
+
* formerly known as PROPERTY_KEY_OPTIONS
|
11
|
+
*
|
12
|
+
* @memberOf Monster
|
13
|
+
* @type {string}
|
14
|
+
* @since 1.15.0
|
15
|
+
*/
|
16
|
+
const PROPERTY_KEY_INTERNALDATA = 'monsterInternalData';
|
17
|
+
|
18
|
+
|
19
|
+
export {
|
20
|
+
Monster,
|
21
|
+
PROPERTY_KEY_INTERNALDATA
|
22
|
+
}
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
6
|
|
7
|
-
import {Monster} from '../namespace.js';
|
7
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
8
8
|
import {Base} from '../types/base.js';
|
9
9
|
|
10
10
|
|
@@ -37,5 +37,5 @@ class AbstractConstraint extends Base {
|
|
37
37
|
}
|
38
38
|
}
|
39
39
|
|
40
|
-
|
40
|
+
assignToNamespace('Monster.Constraints', AbstractConstraint);
|
41
41
|
export {Monster, AbstractConstraint}
|
@@ -3,8 +3,8 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
7
|
+
import {AbstractConstraint} from "./abstract.js";
|
8
8
|
|
9
9
|
/**
|
10
10
|
* Operators allow you to link constraints together. for example, you can check whether a value is an object or an array. each operator has two operands that are linked together.
|
@@ -36,5 +36,5 @@ class AbstractOperator extends AbstractConstraint {
|
|
36
36
|
|
37
37
|
}
|
38
38
|
|
39
|
-
|
39
|
+
assignToNamespace('Monster.Constraints', AbstractOperator);
|
40
40
|
export {Monster, AbstractOperator}
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
6
|
|
7
|
-
import {Monster,
|
7
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
8
8
|
import {AbstractOperator} from "./abstractoperator.js";
|
9
9
|
|
10
10
|
/**
|
@@ -12,7 +12,7 @@ import {AbstractOperator} from "./abstractoperator.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.15.0/dist/modules/constraints/andoperator.js';
|
16
16
|
* new Monster.Constraint.AndOperator();
|
17
17
|
* </script>
|
18
18
|
* ```
|
@@ -21,16 +21,16 @@ import {AbstractOperator} from "./abstractoperator.js";
|
|
21
21
|
*
|
22
22
|
* ```
|
23
23
|
* <script type="module">
|
24
|
-
* import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
24
|
+
* import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/andoperator.js';
|
25
25
|
* new AndOperator();
|
26
26
|
* </script>
|
27
27
|
* ```
|
28
28
|
*
|
29
29
|
* @example
|
30
30
|
*
|
31
|
-
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
32
|
-
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
33
|
-
* import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
31
|
+
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/valid.js';
|
32
|
+
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/invalid.js';
|
33
|
+
* import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/andoperator.js';
|
34
34
|
*
|
35
35
|
* new AndOperator(
|
36
36
|
* new Valid(), new Valid()).isValid()
|
@@ -62,5 +62,5 @@ class AndOperator extends AbstractOperator {
|
|
62
62
|
|
63
63
|
}
|
64
64
|
|
65
|
-
|
65
|
+
assignToNamespace('Monster.Constraints', AndOperator);
|
66
66
|
export {Monster, AndOperator}
|
@@ -3,8 +3,8 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
7
|
+
import {AbstractConstraint} from "./abstract.js";
|
8
8
|
|
9
9
|
/**
|
10
10
|
* The invalid constraint allows an always invalid query to be performed. this constraint is mainly intended for testing.
|
@@ -13,7 +13,7 @@ import {Monster, AbstractConstraint} from "./abstract.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.0/dist/modules/constraints/invalid.js';
|
17
17
|
* new Monster.Constraint.Invalid();
|
18
18
|
* </script>
|
19
19
|
* ```
|
@@ -22,14 +22,14 @@ import {Monster, AbstractConstraint} from "./abstract.js";
|
|
22
22
|
*
|
23
23
|
* ```
|
24
24
|
* <script type="module">
|
25
|
-
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
25
|
+
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/invalid.js';
|
26
26
|
* new Invalid();
|
27
27
|
* </script>
|
28
28
|
* ```
|
29
29
|
*
|
30
30
|
* @example
|
31
31
|
*
|
32
|
-
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
32
|
+
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/invalid.js';
|
33
33
|
*
|
34
34
|
* new Invalid().isValid()
|
35
35
|
* .then(()=>console.log(true))
|
@@ -54,5 +54,5 @@ class Invalid extends AbstractConstraint {
|
|
54
54
|
|
55
55
|
}
|
56
56
|
|
57
|
-
|
57
|
+
assignToNamespace('Monster.Constraints', Invalid);
|
58
58
|
export {Monster, Invalid}
|
@@ -3,8 +3,8 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
7
|
+
import { AbstractConstraint} from "./abstract.js";
|
8
8
|
import {isArray} from "../types/is.js";
|
9
9
|
|
10
10
|
/**
|
@@ -12,7 +12,7 @@ import {isArray} from "../types/is.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.15.0/dist/modules/constraints/isarray.js';
|
16
16
|
* console.log(new Monster.Constraint.IsArray())
|
17
17
|
* </script>
|
18
18
|
* ```
|
@@ -21,14 +21,14 @@ import {isArray} from "../types/is.js";
|
|
21
21
|
*
|
22
22
|
* ```
|
23
23
|
* <script type="module">
|
24
|
-
* import {IsArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
24
|
+
* import {IsArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/isarray.js';
|
25
25
|
* console.log(new IsArray())
|
26
26
|
* </script>
|
27
27
|
* ```
|
28
28
|
*
|
29
29
|
* @example
|
30
30
|
*
|
31
|
-
* import {IsArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
31
|
+
* import {IsArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/isarray.js';
|
32
32
|
*
|
33
33
|
* new IsArray()
|
34
34
|
* .isValid([])
|
@@ -62,5 +62,5 @@ class IsArray extends AbstractConstraint {
|
|
62
62
|
|
63
63
|
}
|
64
64
|
|
65
|
-
|
65
|
+
assignToNamespace('Monster.Constraints', IsArray);
|
66
66
|
export {Monster, IsArray}
|
@@ -3,8 +3,8 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
7
|
+
import {AbstractConstraint} from "./abstract.js";
|
8
8
|
import {isObject} from "../types/is.js";
|
9
9
|
|
10
10
|
/**
|
@@ -12,7 +12,7 @@ import {isObject} from "../types/is.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.15.0/dist/modules/constraints/isobject.js';
|
16
16
|
* console.log(new Monster.Constraint.IsObject())
|
17
17
|
* </script>
|
18
18
|
* ```
|
@@ -21,14 +21,14 @@ import {isObject} from "../types/is.js";
|
|
21
21
|
*
|
22
22
|
* ```
|
23
23
|
* <script type="module">
|
24
|
-
* import {IsObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
24
|
+
* import {IsObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/isobject.js';
|
25
25
|
* console.log(new IsObject())
|
26
26
|
* </script>
|
27
27
|
* ```
|
28
28
|
*
|
29
29
|
* @example
|
30
30
|
*
|
31
|
-
* import {IsObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
31
|
+
* import {IsObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/isobject.js';
|
32
32
|
*
|
33
33
|
* new IsObject()
|
34
34
|
* .isValid({})
|
@@ -63,5 +63,5 @@ class IsObject extends AbstractConstraint {
|
|
63
63
|
|
64
64
|
}
|
65
65
|
|
66
|
-
|
66
|
+
assignToNamespace('Monster.Constraints', IsObject);
|
67
67
|
export {Monster, IsObject}
|
@@ -3,15 +3,15 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
7
|
+
import { AbstractOperator} from "./abstractoperator.js";
|
8
8
|
|
9
9
|
/**
|
10
10
|
* The OrOperator is used to link several constraints. The constraint is fulfilled if one of the constraints is fulfilled.
|
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.15.0/dist/modules/constraint/oroperator.js';
|
15
15
|
* new Monster.Constraint.OrOperator();
|
16
16
|
* </script>
|
17
17
|
* ```
|
@@ -20,16 +20,16 @@ import {Monster, AbstractOperator} from "./abstractoperator.js";
|
|
20
20
|
*
|
21
21
|
* ```
|
22
22
|
* <script type="module">
|
23
|
-
* import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
23
|
+
* import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraint/oroperator.js';
|
24
24
|
* new OrOperator();
|
25
25
|
* </script>
|
26
26
|
* ```
|
27
27
|
*
|
28
28
|
* @example
|
29
29
|
*
|
30
|
-
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
31
|
-
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
32
|
-
* import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
30
|
+
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/valid.js';
|
31
|
+
* import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/invalid.js';
|
32
|
+
* import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/oroperator.js';
|
33
33
|
*
|
34
34
|
* new OrOperator(
|
35
35
|
* new Valid(), new Invalid()).isValid()
|
@@ -88,5 +88,5 @@ class OrOperator extends AbstractOperator {
|
|
88
88
|
|
89
89
|
}
|
90
90
|
|
91
|
-
|
91
|
+
assignToNamespace('Monster.Constraints', OrOperator);
|
92
92
|
export {Monster, OrOperator}
|
@@ -3,8 +3,8 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
7
|
+
import { AbstractConstraint} from "./abstract.js";
|
8
8
|
|
9
9
|
/**
|
10
10
|
* The valid constraint allows an always valid query to be performed. this constraint is mainly intended for testing.
|
@@ -13,7 +13,7 @@ import {Monster, AbstractConstraint} from "./abstract.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.0/dist/modules/constraints/valid.js';
|
17
17
|
* new Monster.Constraint.Valid();
|
18
18
|
* </script>
|
19
19
|
* ```
|
@@ -22,14 +22,14 @@ import {Monster, AbstractConstraint} from "./abstract.js";
|
|
22
22
|
*
|
23
23
|
* ```
|
24
24
|
* <script type="module">
|
25
|
-
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
25
|
+
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/valid.js';
|
26
26
|
* new Valid();
|
27
27
|
* </script>
|
28
28
|
* ```
|
29
29
|
*
|
30
30
|
* @example
|
31
31
|
*
|
32
|
-
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
32
|
+
* import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/constraints/valid.js';
|
33
33
|
*
|
34
34
|
* new Valid().isValid()
|
35
35
|
* .then(()=>console.log(true))
|
@@ -54,5 +54,5 @@ class Valid extends AbstractConstraint {
|
|
54
54
|
|
55
55
|
}
|
56
56
|
|
57
|
-
|
57
|
+
assignToNamespace('Monster.Constraints', Valid);
|
58
58
|
export {Monster, Valid}
|
package/source/data/buildmap.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
6
|
|
7
|
-
import {Monster} from '../namespace.js';
|
7
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
8
8
|
import {isFunction} from "../types/is.js";
|
9
9
|
import {validateString} from "../types/validate.js";
|
10
10
|
import {Pathfinder} from "./pathfinder.js";
|
@@ -19,7 +19,7 @@ import {Pathfinder} from "./pathfinder.js";
|
|
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.0/dist/modules/data/buildmap.js';
|
23
23
|
* console.log(Monster.Data.buildMap())
|
24
24
|
* </script>
|
25
25
|
* ```
|
@@ -28,7 +28,7 @@ import {Pathfinder} from "./pathfinder.js";
|
|
28
28
|
*
|
29
29
|
* ```
|
30
30
|
* <script type="module">
|
31
|
-
* import {buildMap} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
31
|
+
* import {buildMap} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/types/buildmap.js';
|
32
32
|
* console.log(buildMap())
|
33
33
|
* </script>
|
34
34
|
* ```
|
@@ -90,8 +90,8 @@ import {Pathfinder} from "./pathfinder.js";
|
|
90
90
|
* // '1' => 'Holly (952340 Schwalbach)',
|
91
91
|
* // '2' => 'Guy (420729 Panchià)'
|
92
92
|
* // }
|
93
|
-
*
|
94
|
-
* // a filter (function(value, key) {}) can be specified to accept only defined entries.
|
93
|
+
*
|
94
|
+
* // a filter (function(value, key) {}) can be specified to accept only defined entries.
|
95
95
|
* map = buildMap(obj, 'data.*', '${name} (${address.zip} ${address.city})', 'id', function (value, key) {
|
96
96
|
* return (value['id'] >= 20) ? true : false
|
97
97
|
* });
|
@@ -104,12 +104,12 @@ import {Pathfinder} from "./pathfinder.js";
|
|
104
104
|
*
|
105
105
|
* @param {*} subject
|
106
106
|
* @param {string} selector
|
107
|
-
* @param {string|undefined}
|
108
|
-
* @param {string|undefined}
|
109
|
-
* @param {function|undefined} filter
|
107
|
+
* @param {string|undefined} valueTemplate
|
108
|
+
* @param {string|undefined} keyTemplate
|
109
|
+
* @param {function|undefined} filter
|
110
110
|
* @return {*}
|
111
111
|
*/
|
112
|
-
function buildMap(subject, selector,
|
112
|
+
function buildMap(subject, selector, valueTemplate, keyTemplate, filter) {
|
113
113
|
|
114
114
|
validateString(selector);
|
115
115
|
const result = new Map
|
@@ -123,12 +123,12 @@ function buildMap(subject, selector, valuePath, keyPath, filter) {
|
|
123
123
|
|
124
124
|
map.forEach((v, k, m) => {
|
125
125
|
if (isFunction(filter)) {
|
126
|
-
if (filter.call(m, v, k)!==true) return;
|
126
|
+
if (filter.call(m, v, k) !== true) return;
|
127
127
|
}
|
128
128
|
|
129
|
-
k = build(v,
|
130
|
-
v = build(v,
|
131
|
-
|
129
|
+
k = build(v, keyTemplate, k);
|
130
|
+
v = build(v, valueTemplate);
|
131
|
+
|
132
132
|
result.set(k, v);
|
133
133
|
});
|
134
134
|
|
@@ -146,7 +146,7 @@ function build(subject, definition, defaultValue) {
|
|
146
146
|
if (definition === undefined) return defaultValue ? defaultValue : subject;
|
147
147
|
validateString(definition);
|
148
148
|
|
149
|
-
const regexp = /(?<placeholder
|
149
|
+
const regexp = /(?<placeholder>\${(?<path>[a-z.-_0-9]*)})/gm
|
150
150
|
const array = [...definition.matchAll(regexp)];
|
151
151
|
|
152
152
|
let finder = new Pathfinder(subject);
|
@@ -174,5 +174,5 @@ function build(subject, definition, defaultValue) {
|
|
174
174
|
}
|
175
175
|
|
176
176
|
|
177
|
-
|
177
|
+
assignToNamespace('Monster.Data', buildMap);
|
178
178
|
export {Monster, buildMap}
|
package/source/data/diff.js
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
8
|
-
import {
|
7
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
8
|
+
import { isArray, isObject} from "../types/is.js";
|
9
9
|
|
10
10
|
/**
|
11
11
|
* With the diff function you can perform the change of one object to another. The result shows the changes of the second object to the first object.
|
@@ -16,7 +16,7 @@ import {Monster, isArray, isObject} from "../types/is.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.0/dist/modules/data/diff.js';
|
20
20
|
* console.log(Monster.Data.Diff(a, b))
|
21
21
|
* </script>
|
22
22
|
* ```
|
@@ -25,14 +25,14 @@ import {Monster, isArray, isObject} from "../types/is.js";
|
|
25
25
|
*
|
26
26
|
* ```
|
27
27
|
* <script type="module">
|
28
|
-
* import {Diff} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
28
|
+
* import {Diff} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/diff.js';
|
29
29
|
* console.log(Diff(a, b))
|
30
30
|
* </script>
|
31
31
|
* ```
|
32
32
|
*
|
33
33
|
* @example
|
34
34
|
*
|
35
|
-
* import {Diff} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
35
|
+
* import {Diff} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/diff.js';
|
36
36
|
*
|
37
37
|
* // given are two objects x and y.
|
38
38
|
*
|
@@ -244,5 +244,5 @@ function getOperator(a, b) {
|
|
244
244
|
|
245
245
|
}
|
246
246
|
|
247
|
-
|
247
|
+
assignToNamespace('Monster.Data', Diff);
|
248
248
|
export {Monster, Diff}
|
package/source/data/extend.js
CHANGED
@@ -3,15 +3,19 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
7
|
+
import {isObject, isArray} from "../types/is.js";
|
8
|
+
import {typeOf} from "../types/typeof.js";
|
8
9
|
|
9
10
|
/**
|
11
|
+
* extend copies all enumerable own properties from one or
|
12
|
+
* more source objects to a target object. It returns the modified target object.
|
13
|
+
*
|
10
14
|
* You can call the method via the monster namespace `Monster.Data.extend()`.
|
11
15
|
*
|
12
16
|
* ```
|
13
17
|
* <script type="module">
|
14
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
18
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/extend.js';
|
15
19
|
* console.log(Monster.Data.extend(a, b))
|
16
20
|
* </script>
|
17
21
|
* ```
|
@@ -20,31 +24,69 @@ import {Monster, isObject} from "../types/is.js";
|
|
20
24
|
*
|
21
25
|
* ```
|
22
26
|
* <script type="module">
|
23
|
-
* import {extend} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
27
|
+
* import {extend} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/extend.js';
|
24
28
|
* console.log(extend(a, b))
|
25
29
|
* </script>
|
26
30
|
* ```
|
27
31
|
*
|
28
|
-
* @param {object}
|
32
|
+
* @param {object} target
|
33
|
+
* @param {object}
|
29
34
|
* @return {object}
|
30
35
|
* @since 1.10.0
|
31
36
|
* @copyright schukai GmbH
|
32
37
|
* @memberOf Monster/Data
|
38
|
+
* @throws {Error} unsuported argument
|
39
|
+
* @throws {Error} type mismatch
|
33
40
|
*/
|
34
41
|
function extend() {
|
42
|
+
let o, i;
|
43
|
+
|
44
|
+
for (i = 0; i < arguments.length; i++) {
|
45
|
+
let a = arguments[i];
|
46
|
+
|
47
|
+
if (!(isObject(a) || isArray(a))) {
|
48
|
+
throw new Error('unsuported argument ' + JSON.stringify(a));
|
49
|
+
}
|
35
50
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
51
|
+
if (o === undefined) {
|
52
|
+
o = a;
|
53
|
+
continue;
|
54
|
+
}
|
55
|
+
|
56
|
+
for (let k in a) {
|
57
|
+
|
58
|
+
let v = a?.[k];
|
59
|
+
|
60
|
+
if(v===o?.[k]) {
|
61
|
+
continue;
|
43
62
|
}
|
63
|
+
|
64
|
+
if ((isObject(v) || isArray(v))) {
|
65
|
+
|
66
|
+
if (o[k] === undefined) {
|
67
|
+
if (isArray(v)) {
|
68
|
+
o[k] = [];
|
69
|
+
} else {
|
70
|
+
o[k] = {};
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
if (typeOf(o[k]) !== typeOf(v)) {
|
75
|
+
throw new Error("type mismatch: " + JSON.stringify(o[k]) + " != " + JSON.stringify(v));
|
76
|
+
}
|
77
|
+
|
78
|
+
o[k] = extend(o[k], v);
|
79
|
+
|
80
|
+
} else {
|
81
|
+
o[k] = v;
|
82
|
+
}
|
83
|
+
|
44
84
|
}
|
45
85
|
}
|
86
|
+
|
46
87
|
return o;
|
47
88
|
}
|
48
89
|
|
49
|
-
|
90
|
+
|
91
|
+
assignToNamespace('Monster.Data', extend);
|
50
92
|
export {Monster, extend}
|
package/source/data/namespace.js
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {Monster} from '../namespace.js';
|
6
|
+
import {Monster, assignToNamespace} from '../namespace.js';
|
8
7
|
import {isObject, isArray, isInteger} from '../types/is.js';
|
9
8
|
import {validateString, validateInteger} from '../types/validate.js';
|
10
9
|
import {Base} from '../types/base.js';
|
@@ -28,7 +27,7 @@ const WILDCARD = '*';
|
|
28
27
|
*
|
29
28
|
* ```
|
30
29
|
* <script type="module">
|
31
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
30
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/pathfinder.js';
|
32
31
|
* console.log(new Monster.Data.Pathfinder())
|
33
32
|
* </script>
|
34
33
|
* ```
|
@@ -37,7 +36,7 @@ const WILDCARD = '*';
|
|
37
36
|
*
|
38
37
|
* ```
|
39
38
|
* <script type="module">
|
40
|
-
* import {Pathfinder} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
39
|
+
* import {Pathfinder} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/pathfinder.js';
|
41
40
|
* console.log(new Pathfinder())
|
42
41
|
* </script>
|
43
42
|
* ```
|
@@ -79,7 +78,7 @@ const WILDCARD = '*';
|
|
79
78
|
*
|
80
79
|
* @example
|
81
80
|
*
|
82
|
-
* import {Pathfinder} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
81
|
+
* import {Pathfinder} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/pathfinder.js';
|
83
82
|
*
|
84
83
|
* let value = new Pathfinder({
|
85
84
|
* a: {
|
@@ -105,7 +104,7 @@ const WILDCARD = '*';
|
|
105
104
|
*
|
106
105
|
* @example
|
107
106
|
*
|
108
|
-
* import {Pathfinder} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
107
|
+
* import {Pathfinder} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/pathfinder.js';
|
109
108
|
*
|
110
109
|
* let p = new Pathfinder({
|
111
110
|
* a: {
|
@@ -226,7 +225,7 @@ class Pathfinder extends Base {
|
|
226
225
|
|
227
226
|
}
|
228
227
|
|
229
|
-
|
228
|
+
assignToNamespace('Monster.Data', Pathfinder);
|
230
229
|
export {Monster, Pathfinder}
|
231
230
|
|
232
231
|
/**
|