xdbc 1.0.108 → 1.0.109

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.
package/dist/DBC/EQ.js CHANGED
@@ -86,6 +86,23 @@ export class EQ extends DBC {
86
86
  check(toCheck) {
87
87
  return EQ.checkAlgorithm(toCheck, this.equivalent, this.invert);
88
88
  }
89
+ /**
90
+ * Invokes the {@link EQ.checkAlgorithm } passing the value **toCheck** and the specified **type** .
91
+ *
92
+ * @param toCheck See {@link EQ.checkAlgorithm }.
93
+ *
94
+ * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link EQ }.
95
+ *
96
+ * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link EQ }.*/
97
+ static tsCheck(toCheck, equivalent) {
98
+ const result = EQ.checkAlgorithm(toCheck, equivalent, false);
99
+ if (result) {
100
+ return toCheck;
101
+ }
102
+ else {
103
+ throw new DBC.Infringement(result);
104
+ }
105
+ }
89
106
  /**
90
107
  * Creates this {@link EQ } by setting the protected property {@link EQ.equivalent } used by {@link EQ.check }.
91
108
  *
package/dist/DBC.js CHANGED
@@ -70,9 +70,8 @@ export class DBC {
70
70
  const originalMethod = descriptor.value;
71
71
  // biome-ignore lint/suspicious/noExplicitAny: Gotta be any since parameter-values may be undefined.
72
72
  descriptor.value = function (...args) {
73
- // to correctly capture 'this' from the call site
74
73
  // #region Check if a value of one of the method's parameter has been requested and pass it to the
75
- // receptor, if so.
74
+ // receptor, if so.
76
75
  if (DBC.paramValueRequests.has(target) &&
77
76
  DBC.paramValueRequests.get(target).has(propertyKey)) {
78
77
  for (const index of DBC.paramValueRequests
@@ -89,10 +88,8 @@ export class DBC {
89
88
  }
90
89
  }
91
90
  }
92
- // #endregion Check if a value of one of the method's parameter has been requested and pass it to the
91
+ // #endregion Check if a value of one of the method's parameter has been requested and pass it to the
93
92
  // receptor, if so.
94
- // The 'this' here is now the correct 'this' of the instance
95
- // where the decorated method was called.
96
93
  return originalMethod.apply(this, args);
97
94
  };
98
95
  return descriptor;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.108",
2
+ "version": "1.0.109",
3
3
  "name": "xdbc",
4
4
  "scripts": {
5
5
  "docs": "typedoc",
package/src/DBC/EQ.ts CHANGED
@@ -124,6 +124,24 @@ export class EQ extends DBC {
124
124
  public check(toCheck: any) {
125
125
  return EQ.checkAlgorithm(toCheck, this.equivalent, this.invert);
126
126
  }
127
+ /**
128
+ * Invokes the {@link EQ.checkAlgorithm } passing the value **toCheck** and the specified **type** .
129
+ *
130
+ * @param toCheck See {@link EQ.checkAlgorithm }.
131
+ *
132
+ * @returns The **CANDIDATE** **toCheck** doesn't fulfill this {@link EQ }.
133
+ *
134
+ * @throws A {@link DBC.Infringement } if the **CANDIDATE** **toCheck** does not fulfill this {@link EQ }.*/
135
+ public static tsCheck<CANDIDATE>( toCheck : CANDIDATE | undefined | null, equivalent : any ) : CANDIDATE {
136
+ const result = EQ.checkAlgorithm(toCheck, equivalent, false );
137
+
138
+ if( result ) {
139
+ return toCheck as CANDIDATE ;
140
+ }
141
+ else {
142
+ throw new DBC.Infringement( result as string );
143
+ }
144
+ }
127
145
  /**
128
146
  * Creates this {@link EQ } by setting the protected property {@link EQ.equivalent } used by {@link EQ.check }.
129
147
  *
package/src/DBC.ts CHANGED
@@ -92,41 +92,36 @@ export class DBC {
92
92
  propertyKey: string,
93
93
  descriptor: PropertyDescriptor,
94
94
  ): PropertyDescriptor {
95
- const originalMethod = descriptor.value;
96
-
97
- // biome-ignore lint/suspicious/noExplicitAny: Gotta be any since parameter-values may be undefined.
98
- descriptor.value = function (...args: any[]) { // Changed to a regular function expression
99
- // to correctly capture 'this' from the call site
100
- // #region Check if a value of one of the method's parameter has been requested and pass it to the
101
- // receptor, if so.
102
- if (
103
- DBC.paramValueRequests.has(target) &&
104
- DBC.paramValueRequests.get(target).has(propertyKey)
105
- ) {
106
- for (const index of DBC.paramValueRequests
107
- .get(target)
108
- .get(propertyKey)
109
- .keys()) {
110
- if (index < args.length) {
111
- for (const receptor of DBC.paramValueRequests
112
- .get(target)
113
- .get(propertyKey)
114
- .get(index)) {
115
- receptor(args[index]);
116
- }
117
- }
118
- }
119
- }
120
- // #endregion Check if a value of one of the method's parameter has been requested and pass it to the
121
- // receptor, if so.
122
-
123
- // The 'this' here is now the correct 'this' of the instance
124
- // where the decorated method was called.
125
- return originalMethod.apply(this, args);
126
- };
95
+ const originalMethod = descriptor.value;
96
+ // biome-ignore lint/suspicious/noExplicitAny: Gotta be any since parameter-values may be undefined.
97
+ descriptor.value = function (...args: any[]) {
98
+ // #region Check if a value of one of the method's parameter has been requested and pass it to the
99
+ // receptor, if so.
100
+ if (
101
+ DBC.paramValueRequests.has(target) &&
102
+ DBC.paramValueRequests.get(target).has(propertyKey)
103
+ ) {
104
+ for (const index of DBC.paramValueRequests
105
+ .get(target)
106
+ .get(propertyKey)
107
+ .keys()) {
108
+ if (index < args.length) {
109
+ for (const receptor of DBC.paramValueRequests
110
+ .get(target)
111
+ .get(propertyKey)
112
+ .get(index)) {
113
+ receptor(args[index]);
114
+ }
115
+ }
116
+ }
117
+ }
118
+ // #endregion Check if a value of one of the method's parameter has been requested and pass it to the
119
+ // receptor, if so.
120
+ return originalMethod.apply(this, args);
121
+ };
127
122
 
128
- return descriptor;
129
- }
123
+ return descriptor;
124
+ }
130
125
  // #endregion Parameter-value requests.
131
126
  // #region Class
132
127
  /**