@schukai/monster 1.13.0 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. package/CHANGELOG +46 -1
  2. package/README.md +5 -5
  3. package/dist/modules/constants.js +2 -2
  4. package/dist/modules/constraints/abstract.js +2 -2
  5. package/dist/modules/constraints/abstractoperator.js +2 -2
  6. package/dist/modules/constraints/andoperator.js +2 -2
  7. package/dist/modules/constraints/invalid.js +2 -2
  8. package/dist/modules/constraints/isarray.js +2 -2
  9. package/dist/modules/constraints/isobject.js +2 -2
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +2 -2
  12. package/dist/modules/constraints/valid.js +2 -2
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/diff.js +2 -2
  15. package/dist/modules/data/extend.js +2 -2
  16. package/dist/modules/data/namespace.js +1 -1
  17. package/dist/modules/data/pathfinder.js +2 -2
  18. package/dist/modules/data/pipe.js +2 -2
  19. package/dist/modules/data/transformer.js +2 -2
  20. package/dist/modules/dom/assembler.js +2 -2
  21. package/dist/modules/dom/attributes.js +2 -2
  22. package/dist/modules/dom/constants.js +2 -2
  23. package/dist/modules/dom/customcontrol.js +2 -0
  24. package/dist/modules/dom/customelement.js +2 -2
  25. package/dist/modules/dom/events.js +2 -2
  26. package/dist/modules/dom/locale.js +2 -2
  27. package/dist/modules/dom/namespace.js +1 -1
  28. package/dist/modules/dom/template.js +2 -2
  29. package/dist/modules/dom/theme.js +2 -2
  30. package/dist/modules/dom/updater.js +2 -2
  31. package/dist/modules/dom/util.js +2 -2
  32. package/dist/modules/i18n/locale.js +2 -2
  33. package/dist/modules/i18n/namespace.js +1 -1
  34. package/dist/modules/i18n/provider.js +2 -2
  35. package/dist/modules/i18n/providers/fetch.js +2 -2
  36. package/dist/modules/i18n/providers/namespace.js +1 -1
  37. package/dist/modules/i18n/translations.js +2 -2
  38. package/dist/modules/logging/handler/console.js +2 -2
  39. package/dist/modules/logging/handler/namespace.js +1 -1
  40. package/dist/modules/logging/handler.js +2 -2
  41. package/dist/modules/logging/logentry.js +2 -2
  42. package/dist/modules/logging/logger.js +2 -2
  43. package/dist/modules/logging/namespace.js +1 -1
  44. package/dist/modules/math/namespace.js +1 -1
  45. package/dist/modules/math/random.js +2 -2
  46. package/dist/modules/monster.js +2 -2
  47. package/dist/modules/namespace.js +2 -2
  48. package/dist/modules/text/formatter.js +2 -2
  49. package/dist/modules/text/namespace.js +1 -1
  50. package/dist/modules/types/base.js +2 -2
  51. package/dist/modules/types/basewithoptions.js +2 -2
  52. package/dist/modules/types/global.js +2 -2
  53. package/dist/modules/types/id.js +2 -2
  54. package/dist/modules/types/is.js +2 -2
  55. package/dist/modules/types/namespace.js +1 -1
  56. package/dist/modules/types/observer.js +2 -2
  57. package/dist/modules/types/observerlist.js +2 -2
  58. package/dist/modules/types/proxyobserver.js +2 -2
  59. package/dist/modules/types/queue.js +2 -2
  60. package/dist/modules/types/randomid.js +2 -2
  61. package/dist/modules/types/stack.js +2 -2
  62. package/dist/modules/types/tokenlist.js +2 -2
  63. package/dist/modules/types/typeof.js +2 -2
  64. package/dist/modules/types/uniquequeue.js +2 -2
  65. package/dist/modules/types/validate.js +2 -2
  66. package/dist/modules/types/version.js +2 -2
  67. package/dist/modules/util/clone.js +2 -2
  68. package/dist/modules/util/comparator.js +2 -2
  69. package/dist/modules/util/freeze.js +2 -2
  70. package/dist/modules/util/namespace.js +1 -1
  71. package/dist/monster.dev.js +8622 -7709
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +2 -9
  74. package/package.json +1 -1
  75. package/source/constants.js +7 -6
  76. package/source/constraints/abstract.js +2 -2
  77. package/source/constraints/abstractoperator.js +4 -4
  78. package/source/constraints/andoperator.js +8 -8
  79. package/source/constraints/invalid.js +6 -6
  80. package/source/constraints/isarray.js +7 -7
  81. package/source/constraints/isobject.js +7 -7
  82. package/source/constraints/namespace.js +2 -2
  83. package/source/constraints/oroperator.js +8 -8
  84. package/source/constraints/valid.js +7 -7
  85. package/source/data/buildmap.js +15 -15
  86. package/source/data/diff.js +9 -9
  87. package/source/data/extend.js +55 -13
  88. package/source/data/namespace.js +2 -2
  89. package/source/data/pathfinder.js +13 -14
  90. package/source/data/pipe.js +8 -8
  91. package/source/data/transformer.js +11 -11
  92. package/source/dom/assembler.js +7 -7
  93. package/source/dom/attributes.js +89 -46
  94. package/source/dom/constants.js +9 -2
  95. package/source/dom/customcontrol.js +299 -0
  96. package/source/dom/customelement.js +181 -66
  97. package/source/dom/events.js +58 -8
  98. package/source/dom/locale.js +5 -5
  99. package/source/dom/namespace.js +2 -2
  100. package/source/dom/template.js +24 -19
  101. package/source/dom/theme.js +8 -9
  102. package/source/dom/updater.js +46 -24
  103. package/source/dom/util.js +10 -10
  104. package/source/i18n/locale.js +7 -7
  105. package/source/i18n/namespace.js +1 -1
  106. package/source/i18n/provider.js +6 -6
  107. package/source/i18n/providers/fetch.js +10 -10
  108. package/source/i18n/translations.js +5 -5
  109. package/source/logging/handler/console.js +5 -5
  110. package/source/logging/handler/namespace.js +1 -1
  111. package/source/logging/handler.js +8 -8
  112. package/source/logging/logentry.js +5 -5
  113. package/source/logging/logger.js +5 -5
  114. package/source/logging/namespace.js +2 -2
  115. package/source/math/namespace.js +2 -2
  116. package/source/math/random.js +5 -5
  117. package/source/monster.js +48 -44
  118. package/source/namespace.js +2 -2
  119. package/source/text/formatter.js +6 -7
  120. package/source/text/namespace.js +1 -1
  121. package/source/types/base.js +4 -5
  122. package/source/types/basewithoptions.js +10 -9
  123. package/source/types/global.js +7 -7
  124. package/source/types/id.js +7 -7
  125. package/source/types/is.js +22 -22
  126. package/source/types/namespace.js +2 -2
  127. package/source/types/observer.js +7 -7
  128. package/source/types/observerlist.js +4 -4
  129. package/source/types/proxyobserver.js +32 -26
  130. package/source/types/queue.js +13 -7
  131. package/source/types/randomid.js +6 -6
  132. package/source/types/stack.js +11 -4
  133. package/source/types/tokenlist.js +9 -9
  134. package/source/types/typeof.js +5 -5
  135. package/source/types/uniquequeue.js +14 -7
  136. package/source/types/validate.js +27 -27
  137. package/source/types/version.js +9 -9
  138. package/source/util/clone.js +6 -6
  139. package/source/util/comparator.js +7 -7
  140. package/source/util/freeze.js +7 -7
  141. package/source/util/namespace.js +2 -2
  142. package/test/cases/data/extend.js +66 -13
  143. package/test/cases/dom/attributes.js +56 -1
  144. package/test/cases/dom/customcontrol.js +264 -0
  145. package/test/cases/dom/customelement.js +112 -51
  146. package/test/cases/dom/events.js +32 -14
  147. package/test/cases/dom/template.js +40 -1
  148. package/test/cases/monster.js +1 -1
  149. package/test/cases/types/proxyobserver.js +9 -0
  150. package/test/util/jsdom.js +3 -0
  151. package/test/web/import.js +1 -0
  152. package/test/web/monster-dev.html +3 -3
  153. package/test/web/monster.html +2 -2
  154. package/test/web/test.html +3 -3
  155. package/test/web/tests.js +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schukai/monster",
3
- "version": "1.13.0",
3
+ "version": "1.15.2",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -1,21 +1,22 @@
1
1
  'use strict';
2
2
 
3
- import {Monster} from "./namespace.js";
4
-
3
+ import {Monster} from './namespace.js';
5
4
  /**
6
5
  * Property-Keys
7
6
  * @author schukai GmbH
8
7
  */
9
8
 
10
9
  /**
11
- * @memberOf Monster/DOM
10
+ * formerly known as PROPERTY_KEY_OPTIONS
11
+ *
12
+ * @memberOf Monster
12
13
  * @type {string}
13
- * @since 1.10.0
14
+ * @since 1.15.0
14
15
  */
15
- const PROPERTY_KEY_OPTIONS = 'monsterOptions';
16
+ const PROPERTY_KEY_INTERNALDATA = 'monsterInternalData';
16
17
 
17
18
 
18
19
  export {
19
20
  Monster,
20
- PROPERTY_KEY_OPTIONS
21
+ PROPERTY_KEY_INTERNALDATA
21
22
  }
@@ -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 '../types/base.js';
9
9
 
10
10
 
@@ -37,5 +37,5 @@ class AbstractConstraint extends Base {
37
37
  }
38
38
  }
39
39
 
40
- Monster.assignToNamespace('Monster.Constraints', AbstractConstraint);
40
+ assignToNamespace('Monster.Constraints', AbstractConstraint);
41
41
  export {Monster, AbstractConstraint}
@@ -3,12 +3,12 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, AbstractConstraint} from "./abstract.js";
6
+ import {assignToNamespace, Monster} 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.
11
- *
11
+ *
12
12
  * @since 1.3.0
13
13
  * @copyright schukai GmbH
14
14
  * @memberOf Monster/Constraints
@@ -36,5 +36,5 @@ class AbstractOperator extends AbstractConstraint {
36
36
 
37
37
  }
38
38
 
39
- Monster.assignToNamespace('Monster.Constraints', AbstractOperator);
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, AbstractConstraint} from "./abstract.js";
7
+ import {assignToNamespace, Monster} 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.13.0/dist/modules/constraints/andoperator.js';
15
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/andoperator.js';
24
+ * import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/valid.js';
32
- * import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.13.0/dist/modules/constraints/invalid.js';
33
- * import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.13.0/dist/modules/constraints/andoperator.js';
31
+ * import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/constraints/valid.js';
32
+ * import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/constraints/invalid.js';
33
+ * import {AndOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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
- Monster.assignToNamespace('Monster.Constraints', AndOperator);
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 {Monster, AbstractConstraint} from "./abstract.js";
6
+ import {assignToNamespace, Monster} 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.13.0/dist/modules/constraints/invalid.js';
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/invalid.js';
25
+ * import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/invalid.js';
32
+ * import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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
- Monster.assignToNamespace('Monster.Constraints', Invalid);
57
+ assignToNamespace('Monster.Constraints', Invalid);
58
58
  export {Monster, Invalid}
@@ -3,16 +3,16 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, AbstractConstraint} from "./abstract.js";
6
+ import {assignToNamespace, Monster} from '../namespace.js';
8
7
  import {isArray} from "../types/is.js";
8
+ import {AbstractConstraint} from "./abstract.js";
9
9
 
10
10
  /**
11
11
  * You can call the method via the monster namespace `new Monster.Constraint.IsObject()`.
12
12
  *
13
13
  * ```
14
14
  * <script type="module">
15
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.13.0/dist/modules/constraints/isarray.js';
15
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/isarray.js';
24
+ * import {IsArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/isarray.js';
31
+ * import {IsArray} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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
- Monster.assignToNamespace('Monster.Constraints', IsArray);
65
+ assignToNamespace('Monster.Constraints', IsArray);
66
66
  export {Monster, IsArray}
@@ -3,16 +3,16 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, AbstractConstraint} from "./abstract.js";
6
+ import {assignToNamespace, Monster} from '../namespace.js';
8
7
  import {isObject} from "../types/is.js";
8
+ import {AbstractConstraint} from "./abstract.js";
9
9
 
10
10
  /**
11
11
  * You can call the method via the monster namespace `new Monster.Constraint.IsObject()`.
12
12
  *
13
13
  * ```
14
14
  * <script type="module">
15
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.13.0/dist/modules/constraints/isobject.js';
15
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/isobject.js';
24
+ * import {IsObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/isobject.js';
31
+ * import {IsObject} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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
- Monster.assignToNamespace('Monster.Constraints', IsObject);
66
+ assignToNamespace('Monster.Constraints', IsObject);
67
67
  export {Monster, IsObject}
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * Constraints are used to define conditions that must be met by the value of a variable so that the value can be transferred to the system.
5
- *
5
+ *
6
6
  * @namespace Monster/Constraints
7
7
  * @author schukai GmbH
8
8
  */
@@ -11,4 +11,4 @@
11
11
  * @private
12
12
  * @type {string}
13
13
  */
14
- const namespace="Monster.Constraints";
14
+ const namespace = "Monster.Constraints";
@@ -3,15 +3,15 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, AbstractOperator} from "./abstractoperator.js";
6
+ import {assignToNamespace, Monster} 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.13.0/dist/modules/constraint/oroperator.js';
14
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraint/oroperator.js';
23
+ * import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/valid.js';
31
- * import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.13.0/dist/modules/constraints/invalid.js';
32
- * import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.13.0/dist/modules/constraints/oroperator.js';
30
+ * import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/constraints/valid.js';
31
+ * import {Invalid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/constraints/invalid.js';
32
+ * import {OrOperator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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
- Monster.assignToNamespace('Monster.Constraints', OrOperator);
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 {Monster, AbstractConstraint} from "./abstract.js";
6
+ import {assignToNamespace, Monster} 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.13.0/dist/modules/constraints/valid.js';
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/valid.js';
25
+ * import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/constraints/valid.js';
32
+ * import {Valid} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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
- Monster.assignToNamespace('Monster.Constraints', Valid);
57
+ assignToNamespace('Monster.Constraints', Valid);
58
58
  export {Monster, Valid}
@@ -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 {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.13.0/dist/modules/data/buildmap.js';
22
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/types/buildmap.js';
31
+ * import {buildMap} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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} valuePath
108
- * @param {string|undefined} keyPath
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, valuePath, keyPath, filter) {
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, keyPath, k);
130
- v = build(v, valuePath);
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>\$\{(?<path>[a-z.-_0-9]*)\})/gm
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
- Monster.assignToNamespace('Monster.Data', buildMap);
177
+ assignToNamespace('Monster.Data', buildMap);
178
178
  export {Monster, buildMap}
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
- * @author schukai GmbH
4
+ * @author schukai GmbH
5
5
  */
6
6
 
7
-
8
- import {Monster, isArray, isObject} from "../types/is.js";
7
+ import {assignToNamespace, Monster} 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.13.0/dist/modules/data/diff.js';
19
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/data/diff.js';
20
20
  * console.log(Monster.Data.Diff(a, b))
21
21
  * </script>
22
22
  * ```
@@ -25,15 +25,15 @@ 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.13.0/dist/modules/data/diff.js';
28
+ * import {Diff} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/data/diff.js';
29
29
  * console.log(Diff(a, b))
30
30
  * </script>
31
31
  * ```
32
32
  *
33
33
  * @example
34
- *
35
- * import {Diff} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.13.0/dist/modules/data/diff.js';
36
- *
34
+ *
35
+ * import {Diff} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/data/diff.js';
36
+ *
37
37
  * // given are two objects x and y.
38
38
  *
39
39
  * let x = {
@@ -244,5 +244,5 @@ function getOperator(a, b) {
244
244
 
245
245
  }
246
246
 
247
- Monster.assignToNamespace('Monster.Data', Diff);
247
+ assignToNamespace('Monster.Data', Diff);
248
248
  export {Monster, Diff}
@@ -3,15 +3,19 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, isObject} from "../types/is.js";
6
+ import {assignToNamespace, Monster} from '../namespace.js';
7
+ import {isArray, isObject} 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.13.0/dist/modules/data/extend.js';
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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.13.0/dist/modules/data/extend.js';
27
+ * import {extend} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/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
+ }
50
+
51
+ if (o === undefined) {
52
+ o = a;
53
+ continue;
54
+ }
55
+
56
+ for (let k in a) {
57
+
58
+ let v = a?.[k];
35
59
 
36
- for (var o = {}, i = 0; i < arguments.length; i++) {
37
- if (!isObject(o)) continue;
38
- for (var k in arguments[i]) {
39
- if (arguments[i].hasOwnProperty(k)) {
40
- o[k] = isObject(arguments[i][k])
41
- ? extend(o[k] || {}, arguments[i][k])
42
- : arguments[i][k];
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
- Monster.assignToNamespace('Monster.Data', extend);
90
+
91
+ assignToNamespace('Monster.Data', extend);
50
92
  export {Monster, extend}
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * In this namespace you will find classes and methods for handling data.
5
- *
5
+ *
6
6
  * @namespace Monster/Data
7
7
  * @author schukai GmbH
8
8
  */
@@ -12,4 +12,4 @@
12
12
  * @private
13
13
  * @type {string}
14
14
  */
15
- const namespace="Monster.Data";
15
+ const namespace = "Monster.Data";