@ayapapa-npm/contracts-js 0.2.0 → 0.2.2
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/README.md +168 -18
- package/dist/index.cjs +367 -95
- package/dist/index.d.cts +437 -102
- package/dist/index.d.ts +437 -102
- package/dist/index.js +367 -95
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,152 +1,487 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Contract
|
|
3
|
-
*
|
|
2
|
+
* Design by Contract utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides runtime contract checks based on
|
|
5
|
+
* Design by Contract principles.
|
|
6
|
+
*
|
|
7
|
+
* ## Contract Types
|
|
8
|
+
*
|
|
9
|
+
* - REQUIRE (Precondition)
|
|
10
|
+
* Conditions that must be satisfied before execution starts.
|
|
11
|
+
* Used for validating input arguments and required states.
|
|
12
|
+
*
|
|
13
|
+
* - VERIFY (Intermediate Condition)
|
|
14
|
+
* Conditions checked during execution.
|
|
15
|
+
* Used for validating intermediate results and internal assumptions.
|
|
16
|
+
*
|
|
17
|
+
* - ENSURE (Postcondition)
|
|
18
|
+
* Conditions that must be satisfied after execution completes.
|
|
19
|
+
* Used for validating return values and completed state changes.
|
|
20
|
+
*
|
|
21
|
+
* - INVARIANT (Invariant Condition)
|
|
22
|
+
* Conditions that must remain valid throughout
|
|
23
|
+
* the lifetime of an object or component.
|
|
24
|
+
*
|
|
25
|
+
* ## Debug Mode
|
|
26
|
+
*
|
|
27
|
+
* Methods ending with `_DEBUG` execute contract checks only
|
|
28
|
+
* when `DEBUG_MODE` is enabled.
|
|
29
|
+
*
|
|
30
|
+
* When `DEBUG_MODE` is disabled,
|
|
31
|
+
* these methods return the original condition value
|
|
32
|
+
* without performing validation.
|
|
33
|
+
*
|
|
34
|
+
* @module Contracts
|
|
4
35
|
*/
|
|
5
36
|
declare class Contracts {
|
|
37
|
+
/** @type {boolean} Debug mode state */
|
|
6
38
|
static DEBUG_MODE: boolean;
|
|
7
39
|
/**
|
|
8
|
-
* Configures
|
|
9
|
-
*
|
|
40
|
+
* Configures contract checking behavior.
|
|
41
|
+
*
|
|
42
|
+
* @param {{debug?: boolean}} config
|
|
43
|
+
* Configuration options.
|
|
44
|
+
*
|
|
45
|
+
* The `debug` property enables or disables
|
|
46
|
+
* debug-only contract checks.
|
|
47
|
+
*
|
|
48
|
+
* When `debug` is `true`,
|
|
49
|
+
* methods ending with `_DEBUG` perform validation.
|
|
50
|
+
*
|
|
51
|
+
* When `debug` is `false` or omitted,
|
|
52
|
+
* methods ending with `_DEBUG` skip validation.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* Contracts.setConfig({ debug: true });
|
|
10
56
|
*/
|
|
11
57
|
static setConfig(config: {
|
|
12
58
|
debug?: boolean;
|
|
13
59
|
}): void;
|
|
14
60
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
61
|
+
* Verifies an intermediate condition during execution.
|
|
62
|
+
*
|
|
63
|
+
* VERIFY is used to validate intermediate results
|
|
64
|
+
* and internal assumptions during execution.
|
|
65
|
+
*
|
|
66
|
+
* Unlike REQUIRE and ENSURE, VERIFY does not represent
|
|
67
|
+
* a condition at the function boundary.
|
|
68
|
+
*
|
|
69
|
+
* Unlike INVARIANT, VERIFY does not represent a condition
|
|
70
|
+
* that must always remain true.
|
|
71
|
+
*
|
|
72
|
+
* Typical usage:
|
|
73
|
+
* - Validate intermediate calculation results.
|
|
74
|
+
* - Confirm internal processing states.
|
|
75
|
+
* - Check temporary assumptions during execution.
|
|
76
|
+
*
|
|
77
|
+
* @param {boolean} isOk
|
|
78
|
+
* Condition result to verify.
|
|
79
|
+
*
|
|
80
|
+
* @param {string|null} [ngMsg]
|
|
81
|
+
* Failure message.
|
|
82
|
+
*
|
|
83
|
+
* @param {(new (...args:any[])=>Error)|null} [ErrorClass=Error]
|
|
84
|
+
* Error constructor used when the check fails.
|
|
85
|
+
*
|
|
86
|
+
* Supported values:
|
|
87
|
+
* - `Error` (default)
|
|
88
|
+
* - `TypeError`
|
|
89
|
+
* - `RangeError`
|
|
90
|
+
* - Custom Error subclasses
|
|
91
|
+
* - `null` to skip throwing and log the failure.
|
|
92
|
+
*
|
|
93
|
+
* @param {Object<string, *>} [eProps]
|
|
94
|
+
* Additional properties assigned to the error object.
|
|
95
|
+
*
|
|
96
|
+
* @returns {boolean}
|
|
97
|
+
* Returns the original condition value.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const result = calculate();
|
|
101
|
+
*
|
|
102
|
+
* Contracts.VERIFY(
|
|
103
|
+
* result >= 0,
|
|
104
|
+
* 'Calculation result must not be negative'
|
|
105
|
+
* );
|
|
23
106
|
*/
|
|
24
|
-
static VERIFY(isOk: boolean, ngMsg?: string,
|
|
107
|
+
static VERIFY(isOk: boolean, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
25
108
|
[x: string]: any;
|
|
26
109
|
}): boolean;
|
|
27
110
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
111
|
+
* Verifies an intermediate condition in debug mode only.
|
|
112
|
+
*
|
|
113
|
+
* Performs the same validation as VERIFY only when
|
|
114
|
+
* DEBUG_MODE is enabled.
|
|
115
|
+
*
|
|
116
|
+
* When DEBUG_MODE is disabled,
|
|
117
|
+
* no validation is performed.
|
|
118
|
+
*
|
|
119
|
+
* Typical usage:
|
|
120
|
+
* - Validate intermediate results during development.
|
|
121
|
+
* - Check internal assumptions while debugging.
|
|
122
|
+
*
|
|
123
|
+
* @param {boolean} isOk
|
|
124
|
+
* Condition result to verify.
|
|
125
|
+
*
|
|
126
|
+
* @param {string|null} [ngMsg]
|
|
127
|
+
* Failure message.
|
|
128
|
+
*
|
|
129
|
+
* @param {(new (...args:any[])=>Error)|null} [ErrorClass=Error]
|
|
130
|
+
* Error constructor used when the check fails.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object<string, *>} [eProps]
|
|
133
|
+
* Additional properties assigned to the error object.
|
|
134
|
+
*
|
|
135
|
+
* @returns {boolean}
|
|
136
|
+
* Returns the original condition value.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* Contracts.VERIFY_DEBUG(
|
|
140
|
+
* intermediate !== null,
|
|
141
|
+
* 'Intermediate value must not be null'
|
|
142
|
+
* );
|
|
36
143
|
*/
|
|
37
|
-
static VERIFY_DEBUG(isOk: boolean, ngMsg?: string,
|
|
144
|
+
static VERIFY_DEBUG(isOk: boolean, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
38
145
|
[x: string]: any;
|
|
39
146
|
}): boolean;
|
|
40
147
|
/**
|
|
41
|
-
* Checks a precondition.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
148
|
+
* Checks a precondition before execution.
|
|
149
|
+
*
|
|
150
|
+
* A precondition defines conditions that must be satisfied
|
|
151
|
+
* before a function or operation starts.
|
|
152
|
+
*
|
|
153
|
+
* The caller is responsible for satisfying preconditions.
|
|
154
|
+
*
|
|
155
|
+
* Typical usage:
|
|
156
|
+
* - Validate function arguments.
|
|
157
|
+
* - Validate required object state.
|
|
158
|
+
* - Check required external conditions.
|
|
159
|
+
*
|
|
160
|
+
* @param {boolean} isOk
|
|
161
|
+
* Condition result to verify.
|
|
162
|
+
*
|
|
163
|
+
* @param {string|null} [ngMsg]
|
|
164
|
+
* Failure message.
|
|
165
|
+
*
|
|
166
|
+
* @param {(new (...args:any[])=>Error)|null} [ErrorClass=Error]
|
|
167
|
+
* Error constructor used when the check fails.
|
|
168
|
+
*
|
|
169
|
+
* Supported values:
|
|
170
|
+
* - `Error` (default)
|
|
171
|
+
* - `TypeError`
|
|
172
|
+
* - `RangeError`
|
|
173
|
+
* - Custom Error subclasses
|
|
174
|
+
* - `null` to skip throwing and log the failure.
|
|
175
|
+
*
|
|
176
|
+
* @param {Object<string, *>} [eProps]
|
|
177
|
+
* Additional properties assigned to the error object.
|
|
178
|
+
*
|
|
179
|
+
* @returns {boolean}
|
|
180
|
+
* Returns the original condition value.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* function divide(a, b) {
|
|
184
|
+
* Contracts.REQUIRE(
|
|
185
|
+
* typeof a === 'number',
|
|
186
|
+
* 'a must be a number'
|
|
187
|
+
* );
|
|
188
|
+
*
|
|
189
|
+
* Contracts.REQUIRE(
|
|
190
|
+
* b !== 0,
|
|
191
|
+
* 'Divisor cannot be zero'
|
|
192
|
+
* );
|
|
193
|
+
*
|
|
194
|
+
* return a / b;
|
|
195
|
+
* }
|
|
50
196
|
*/
|
|
51
|
-
static REQUIRE(isOk: boolean, ngMsg?: string,
|
|
197
|
+
static REQUIRE(isOk: boolean, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
52
198
|
[x: string]: any;
|
|
53
199
|
}): boolean;
|
|
54
200
|
/**
|
|
55
|
-
* Checks a precondition
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
201
|
+
* Checks a precondition in debug mode only.
|
|
202
|
+
*
|
|
203
|
+
* Performs the same validation as REQUIRE only when
|
|
204
|
+
* DEBUG_MODE is enabled.
|
|
205
|
+
*
|
|
206
|
+
* When DEBUG_MODE is disabled,
|
|
207
|
+
* no validation is performed.
|
|
208
|
+
*
|
|
209
|
+
* Typical usage:
|
|
210
|
+
* - Validate assumptions during development.
|
|
211
|
+
* - Perform additional argument checks while debugging.
|
|
212
|
+
*
|
|
213
|
+
* @param {boolean} isOk
|
|
214
|
+
* Condition result to verify.
|
|
215
|
+
*
|
|
216
|
+
* @param {string|null} [ngMsg]
|
|
217
|
+
* Failure message.
|
|
218
|
+
*
|
|
219
|
+
* @param {(new (...args:any[])=>Error)|null} [ErrorClass=Error]
|
|
220
|
+
* Error constructor used when the check fails.
|
|
221
|
+
*
|
|
222
|
+
* @param {Object<string, *>} [eProps]
|
|
223
|
+
* Additional properties assigned to the error object.
|
|
224
|
+
*
|
|
225
|
+
* @returns {boolean}
|
|
226
|
+
* Returns the original condition value.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* Contracts.REQUIRE_DEBUG(
|
|
230
|
+
* user !== null,
|
|
231
|
+
* 'User must exist during debugging'
|
|
232
|
+
* );
|
|
63
233
|
*/
|
|
64
|
-
static REQUIRE_DEBUG(isOk: boolean, ngMsg?: string,
|
|
234
|
+
static REQUIRE_DEBUG(isOk: boolean, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
65
235
|
[x: string]: any;
|
|
66
236
|
}): boolean;
|
|
67
237
|
/**
|
|
68
|
-
* Checks a postcondition.
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
238
|
+
* Checks a postcondition after execution.
|
|
239
|
+
*
|
|
240
|
+
* A postcondition defines conditions that must be satisfied
|
|
241
|
+
* after a function or operation completes.
|
|
242
|
+
*
|
|
243
|
+
* ENSURE represents guarantees provided by the function
|
|
244
|
+
* to its caller.
|
|
245
|
+
*
|
|
246
|
+
* Typical usage:
|
|
247
|
+
* - Validate return values.
|
|
248
|
+
* - Confirm state changes.
|
|
249
|
+
* - Verify that processing completed correctly.
|
|
250
|
+
*
|
|
251
|
+
* @param {boolean} isOk
|
|
252
|
+
* Condition result to verify.
|
|
253
|
+
*
|
|
254
|
+
* @param {string|null} [ngMsg]
|
|
255
|
+
* Failure message.
|
|
256
|
+
*
|
|
257
|
+
* @param {(new (...args:any[])=>Error)|null} [ErrorClass=Error]
|
|
258
|
+
* Error constructor used when the check fails.
|
|
259
|
+
*
|
|
260
|
+
* Supported values:
|
|
261
|
+
* - `Error` (default)
|
|
262
|
+
* - `TypeError`
|
|
263
|
+
* - `RangeError`
|
|
264
|
+
* - Custom Error subclasses
|
|
265
|
+
* - `null` to skip throwing and log the failure.
|
|
266
|
+
*
|
|
267
|
+
* @param {Object<string, *>} [eProps]
|
|
268
|
+
* Additional properties assigned to the error object.
|
|
269
|
+
*
|
|
270
|
+
* @returns {boolean}
|
|
271
|
+
* Returns the original condition value.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* function double(value) {
|
|
275
|
+
* Contracts.REQUIRE(
|
|
276
|
+
* value >= 0,
|
|
277
|
+
* 'Value must not be negative'
|
|
278
|
+
* );
|
|
279
|
+
*
|
|
280
|
+
* const result = value * 2;
|
|
281
|
+
*
|
|
282
|
+
* Contracts.ENSURE(
|
|
283
|
+
* result >= 0,
|
|
284
|
+
* 'Result must not be negative'
|
|
285
|
+
* );
|
|
286
|
+
*
|
|
287
|
+
* return result;
|
|
288
|
+
* }
|
|
77
289
|
*/
|
|
78
|
-
static ENSURE(isOk: boolean, ngMsg?: string,
|
|
290
|
+
static ENSURE(isOk: boolean, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
79
291
|
[x: string]: any;
|
|
80
292
|
}): boolean;
|
|
81
293
|
/**
|
|
82
|
-
* Checks a postcondition
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
294
|
+
* Checks a postcondition in debug mode only.
|
|
295
|
+
*
|
|
296
|
+
* Performs the same validation as ENSURE only when
|
|
297
|
+
* DEBUG_MODE is enabled.
|
|
298
|
+
*
|
|
299
|
+
* When DEBUG_MODE is disabled,
|
|
300
|
+
* no validation is performed.
|
|
301
|
+
*
|
|
302
|
+
* Typical usage:
|
|
303
|
+
* - Validate detailed results during development.
|
|
304
|
+
* - Confirm internal behavior while debugging.
|
|
305
|
+
*
|
|
306
|
+
* @param {boolean} isOk
|
|
307
|
+
* Condition result to verify.
|
|
308
|
+
*
|
|
309
|
+
* @param {string|null} [ngMsg]
|
|
310
|
+
* Failure message.
|
|
311
|
+
*
|
|
312
|
+
* @param {(new (...args:any[])=>Error)|null} [ErrorClass=Error]
|
|
313
|
+
* Error constructor used when the check fails.
|
|
314
|
+
*
|
|
315
|
+
* @param {Object<string, *>} [eProps]
|
|
316
|
+
* Additional properties assigned to the error object.
|
|
317
|
+
*
|
|
318
|
+
* @returns {boolean}
|
|
319
|
+
* Returns the original condition value.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* Contracts.ENSURE_DEBUG(
|
|
323
|
+
* result !== undefined,
|
|
324
|
+
* 'Result should exist during debugging'
|
|
325
|
+
* );
|
|
90
326
|
*/
|
|
91
|
-
static ENSURE_DEBUG(isOk: boolean, ngMsg?: string,
|
|
327
|
+
static ENSURE_DEBUG(isOk: boolean, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
92
328
|
[x: string]: any;
|
|
93
329
|
}): boolean;
|
|
94
330
|
/**
|
|
95
|
-
* Checks an invariant.
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
331
|
+
* Checks an invariant condition.
|
|
332
|
+
*
|
|
333
|
+
* An invariant represents a condition that must remain valid
|
|
334
|
+
* throughout the lifetime of an object or component.
|
|
335
|
+
*
|
|
336
|
+
* Typical usage:
|
|
337
|
+
* - Validate internal object consistency.
|
|
338
|
+
* - Protect class state integrity.
|
|
339
|
+
* - Confirm assumptions that must always hold.
|
|
340
|
+
*
|
|
341
|
+
* In Design by Contract terminology,
|
|
342
|
+
* INVARIANT represents conditions that must always remain true.
|
|
343
|
+
*
|
|
344
|
+
* @param {boolean} isOk
|
|
345
|
+
* Condition result to verify.
|
|
346
|
+
*
|
|
347
|
+
* @param {string|null} [ngMsg]
|
|
348
|
+
* Failure message.
|
|
349
|
+
*
|
|
350
|
+
* @param {(new (...args:any[])=>Error)|null} [ErrorClass=Error]
|
|
351
|
+
* Error constructor used when the check fails.
|
|
352
|
+
*
|
|
353
|
+
* Supported values:
|
|
354
|
+
* - `Error` (default)
|
|
355
|
+
* - `TypeError`
|
|
356
|
+
* - `RangeError`
|
|
357
|
+
* - Custom Error subclasses
|
|
358
|
+
* - `null` to skip throwing and log the failure.
|
|
359
|
+
*
|
|
360
|
+
* @param {Object<string, *>} [eProps]
|
|
361
|
+
* Additional properties assigned to the error object.
|
|
362
|
+
*
|
|
363
|
+
* @returns {boolean}
|
|
364
|
+
* Returns the original condition value.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* class BankAccount {
|
|
368
|
+
*
|
|
369
|
+
* withdraw(amount) {
|
|
370
|
+
* this.balance -= amount;
|
|
371
|
+
*
|
|
372
|
+
* Contracts.INVARIANT(
|
|
373
|
+
* this.balance >= 0,
|
|
374
|
+
* 'Balance cannot be negative'
|
|
375
|
+
* );
|
|
376
|
+
* }
|
|
377
|
+
*
|
|
378
|
+
* }
|
|
104
379
|
*/
|
|
105
|
-
static INVARIANT(isOk: boolean, ngMsg?: string,
|
|
380
|
+
static INVARIANT(isOk: boolean, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
106
381
|
[x: string]: any;
|
|
107
382
|
}): boolean;
|
|
108
383
|
/**
|
|
109
|
-
* Checks an invariant
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
384
|
+
* Checks an invariant condition in debug mode only.
|
|
385
|
+
*
|
|
386
|
+
* Performs the same validation as INVARIANT only when
|
|
387
|
+
* DEBUG_MODE is enabled.
|
|
388
|
+
*
|
|
389
|
+
* When DEBUG_MODE is disabled,
|
|
390
|
+
* no validation is performed.
|
|
391
|
+
*
|
|
392
|
+
* Typical usage:
|
|
393
|
+
* - Validate object consistency during development.
|
|
394
|
+
* - Detect unexpected state changes while debugging.
|
|
395
|
+
*
|
|
396
|
+
* @param {boolean} isOk
|
|
397
|
+
* Condition result to verify.
|
|
398
|
+
*
|
|
399
|
+
* @param {string|null} [ngMsg]
|
|
400
|
+
* Failure message.
|
|
401
|
+
*
|
|
402
|
+
* @param {(new (...args:any[])=>Error)|null} [ErrorClass=Error]
|
|
403
|
+
* Error constructor used when the check fails.
|
|
404
|
+
*
|
|
405
|
+
* @param {Object<string, *>} [eProps]
|
|
406
|
+
* Additional properties assigned to the error object.
|
|
407
|
+
*
|
|
408
|
+
* @returns {boolean}
|
|
409
|
+
* Returns the original condition value.
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* Contracts.INVARIANT_DEBUG(
|
|
413
|
+
* cache.size < 1000,
|
|
414
|
+
* 'Cache size exceeded expected limit'
|
|
415
|
+
* );
|
|
117
416
|
*/
|
|
118
|
-
static INVARIANT_DEBUG(isOk: boolean, ngMsg?: string,
|
|
417
|
+
static INVARIANT_DEBUG(isOk: boolean, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
119
418
|
[x: string]: any;
|
|
120
419
|
}): boolean;
|
|
121
420
|
/**
|
|
122
|
-
*
|
|
421
|
+
* Core contract evaluation logic.
|
|
422
|
+
*
|
|
423
|
+
* Evaluates a condition and handles failures.
|
|
424
|
+
* All public contract methods delegate to this method.
|
|
425
|
+
*
|
|
426
|
+
* Behavior:
|
|
427
|
+
* - When the condition is true, returns the original value.
|
|
428
|
+
* - When the condition is false and ErrorClass is specified,
|
|
429
|
+
* throws an instance of the specified error class.
|
|
430
|
+
* - When ErrorClass is null,
|
|
431
|
+
* logs the failure message instead of throwing.
|
|
432
|
+
*
|
|
433
|
+
* @param {boolean} isOk
|
|
434
|
+
* Condition result.
|
|
435
|
+
*
|
|
436
|
+
* @param {string} prefix
|
|
437
|
+
* Contract type prefix used in the error message.
|
|
438
|
+
*
|
|
439
|
+
* @param {string|null} ngMsg
|
|
440
|
+
* Failure message.
|
|
441
|
+
*
|
|
442
|
+
* @param {(new (...args:any[])=>Error)|null} ErrorClass
|
|
443
|
+
* Error constructor.
|
|
444
|
+
*
|
|
445
|
+
* @param {Object<string, *>} eProps
|
|
446
|
+
* Additional properties assigned to the error object.
|
|
447
|
+
*
|
|
448
|
+
* @returns {boolean}
|
|
449
|
+
* Returns the original condition value.
|
|
450
|
+
*
|
|
123
451
|
*/
|
|
124
|
-
|
|
125
|
-
* Core evaluation logic.
|
|
126
|
-
* If the result is false and an `error` class is provided, throws an exception.
|
|
127
|
-
* Otherwise, logs the message to `console.error`.
|
|
128
|
-
* @param {boolean} isOk The result of the condition check.
|
|
129
|
-
* @param {string} [prefix] Prefix for the error message.
|
|
130
|
-
* @param {string} [ngMsg] The error message.
|
|
131
|
-
* @param {new (...args: any[]) => Error} [error] The error class to throw (Error or its subclass).
|
|
132
|
-
* @param {Object<string, *>} [eProps={}] Properties to assign to the error instance.
|
|
133
|
-
* @return {boolean} The evaluation result (returns `isOk` as is).
|
|
134
|
-
*/
|
|
135
|
-
static "__#1@#check"(isOk: boolean, prefix?: string, ngMsg?: string, error?: new (...args: any[]) => Error, eProps?: {
|
|
452
|
+
static "__#1@#check"(isOk: boolean, prefix?: string, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
136
453
|
[x: string]: any;
|
|
137
454
|
}): boolean;
|
|
138
455
|
/**
|
|
139
|
-
* Debug evaluation logic
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
456
|
+
* Debug-only contract evaluation logic.
|
|
457
|
+
*
|
|
458
|
+
* Executes contract validation only when DEBUG_MODE
|
|
459
|
+
* is enabled.
|
|
460
|
+
*
|
|
461
|
+
* When DEBUG_MODE is disabled,
|
|
462
|
+
* this method returns the original condition value
|
|
463
|
+
* without performing any validation.
|
|
464
|
+
*
|
|
465
|
+
* @param {boolean} isOk
|
|
466
|
+
* Condition result.
|
|
467
|
+
*
|
|
468
|
+
* @param {string} prefix
|
|
469
|
+
* Contract type prefix used in the error message.
|
|
470
|
+
*
|
|
471
|
+
* @param {string|null} ngMsg
|
|
472
|
+
* Failure message.
|
|
473
|
+
*
|
|
474
|
+
* @param {(new (...args:any[])=>Error)|null} ErrorClass
|
|
475
|
+
* Error constructor.
|
|
476
|
+
*
|
|
477
|
+
* @param {Object<string, *>} eProps
|
|
478
|
+
* Additional properties assigned to the error object.
|
|
479
|
+
*
|
|
480
|
+
* @returns {boolean}
|
|
481
|
+
* Returns the original condition value.
|
|
482
|
+
*
|
|
148
483
|
*/
|
|
149
|
-
static "__#1@#checkDebug"(isOk: boolean, prefix?: string, ngMsg?: string,
|
|
484
|
+
static "__#1@#checkDebug"(isOk: boolean, prefix?: string, ngMsg?: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eProps?: {
|
|
150
485
|
[x: string]: any;
|
|
151
486
|
}): boolean;
|
|
152
487
|
}
|