xdbc 1.0.207 → 1.0.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/Assessment.html +350 -0
  2. package/Assessment.md +507 -51
  3. package/CHANGELOG.md +55 -0
  4. package/CONTRIBUTING.md +129 -17
  5. package/README.md +373 -71
  6. package/SECURITY.md +60 -18
  7. package/SUPPORT.md +65 -0
  8. package/__tests__/DBC/DEFINED.test.ts +53 -0
  9. package/__tests__/DBC/Decorators.test.ts +365 -0
  10. package/__tests__/DBC/GREATER.test.ts +8 -6
  11. package/__tests__/DBC/HasAttribute.test.ts +56 -0
  12. package/__tests__/DBC/IF.test.ts +52 -0
  13. package/__tests__/DBC/JSON.Parse.test.ts +1 -1
  14. package/__tests__/DBC/OR.test.ts +1 -1
  15. package/__tests__/DBC/REGEX.test.ts +1 -1
  16. package/__tests__/DBC/TYPE.test.ts +1 -1
  17. package/__tests__/DBC/UNDEFINED.test.ts +45 -0
  18. package/__tests__/DBC/ZOD.test.ts +54 -0
  19. package/jest.config.js +21 -0
  20. package/package.json +4 -5
  21. package/src/DBC/AE.ts +10 -6
  22. package/src/DBC/COMPARISON/GREATER.ts +11 -7
  23. package/src/DBC/COMPARISON/GREATER_OR_EQUAL.ts +14 -10
  24. package/src/DBC/COMPARISON/LESS.ts +14 -10
  25. package/src/DBC/COMPARISON/LESS_OR_EQUAL.ts +14 -10
  26. package/src/DBC/COMPARISON.ts +20 -43
  27. package/src/DBC/DEFINED.ts +4 -23
  28. package/src/DBC/EQ/DIFFERENT.ts +21 -56
  29. package/src/DBC/EQ.ts +7 -26
  30. package/src/DBC/HasAttribute.ts +9 -26
  31. package/src/DBC/IF.ts +8 -27
  32. package/src/DBC/INSTANCE.ts +5 -22
  33. package/src/DBC/JSON.OP.ts +4 -34
  34. package/src/DBC/JSON.Parse.ts +5 -25
  35. package/src/DBC/OR.ts +5 -14
  36. package/src/DBC/REGEX.ts +41 -40
  37. package/src/DBC/TYPE.ts +6 -25
  38. package/src/DBC/UNDEFINED.ts +3 -22
  39. package/src/DBC/ZOD.ts +10 -27
  40. package/src/DBC.ts +223 -55
  41. package/tsconfig.json +7 -4
  42. package/tsconfig.test.json +12 -0
  43. package/.parcel-cache/bf96c58b6061a62a-BundleGraph +0 -0
  44. package/.parcel-cache/d7c812d65aeeac59-AssetGraph +0 -0
  45. package/.parcel-cache/data.mdb +0 -0
  46. package/.parcel-cache/e81759c1f106a17f-RequestGraph +0 -0
  47. package/.parcel-cache/fe0db3c4eb428be2-AssetGraph +0 -0
  48. package/.parcel-cache/lock.mdb +0 -0
  49. package/.parcel-cache/snapshot-e81759c1f106a17f.txt +0 -4609
  50. package/dist/DBC/AE.js +0 -173
  51. package/dist/DBC/COMPARISON/GREATER.js +0 -21
  52. package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +0 -21
  53. package/dist/DBC/COMPARISON/LESS.js +0 -21
  54. package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +0 -21
  55. package/dist/DBC/COMPARISON.js +0 -99
  56. package/dist/DBC/DEFINED.js +0 -99
  57. package/dist/DBC/EQ/DIFFERENT.js +0 -21
  58. package/dist/DBC/EQ.js +0 -100
  59. package/dist/DBC/GREATER.js +0 -99
  60. package/dist/DBC/HasAttribute.js +0 -108
  61. package/dist/DBC/IF.js +0 -99
  62. package/dist/DBC/INSTANCE.js +0 -93
  63. package/dist/DBC/JSON.OP.js +0 -133
  64. package/dist/DBC/JSON.Parse.js +0 -114
  65. package/dist/DBC/OR.js +0 -113
  66. package/dist/DBC/REGEX.js +0 -110
  67. package/dist/DBC/TYPE.js +0 -87
  68. package/dist/DBC/ZOD.js +0 -114
  69. package/dist/DBC.js +0 -336
  70. package/dist/Demo.js +0 -290
  71. package/dist/Test.html +0 -18
  72. package/dist/bundle.js +0 -2064
  73. package/dist/index.html +0 -18
  74. package/jest.config.ts +0 -20
  75. package/xpackage-lock.json +0 -122
package/dist/DBC/AE.js DELETED
@@ -1,173 +0,0 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } defining that all elements of an {@link object }s have to fulfill
4
- * a given {@link object }'s check-method (**( toCheck : any ) => boolean | string**).
5
- *
6
- * @remarks
7
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
8
- export class AE extends DBC {
9
- // #region Condition checking.
10
- /**
11
- * Checks each element of the **value**-{@link Array < any >} against the given **condition**, if it is one. If it is not
12
- * the **value** itself will be checked.
13
- *
14
- * @param condition The { check: (toCheck: any) => boolean | string } to check the **value** against.
15
- * @param value Either **value**-{@link Array < any >}, which's elements will be checked, or the value to be
16
- * checked itself.
17
- * @param index If specified with **idxEnd** being undefined, this {@link Number } will be seen as the index of
18
- * the value-{@link Array }'s element to check. If value isn't an {@link Array } this parameter
19
- * will not have any effect.
20
- * With **idxEnd** not undefined this parameter indicates the beginning of the span of elements to
21
- * check within the value-{@link Array }.
22
- * @param idxEnd Indicates the last element's index (including) of the span of value-{@link Array } elements to check.
23
- * Setting this parameter to -1 specifies that all value-{@link Array }'s elements beginning from the
24
- * specified **index** shall be checked.
25
- *
26
- * @returns As soon as the **condition** returns a {@link string }, instead of TRUE, the returned string. TRUE if the
27
- * **condition** never returns a {@link string}. */
28
- static checkAlgorithm(condition, value, index, idxEnd) {
29
- if (Array.isArray(value)) {
30
- if (index !== undefined && idxEnd === undefined) {
31
- if (index > -1 && index < value.length) {
32
- const result = condition.check(value[index]);
33
- if (typeof result === "string") {
34
- return `Violating-Arrayelement at index "${index}" with value "${value[index]}". ${result}`;
35
- }
36
- }
37
- return true; // In order for optional parameter to not cause an error if they are omitted.
38
- }
39
- const ending = idxEnd !== undefined
40
- ? idxEnd !== -1
41
- ? idxEnd + 1
42
- : value.length
43
- : value.length;
44
- for (let i = index ? index : 0; i < ending; i++) {
45
- const result = condition.check(value[i]);
46
- if (result !== true) {
47
- return `Violating-Arrayelement at index ${i}. ${result}`;
48
- }
49
- }
50
- }
51
- else {
52
- return condition.check(value);
53
- }
54
- return true;
55
- }
56
- /**
57
- * A parameter-decorator factory using the {@link AE.checkAlgorithm } with either multiple or a single one
58
- * of the **realConditions** to check the tagged parameter-value against with.
59
- * When specifying an **index** and the tagged parameter's **value** is an {@link Array }, the **realConditions** apply to the
60
- * element at the specified **index**.
61
- * If the {@link Array } is too short the currently processed { check: (toCheck: any) => boolean | string } of
62
- * **realConditions** will be verified to TRUE automatically, considering optional parameters.
63
- * If an **index** is specified but the tagged parameter's value isn't an array, the **index** is treated as being undefined.
64
- * If **index** is undefined and the tagged parameter's value is an {@link Array } each element of it will be checked
65
- * against the **realConditions**.
66
- *
67
- * @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
68
- * against with.
69
- * @param index See the {@link AE.checkAlgorithm }.
70
- * @param idxEnd See the {@link AE.checkAlgorithm }.
71
- * @param path See {@link DBC.decPrecondition }.
72
- * @param dbc See {@link DBC.decPrecondition }.
73
- *
74
- * @returns A {@link string } as soon as one { check: (toCheck: any) => boolean | string } of **realConditions** returns one.
75
- * Otherwise TRUE. */
76
- static PRE(realConditions, index = undefined, idxEnd = undefined, path = undefined, dbc = "WaXCode.DBC") {
77
- return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
78
- if (Array.isArray(realConditions)) {
79
- for (const currentCondition of realConditions) {
80
- const result = AE.checkAlgorithm(currentCondition, value, index, idxEnd);
81
- if (typeof result !== "boolean")
82
- return result;
83
- }
84
- }
85
- else {
86
- return AE.checkAlgorithm(realConditions, value, index, idxEnd);
87
- }
88
- return true;
89
- }, dbc, path);
90
- }
91
- /**
92
- * A method-decorator factory using the {@link AE.checkAlgorithm } with either multiple or a single one
93
- * of the **realConditions** to check the tagged method's return-value against with.
94
- *
95
- * @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
96
- * against with.
97
- * @param index See the {@link AE.checkAlgorithm }.
98
- * @param idxEnd See the {@link AE.checkAlgorithm }.
99
- * @param path See {@link DBC.decPrecondition }.
100
- * @param dbc See {@link DBC.decPrecondition }.
101
- *
102
- * @returns A {@link string } as soon as one { check: (toCheck: any) => boolean | string } of **realConditions** return one.
103
- * Otherwise TRUE. */
104
- static POST(realConditions, index = undefined, idxEnd = undefined, path = undefined, dbc = "WaXCode.DBC") {
105
- return DBC.decPostcondition((value, target, propertyKey) => {
106
- if (Array.isArray(realConditions)) {
107
- for (const currentCondition of realConditions) {
108
- const result = AE.checkAlgorithm(currentCondition, value, index, idxEnd);
109
- if (typeof result !== "boolean")
110
- return result;
111
- }
112
- }
113
- else {
114
- return AE.checkAlgorithm(
115
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
116
- realConditions, value, index, idxEnd);
117
- }
118
- return true;
119
- }, dbc, path);
120
- }
121
- /**
122
- * A field-decorator factory using the {@link AE.checkAlgorithm } with either multiple or a single one
123
- * of the **realConditions** to check the tagged field.
124
- *
125
- * @param realConditions Either one or more { check: (toCheck: any) => boolean | string } to check the tagged parameter-value
126
- * against with.
127
- * @param index See the {@link AE.checkAlgorithm }.
128
- * @param idxEnd See the {@link AE.checkAlgorithm }.
129
- * @param path See {@link DBC.decInvariant }.
130
- * @param dbc See {@link DBC.decInvariant }.
131
- *
132
- * @returns See {@link DBC.decInvariant }. */
133
- static INVARIANT(realConditions, index = undefined, idxEnd = undefined, path = undefined, dbc = "WaXCode.DBC") {
134
- return DBC.decInvariant([new AE(realConditions, index, idxEnd)], path, dbc);
135
- }
136
- // #endregion Condition checking.
137
- // #region Referenced Condition checking.
138
- //
139
- // For usage in dynamic scenarios (like global functions).
140
- //
141
- /**
142
- * Invokes the {@link AE.checkAlgorithm } with all {@link AE.conditions } and the {@link object } {@link toCheck },
143
- * {@link AE.index } & {@link AE.idxEnd }.
144
- *
145
- * @param toCheck See {@link AE.checkAlgorithm }.
146
- *
147
- * @returns See {@link EQ.checkAlgorithm}. */
148
- check(toCheck) {
149
- if (Array.isArray(this.conditions)) {
150
- for (const currentCondition of this.conditions) {
151
- const result = AE.checkAlgorithm(currentCondition, toCheck, this.index, this.idxEnd);
152
- if (typeof result !== "boolean")
153
- return result;
154
- }
155
- }
156
- else {
157
- return AE.checkAlgorithm(
158
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
159
- this.conditions, toCheck, this.index, this.idxEnd);
160
- }
161
- return true;
162
- }
163
- /**
164
- * Creates this {@link AE } by setting the protected property {@link AE.conditions }, {@link AE.index } and {@link AE.idxEnd } used by {@link AE.check }.
165
- *
166
- * @param equivalent See {@link EQ.check }. */
167
- constructor(conditions, index = undefined, idxEnd = undefined) {
168
- super();
169
- this.conditions = conditions;
170
- this.index = index;
171
- this.idxEnd = idxEnd;
172
- }
173
- }
@@ -1,21 +0,0 @@
1
- import { COMPARISON } from "../COMPARISON";
2
- /** See {@link COMPARISON }. */
3
- export class GREATER extends COMPARISON {
4
- /** See {@link COMPARISON.PRE }. */
5
- static PRE(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
6
- return COMPARISON.PRE(equivalent, false, false, path, dbc);
7
- }
8
- /** See {@link COMPARISON.POST }. */
9
- static POST(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
10
- return COMPARISON.POST(equivalent, false, false, path, dbc);
11
- }
12
- /** See {@link COMPARISON.INVARIANT }. */
13
- static INVARIANT(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
14
- return COMPARISON.INVARIANT(equivalent, false, false, path, dbc);
15
- }
16
- /** See {@link COMPARISON.constructor }. */
17
- constructor(equivalent) {
18
- super(equivalent, false, false);
19
- this.equivalent = equivalent;
20
- }
21
- }
@@ -1,21 +0,0 @@
1
- import { COMPARISON } from "../COMPARISON";
2
- /** See {@link COMPARISON }. */
3
- export class GREATER_OR_EQUAL extends COMPARISON {
4
- /** See {@link COMPARISON.PRE }. */
5
- static PRE(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
6
- return COMPARISON.PRE(equivalent, true, false, path, dbc);
7
- }
8
- /** See {@link COMPARISON.POST }. */
9
- static POST(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
10
- return COMPARISON.POST(equivalent, true, false, path, dbc);
11
- }
12
- /** See {@link COMPARISON.INVARIANT }. */
13
- static INVARIANT(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
14
- return COMPARISON.INVARIANT(equivalent, true, false, path, dbc);
15
- }
16
- /** See {@link COMPARISON.constructor }. */
17
- constructor(equivalent) {
18
- super(equivalent, true, false);
19
- this.equivalent = equivalent;
20
- }
21
- }
@@ -1,21 +0,0 @@
1
- import { COMPARISON } from "../COMPARISON";
2
- /** See {@link COMPARISON }. */
3
- export class LESS extends COMPARISON {
4
- /** See {@link COMPARISON.PRE }. */
5
- static PRE(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
6
- return COMPARISON.PRE(equivalent, false, true, path, dbc);
7
- }
8
- /** See {@link COMPARISON.POST }. */
9
- static POST(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
10
- return COMPARISON.POST(equivalent, false, true, path, dbc);
11
- }
12
- /** See {@link COMPARISON.INVARIANT }. */
13
- static INVARIANT(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
14
- return COMPARISON.INVARIANT(equivalent, false, true, path, dbc);
15
- }
16
- /** See {@link COMPARISON.constructor }. */
17
- constructor(equivalent) {
18
- super(equivalent, false, true);
19
- this.equivalent = equivalent;
20
- }
21
- }
@@ -1,21 +0,0 @@
1
- import { COMPARISON } from "../COMPARISON";
2
- /** See {@link COMPARISON }. */
3
- export class LESS_OR_EQUAL extends COMPARISON {
4
- /** See {@link COMPARISON.PRE }. */
5
- static PRE(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
6
- return COMPARISON.PRE(equivalent, true, true, path, dbc);
7
- }
8
- /** See {@link COMPARISON.POST }. */
9
- static POST(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
10
- return COMPARISON.POST(equivalent, true, true, path, dbc);
11
- }
12
- /** See {@link COMPARISON.INVARIANT }. */
13
- static INVARIANT(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
14
- return COMPARISON.INVARIANT(equivalent, true, true, path, dbc);
15
- }
16
- /** See {@link COMPARISON.constructor }. */
17
- constructor(equivalent) {
18
- super(equivalent, true, true);
19
- this.equivalent = equivalent;
20
- }
21
- }
@@ -1,99 +0,0 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } defining a comparison between two {@link object }s.
4
- *
5
- * @remarks
6
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
- export class COMPARISON extends DBC {
8
- // #region Condition checking.
9
- /**
10
- * Does a comparison between the {@link object } **toCheck** and the **equivalent**.
11
- *
12
- * @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
13
- * @param equivalent The {@link object } the one **toCheck** has to be equal to in order for this {@link DBC } to be
14
- * fulfilled.
15
- *
16
- * @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
17
- static checkAlgorithm(toCheck, equivalent, equalityPermitted, invert) {
18
- if (equalityPermitted && !invert && toCheck < equivalent) {
19
- return `Value has to to be greater than or equal to "${equivalent}"`;
20
- }
21
- if (equalityPermitted && invert && toCheck > equivalent) {
22
- return `Value must not to be less than or equal to "${equivalent}"`;
23
- }
24
- if (!equalityPermitted && !invert && toCheck <= equivalent) {
25
- return `Value has to to be greater than "${equivalent}"`;
26
- }
27
- if (!equalityPermitted && invert && toCheck >= equivalent) {
28
- return `Value must not to be less than "${equivalent}"`;
29
- }
30
- return true;
31
- }
32
- /**
33
- * A parameter-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
34
- * by the tagged parameter.
35
- *
36
- * @param equivalent See {@link COMPARISON.checkAlgorithm }.
37
- * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
38
- * @param path See {@link DBC.decPrecondition }.
39
- * @param dbc See {@link DBC.decPrecondition }.
40
- *
41
- * @returns See {@link DBC.decPrecondition }. */
42
- static PRE(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
43
- return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
44
- return COMPARISON.checkAlgorithm(value, equivalent, equalityPermitted, invert);
45
- }, dbc, path);
46
- }
47
- /**
48
- * A method-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
49
- * by the tagged method's returnvalue.
50
- *
51
- * @param equivalent See {@link COMPARISON.checkAlgorithm }.
52
- * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
53
- * @param path See {@link DBC.Postcondition }.
54
- * @param dbc See {@link DBC.decPostcondition }.
55
- *
56
- * @returns See {@link DBC.decPostcondition }. */
57
- static POST(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
58
- return DBC.decPostcondition((value, target, propertyKey) => {
59
- return COMPARISON.checkAlgorithm(value, equalityPermitted, equivalent, invert);
60
- }, dbc, path);
61
- }
62
- /**
63
- * A field-decorator factory using the {@link COMPARISON.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
64
- * by the tagged field.
65
- *
66
- * @param equivalent See {@link COMPARISON.checkAlgorithm }.
67
- * @param equalityPermitted See {@link COMPARISON.checkAlgorithm }.
68
- * @param path See {@link DBC.decInvariant }.
69
- * @param dbc See {@link DBC.decInvariant }.
70
- *
71
- * @returns See {@link DBC.decInvariant }. */
72
- static INVARIANT(equivalent, equalityPermitted = false, invert = false, path = undefined, dbc = "WaXCode.DBC") {
73
- return DBC.decInvariant([new COMPARISON(equivalent, equalityPermitted, invert)], path, dbc);
74
- }
75
- // #endregion Condition checking.
76
- // #region Referenced Condition checking.
77
- // #region Dynamic usage.
78
- /**
79
- * Invokes the {@link COMPARISON.checkAlgorithm } passing the value **toCheck**, {@link COMPARISON.equivalent } and {@link COMPARISON.invert }.
80
- *
81
- * @param toCheck See {@link COMPARISON.checkAlgorithm }.
82
- *
83
- * @returns See {@link COMPARISON.checkAlgorithm}. */
84
- check(toCheck) {
85
- return COMPARISON.checkAlgorithm(toCheck, this.equivalent, this.equalityPermitted, this.invert);
86
- }
87
- /**
88
- * Creates this {@link COMPARISON } by setting the protected property {@link COMPARISON.equivalent }, {@link COMPARISON.equalityPermitted } and {@link COMPARISON.invert } used by {@link COMPARISON.check }.
89
- *
90
- * @param equivalent See {@link COMPARISON.check }.
91
- * @param equalityPermitted See {@link COMPARISON.check }.
92
- * @param invert See {@link COMPARISON.check }. */
93
- constructor(equivalent, equalityPermitted = false, invert = false) {
94
- super();
95
- this.equivalent = equivalent;
96
- this.equalityPermitted = equalityPermitted;
97
- this.invert = invert;
98
- }
99
- }
@@ -1,99 +0,0 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } defining that an {@link object }s must be defined thus it's value may not be **null** or **undefined**.
4
- *
5
- * @remarks
6
- * Maintainer: Salvatore Callari (XDBC@WaXCode.net) */
7
- export class DEFINED extends DBC {
8
- /**
9
- * Checks if the value **toCheck** is null or undefined.
10
- *
11
- * @param toCheck The {@link Object } to check.
12
- *
13
- * @returns TRUE if the value **toCheck** is of the specified **type**, otherwise FALSE. */
14
- // biome-ignore lint/suspicious/noExplicitAny: Necessary for dynamic type checking of also UNDEFINED.
15
- static checkAlgorithm(toCheck) {
16
- // biome-ignore lint/suspicious/useValidTypeof: Necessary
17
- if (toCheck === undefined || toCheck === null) {
18
- return `Value may not be UNDEFINED or NULL but it is ${toCheck === undefined ? "UNDEFINED" : "NULL"}`;
19
- }
20
- return true;
21
- }
22
- /**
23
- * A parameter-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
24
- * by the tagged parameter.
25
- *
26
- * @param type See {@link DEFINED.checkAlgorithm }.
27
- * @param path See {@link DBC.decPrecondition }.
28
- * @param dbc See {@link DBC.decPrecondition }.
29
- *
30
- * @returns See {@link DBC.decPrecondition }. */
31
- static PRE(path = undefined, dbc = "WaXCode.DBC") {
32
- return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
33
- return DEFINED.checkAlgorithm(value);
34
- }, dbc, path);
35
- }
36
- /**
37
- * A method-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
38
- * by the tagged method's returnvalue.
39
- *
40
- * @param type See {@link DEFINED.checkAlgorithm }.
41
- * @param path See {@link DBC.Postcondition }.
42
- * @param dbc See {@link DBC.decPostcondition }.
43
- *
44
- * @returns See {@link DBC.decPostcondition }. */
45
- static POST(type, path = undefined, dbc = "WaXCode.DBC") {
46
- return DBC.decPostcondition((value, target, propertyKey) => {
47
- return DEFINED.checkAlgorithm(value);
48
- }, dbc, path);
49
- }
50
- /**
51
- * A field-decorator factory using the {@link DEFINED.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
52
- * by the tagged field.
53
- *
54
- * @param type See {@link DEFINED.checkAlgorithm }.
55
- * @param path See {@link DBC.decInvariant }.
56
- * @param dbc See {@link DBC.decInvariant }.
57
- *
58
- * @returns See {@link DBC.decInvariant }. */
59
- static INVARIANT(type, path = undefined, dbc = "WaXCode.DBC") {
60
- return DBC.decInvariant([new DEFINED()], path, dbc);
61
- }
62
- // #endregion Condition checking.
63
- // #region Referenced Condition checking.
64
- //
65
- // For usage in dynamic scenarios (like with AE-DBC).
66
- //
67
- /**
68
- * Invokes the {@link DEFINED.checkAlgorithm } passing the value **toCheck** and the {@link DEFINED.type } .
69
- *
70
- * @param toCheck See {@link DEFINED.checkAlgorithm }.
71
- *
72
- * @returns See {@link DEFINED.checkAlgorithm}. */
73
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
74
- check(toCheck) {
75
- return DEFINED.checkAlgorithm(toCheck);
76
- }
77
- /**
78
- * Invokes the {@link DEFINED.checkAlgorithm } passing the value **toCheck** and the {@link DEFINED.type } .
79
- *
80
- * @param toCheck See {@link DEFINED.checkAlgorithm }.
81
- * @param id A {@link string } identifying this {@link INSTANCE } via the {@link DBC.Infringement }-Message.
82
- *
83
- * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link DEFINED }.
84
- *
85
- * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link DEFINED }.*/
86
- static tsCheck(toCheck, id = undefined) {
87
- const result = DEFINED.checkAlgorithm(toCheck);
88
- if (result === true) {
89
- return toCheck;
90
- }
91
- else {
92
- throw new DBC.Infringement(`${id ? `(${id}) ` : ""}${result}`);
93
- }
94
- }
95
- /** Creates this {@link DEFINED }. */
96
- constructor() {
97
- super();
98
- }
99
- }
@@ -1,21 +0,0 @@
1
- import { EQ } from "../EQ";
2
- /** See {@link COMPARISON }. */
3
- export class DIFFERENT extends EQ {
4
- /** See {@link COMPARISON.PRE }. */
5
- static PRE(equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
6
- return EQ.PRE(equivalent, true, path, dbc);
7
- }
8
- /** See {@link COMPARISON.POST }. */
9
- static POST(equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
10
- return EQ.POST(equivalent, true, path, dbc);
11
- }
12
- /** See {@link COMPARISON.INVARIANT }. */
13
- static INVARIANT(equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
14
- return EQ.INVARIANT(equivalent, true, path, dbc);
15
- }
16
- /** See {@link COMPARISON.constructor }. */
17
- constructor(equivalent) {
18
- super(equivalent, true);
19
- this.equivalent = equivalent;
20
- }
21
- }
package/dist/DBC/EQ.js DELETED
@@ -1,100 +0,0 @@
1
- import { DBC } from "../DBC";
2
- /**
3
- * A {@link DBC } defining that two {@link object }s gotta be equal.
4
- *
5
- * @remarks
6
- * Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
7
- export class EQ extends DBC {
8
- // #region Condition checking.
9
- /**
10
- * Checks if the value **toCheck** is equal to the specified **equivalent**.
11
- *
12
- * @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
13
- * @param equivalent The {@link object } the one **toCheck** has to be equal to in order for this {@link DBC } to be
14
- * fulfilled.
15
- *
16
- * @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
17
- static checkAlgorithm(
18
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
19
- toCheck, equivalent, invert) {
20
- if (!invert && equivalent !== toCheck) {
21
- return `Value has to to be equal to "${equivalent}"`;
22
- }
23
- if (invert && equivalent === toCheck) {
24
- return `Value must not to be equal to "${equivalent}"`;
25
- }
26
- return true;
27
- }
28
- /**
29
- * A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
30
- * by the tagged parameter.
31
- *
32
- * @param equivalent See {@link EQ.checkAlgorithm }.
33
- * @param path See {@link DBC.decPrecondition }.
34
- * @param dbc See {@link DBC.decPrecondition }.
35
- *
36
- * @returns See {@link DBC.decPrecondition }. */
37
- static PRE(
38
- // biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
39
- equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
40
- return DBC.decPrecondition((value, target, methodName, parameterIndex) => {
41
- return EQ.checkAlgorithm(value, equivalent, invert);
42
- }, dbc, path);
43
- }
44
- /**
45
- * A method-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
46
- * by the tagged method's returnvalue.
47
- *
48
- * @param equivalent See {@link EQ.checkAlgorithm }.
49
- * @param path See {@link DBC.Postcondition }.
50
- * @param dbc See {@link DBC.decPostcondition }.
51
- *
52
- * @returns See {@link DBC.decPostcondition }. */
53
- static POST(
54
- // biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
55
- equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
56
- return DBC.decPostcondition((value, target, propertyKey) => {
57
- return EQ.checkAlgorithm(value, equivalent, invert);
58
- }, dbc, path);
59
- }
60
- /**
61
- * A field-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
62
- * by the tagged field.
63
- *
64
- * @param equivalent See {@link EQ.checkAlgorithm }.
65
- * @param path See {@link DBC.decInvariant }.
66
- * @param dbc See {@link DBC.decInvariant }.
67
- *
68
- * @returns See {@link DBC.decInvariant }. */
69
- static INVARIANT(
70
- // biome-ignore lint/suspicious/noExplicitAny: To check for UNDEFINED and NULL.
71
- equivalent, invert = false, path = undefined, dbc = "WaXCode.DBC") {
72
- return DBC.decInvariant([new EQ(equivalent, invert)], path, dbc);
73
- }
74
- // #endregion Condition checking.
75
- // #region Referenced Condition checking.
76
- //
77
- // For usage in dynamic scenarios (like with AE-DBC).
78
- //
79
- /**
80
- * Invokes the {@link EQ.checkAlgorithm } passing the value **toCheck**, {@link EQ.equivalent } and {@link EQ.invert }.
81
- *
82
- * @param toCheck See {@link EQ.checkAlgorithm }.
83
- *
84
- * @returns See {@link EQ.checkAlgorithm}. */
85
- // biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
86
- check(toCheck) {
87
- return EQ.checkAlgorithm(toCheck, this.equivalent, this.invert);
88
- }
89
- /**
90
- * Creates this {@link EQ } by setting the protected property {@link EQ.equivalent } used by {@link EQ.check }.
91
- *
92
- * @param equivalent See {@link EQ.check }. */
93
- constructor(
94
- // biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
95
- equivalent, invert = false) {
96
- super();
97
- this.equivalent = equivalent;
98
- this.invert = invert;
99
- }
100
- }