@ayapapa-npm/contracts-js 0.2.5 → 0.3.0
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/index.cjs +108 -38
- package/dist/index.d.cts +118 -32
- package/dist/index.d.ts +118 -32
- package/dist/index.js +108 -38
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -115,11 +115,12 @@ declare class Contracts {
|
|
|
115
115
|
* @param isOk
|
|
116
116
|
* Condition result to verify.
|
|
117
117
|
*
|
|
118
|
-
* @param
|
|
118
|
+
* @param ngMsg
|
|
119
119
|
* Failure message.
|
|
120
120
|
*
|
|
121
|
-
* @param
|
|
121
|
+
* @param ErrorClass
|
|
122
122
|
* Error constructor used when the check fails.
|
|
123
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
123
124
|
*
|
|
124
125
|
* Supported values:
|
|
125
126
|
* - `Error` (default)
|
|
@@ -128,7 +129,10 @@ declare class Contracts {
|
|
|
128
129
|
* - Custom Error subclasses
|
|
129
130
|
* - `null` to skip throwing and log the failure.
|
|
130
131
|
*
|
|
131
|
-
* @param
|
|
132
|
+
* @param eParams
|
|
133
|
+
* Parameter options following the message passed to the Error constructor.
|
|
134
|
+
*
|
|
135
|
+
* @param eProps
|
|
132
136
|
* Additional properties assigned to the error object.
|
|
133
137
|
*
|
|
134
138
|
* @returns
|
|
@@ -142,7 +146,11 @@ declare class Contracts {
|
|
|
142
146
|
* 'Calculation result must not be negative'
|
|
143
147
|
* );
|
|
144
148
|
*/
|
|
145
|
-
static VERIFY(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
149
|
+
static VERIFY(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
} | null, eProps?: {
|
|
152
|
+
[key: string]: any;
|
|
153
|
+
} | null): boolean;
|
|
146
154
|
/**
|
|
147
155
|
* Verifies an intermediate condition in debug mode only.
|
|
148
156
|
*
|
|
@@ -159,11 +167,12 @@ declare class Contracts {
|
|
|
159
167
|
* @param isOk
|
|
160
168
|
* Condition result to verify.
|
|
161
169
|
*
|
|
162
|
-
* @param
|
|
170
|
+
* @param ngMsg
|
|
163
171
|
* Failure message.
|
|
164
172
|
*
|
|
165
|
-
* @param
|
|
173
|
+
* @param ErrorClass
|
|
166
174
|
* Error constructor used when the check fails.
|
|
175
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
167
176
|
*
|
|
168
177
|
* Supported values:
|
|
169
178
|
* - `Error` (default)
|
|
@@ -172,7 +181,10 @@ declare class Contracts {
|
|
|
172
181
|
* - Custom Error subclasses
|
|
173
182
|
* - `null` to skip throwing and log the failure.
|
|
174
183
|
*
|
|
175
|
-
* @param
|
|
184
|
+
* @param eParams
|
|
185
|
+
* Parameter options following the message passed to the Error constructor.
|
|
186
|
+
*
|
|
187
|
+
* @param eProps
|
|
176
188
|
* Additional properties assigned to the error object.
|
|
177
189
|
*
|
|
178
190
|
* @returns
|
|
@@ -184,7 +196,11 @@ declare class Contracts {
|
|
|
184
196
|
* 'Intermediate value must not be null'
|
|
185
197
|
* );
|
|
186
198
|
*/
|
|
187
|
-
static VERIFY_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
199
|
+
static VERIFY_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
200
|
+
[key: string]: any;
|
|
201
|
+
} | null, eProps?: {
|
|
202
|
+
[key: string]: any;
|
|
203
|
+
} | null): boolean;
|
|
188
204
|
/**
|
|
189
205
|
* Checks a precondition before execution.
|
|
190
206
|
*
|
|
@@ -201,11 +217,12 @@ declare class Contracts {
|
|
|
201
217
|
* @param isOk
|
|
202
218
|
* Condition result to verify.
|
|
203
219
|
*
|
|
204
|
-
* @param
|
|
220
|
+
* @param ngMsg
|
|
205
221
|
* Failure message.
|
|
206
222
|
*
|
|
207
|
-
* @param
|
|
223
|
+
* @param ErrorClass
|
|
208
224
|
* Error constructor used when the check fails.
|
|
225
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
209
226
|
*
|
|
210
227
|
* Supported values:
|
|
211
228
|
* - `Error` (default)
|
|
@@ -214,7 +231,10 @@ declare class Contracts {
|
|
|
214
231
|
* - Custom Error subclasses
|
|
215
232
|
* - `null` to skip throwing and log the failure.
|
|
216
233
|
*
|
|
217
|
-
* @param
|
|
234
|
+
* @param eParams
|
|
235
|
+
* Parameter options following the message passed to the Error constructor.
|
|
236
|
+
*
|
|
237
|
+
* @param eProps
|
|
218
238
|
* Additional properties assigned to the error object.
|
|
219
239
|
*
|
|
220
240
|
* @returns
|
|
@@ -235,7 +255,11 @@ declare class Contracts {
|
|
|
235
255
|
* return a / b;
|
|
236
256
|
* }
|
|
237
257
|
*/
|
|
238
|
-
static REQUIRE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
258
|
+
static REQUIRE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
259
|
+
[key: string]: any;
|
|
260
|
+
} | null, eProps?: {
|
|
261
|
+
[key: string]: any;
|
|
262
|
+
} | null): boolean;
|
|
239
263
|
/**
|
|
240
264
|
* Checks a precondition in debug mode only.
|
|
241
265
|
*
|
|
@@ -252,11 +276,12 @@ declare class Contracts {
|
|
|
252
276
|
* @param isOk
|
|
253
277
|
* Condition result to verify.
|
|
254
278
|
*
|
|
255
|
-
* @param
|
|
279
|
+
* @param ngMsg
|
|
256
280
|
* Failure message.
|
|
257
281
|
*
|
|
258
|
-
* @param
|
|
282
|
+
* @param ErrorClass
|
|
259
283
|
* Error constructor used when the check fails.
|
|
284
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
260
285
|
*
|
|
261
286
|
* Supported values:
|
|
262
287
|
* - `Error` (default)
|
|
@@ -265,7 +290,10 @@ declare class Contracts {
|
|
|
265
290
|
* - Custom Error subclasses
|
|
266
291
|
* - `null` to skip throwing and log the failure.
|
|
267
292
|
*
|
|
268
|
-
* @param
|
|
293
|
+
* @param eParams
|
|
294
|
+
* Parameter options following the message passed to the Error constructor.
|
|
295
|
+
*
|
|
296
|
+
* @param eProps
|
|
269
297
|
* Additional properties assigned to the error object.
|
|
270
298
|
*
|
|
271
299
|
* @returns
|
|
@@ -277,7 +305,11 @@ declare class Contracts {
|
|
|
277
305
|
* 'User must exist during debugging'
|
|
278
306
|
* );
|
|
279
307
|
*/
|
|
280
|
-
static REQUIRE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
308
|
+
static REQUIRE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
309
|
+
[key: string]: any;
|
|
310
|
+
} | null, eProps?: {
|
|
311
|
+
[key: string]: any;
|
|
312
|
+
} | null): boolean;
|
|
281
313
|
/**
|
|
282
314
|
* Checks a postcondition after execution.
|
|
283
315
|
*
|
|
@@ -295,11 +327,12 @@ declare class Contracts {
|
|
|
295
327
|
* @param isOk
|
|
296
328
|
* Condition result to verify.
|
|
297
329
|
*
|
|
298
|
-
* @param
|
|
330
|
+
* @param ngMsg
|
|
299
331
|
* Failure message.
|
|
300
332
|
*
|
|
301
|
-
* @param
|
|
333
|
+
* @param ErrorClass
|
|
302
334
|
* Error constructor used when the check fails.
|
|
335
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
303
336
|
*
|
|
304
337
|
* Supported values:
|
|
305
338
|
* - `Error` (default)
|
|
@@ -308,7 +341,10 @@ declare class Contracts {
|
|
|
308
341
|
* - Custom Error subclasses
|
|
309
342
|
* - `null` to skip throwing and log the failure.
|
|
310
343
|
*
|
|
311
|
-
* @param
|
|
344
|
+
* @param eParams
|
|
345
|
+
* Parameter options following the message passed to the Error constructor.
|
|
346
|
+
*
|
|
347
|
+
* @param eProps
|
|
312
348
|
* Additional properties assigned to the error object.
|
|
313
349
|
*
|
|
314
350
|
* @returns
|
|
@@ -331,7 +367,11 @@ declare class Contracts {
|
|
|
331
367
|
* return result;
|
|
332
368
|
* }
|
|
333
369
|
*/
|
|
334
|
-
static ENSURE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
370
|
+
static ENSURE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
371
|
+
[key: string]: any;
|
|
372
|
+
} | null, eProps?: {
|
|
373
|
+
[key: string]: any;
|
|
374
|
+
} | null): boolean;
|
|
335
375
|
/**
|
|
336
376
|
* Checks a postcondition in debug mode only.
|
|
337
377
|
*
|
|
@@ -348,11 +388,12 @@ declare class Contracts {
|
|
|
348
388
|
* @param isOk
|
|
349
389
|
* Condition result to verify.
|
|
350
390
|
*
|
|
351
|
-
* @param
|
|
391
|
+
* @param ngMsg
|
|
352
392
|
* Failure message.
|
|
353
393
|
*
|
|
354
|
-
* @param
|
|
394
|
+
* @param ErrorClass
|
|
355
395
|
* Error constructor used when the check fails.
|
|
396
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
356
397
|
*
|
|
357
398
|
* Supported values:
|
|
358
399
|
* - `Error` (default)
|
|
@@ -361,7 +402,10 @@ declare class Contracts {
|
|
|
361
402
|
* - Custom Error subclasses
|
|
362
403
|
* - `null` to skip throwing and log the failure.
|
|
363
404
|
*
|
|
364
|
-
* @param
|
|
405
|
+
* @param eParams
|
|
406
|
+
* Parameter options following the message passed to the Error constructor.
|
|
407
|
+
*
|
|
408
|
+
* @param eProps
|
|
365
409
|
* Additional properties assigned to the error object.
|
|
366
410
|
*
|
|
367
411
|
* @returns
|
|
@@ -373,7 +417,11 @@ declare class Contracts {
|
|
|
373
417
|
* 'Result should exist during debugging'
|
|
374
418
|
* );
|
|
375
419
|
*/
|
|
376
|
-
static ENSURE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
420
|
+
static ENSURE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
421
|
+
[key: string]: any;
|
|
422
|
+
} | null, eProps?: {
|
|
423
|
+
[key: string]: any;
|
|
424
|
+
} | null): boolean;
|
|
377
425
|
/**
|
|
378
426
|
* Checks an invariant condition.
|
|
379
427
|
*
|
|
@@ -391,11 +439,12 @@ declare class Contracts {
|
|
|
391
439
|
* @param isOk
|
|
392
440
|
* Condition result to verify.
|
|
393
441
|
*
|
|
394
|
-
* @param
|
|
442
|
+
* @param ngMsg
|
|
395
443
|
* Failure message.
|
|
396
444
|
*
|
|
397
|
-
* @param
|
|
445
|
+
* @param ErrorClass
|
|
398
446
|
* Error constructor used when the check fails.
|
|
447
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
399
448
|
*
|
|
400
449
|
* Supported values:
|
|
401
450
|
* - `Error` (default)
|
|
@@ -404,7 +453,10 @@ declare class Contracts {
|
|
|
404
453
|
* - Custom Error subclasses
|
|
405
454
|
* - `null` to skip throwing and log the failure.
|
|
406
455
|
*
|
|
407
|
-
* @param
|
|
456
|
+
* @param eParams
|
|
457
|
+
* Parameter options following the message passed to the Error constructor.
|
|
458
|
+
*
|
|
459
|
+
* @param eProps
|
|
408
460
|
* Additional properties assigned to the error object.
|
|
409
461
|
*
|
|
410
462
|
* @returns
|
|
@@ -424,7 +476,11 @@ declare class Contracts {
|
|
|
424
476
|
*
|
|
425
477
|
* }
|
|
426
478
|
*/
|
|
427
|
-
static INVARIANT(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
479
|
+
static INVARIANT(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
480
|
+
[key: string]: any;
|
|
481
|
+
} | null, eProps?: {
|
|
482
|
+
[key: string]: any;
|
|
483
|
+
} | null): boolean;
|
|
428
484
|
/**
|
|
429
485
|
* Checks an invariant condition in debug mode only.
|
|
430
486
|
*
|
|
@@ -446,6 +502,7 @@ declare class Contracts {
|
|
|
446
502
|
*
|
|
447
503
|
* @param [ErrorClass=Error]
|
|
448
504
|
* Error constructor used when the check fails.
|
|
505
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
449
506
|
*
|
|
450
507
|
* Supported values:
|
|
451
508
|
* - `Error` (default)
|
|
@@ -454,6 +511,9 @@ declare class Contracts {
|
|
|
454
511
|
* - Custom Error subclasses
|
|
455
512
|
* - `null` to skip throwing and log the failure.
|
|
456
513
|
*
|
|
514
|
+
* @param eParams
|
|
515
|
+
* Parameter options following the message passed to the Error constructor.
|
|
516
|
+
*
|
|
457
517
|
* @param [eProps = {}]
|
|
458
518
|
* Additional properties assigned to the error object.
|
|
459
519
|
*
|
|
@@ -466,7 +526,11 @@ declare class Contracts {
|
|
|
466
526
|
* 'Cache size exceeded expected limit'
|
|
467
527
|
* );
|
|
468
528
|
*/
|
|
469
|
-
static INVARIANT_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
529
|
+
static INVARIANT_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
530
|
+
[key: string]: any;
|
|
531
|
+
} | null, eProps?: {
|
|
532
|
+
[key: string]: any;
|
|
533
|
+
} | null): boolean;
|
|
470
534
|
/**
|
|
471
535
|
* Core contract evaluation logic.
|
|
472
536
|
*
|
|
@@ -493,7 +557,18 @@ declare class Contracts {
|
|
|
493
557
|
* Failure message.
|
|
494
558
|
*
|
|
495
559
|
* @param ErrorClass
|
|
496
|
-
* Error constructor.
|
|
560
|
+
* Error constructor used when the check fails.
|
|
561
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
562
|
+
*
|
|
563
|
+
* Supported values:
|
|
564
|
+
* - `Error` (default)
|
|
565
|
+
* - `TypeError`
|
|
566
|
+
* - `RangeError`
|
|
567
|
+
* - Custom Error subclasses
|
|
568
|
+
* - `null` to skip throwing and log the failure.
|
|
569
|
+
*
|
|
570
|
+
* @param eParams
|
|
571
|
+
* Parameter options following the message passed to the Error constructor.
|
|
497
572
|
*
|
|
498
573
|
* @param eProps
|
|
499
574
|
* Additional properties assigned to the error object.
|
|
@@ -524,8 +599,19 @@ declare class Contracts {
|
|
|
524
599
|
* @param ngMsg
|
|
525
600
|
* Failure message.
|
|
526
601
|
*
|
|
527
|
-
* @param ErrorClass
|
|
528
|
-
* Error constructor.
|
|
602
|
+
* @param ErrorClass=Error
|
|
603
|
+
* Error constructor used when the check fails.
|
|
604
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
605
|
+
*
|
|
606
|
+
* Supported values:
|
|
607
|
+
* - `Error` (default)
|
|
608
|
+
* - `TypeError`
|
|
609
|
+
* - `RangeError`
|
|
610
|
+
* - Custom Error subclasses
|
|
611
|
+
* - `null` to skip throwing and log the failure.
|
|
612
|
+
*
|
|
613
|
+
* @param eParams
|
|
614
|
+
* Parameter options following the message passed to the Error constructor.
|
|
529
615
|
*
|
|
530
616
|
* @param eProps
|
|
531
617
|
* Additional properties assigned to the error object.
|
package/dist/index.d.ts
CHANGED
|
@@ -115,11 +115,12 @@ declare class Contracts {
|
|
|
115
115
|
* @param isOk
|
|
116
116
|
* Condition result to verify.
|
|
117
117
|
*
|
|
118
|
-
* @param
|
|
118
|
+
* @param ngMsg
|
|
119
119
|
* Failure message.
|
|
120
120
|
*
|
|
121
|
-
* @param
|
|
121
|
+
* @param ErrorClass
|
|
122
122
|
* Error constructor used when the check fails.
|
|
123
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
123
124
|
*
|
|
124
125
|
* Supported values:
|
|
125
126
|
* - `Error` (default)
|
|
@@ -128,7 +129,10 @@ declare class Contracts {
|
|
|
128
129
|
* - Custom Error subclasses
|
|
129
130
|
* - `null` to skip throwing and log the failure.
|
|
130
131
|
*
|
|
131
|
-
* @param
|
|
132
|
+
* @param eParams
|
|
133
|
+
* Parameter options following the message passed to the Error constructor.
|
|
134
|
+
*
|
|
135
|
+
* @param eProps
|
|
132
136
|
* Additional properties assigned to the error object.
|
|
133
137
|
*
|
|
134
138
|
* @returns
|
|
@@ -142,7 +146,11 @@ declare class Contracts {
|
|
|
142
146
|
* 'Calculation result must not be negative'
|
|
143
147
|
* );
|
|
144
148
|
*/
|
|
145
|
-
static VERIFY(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
149
|
+
static VERIFY(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
} | null, eProps?: {
|
|
152
|
+
[key: string]: any;
|
|
153
|
+
} | null): boolean;
|
|
146
154
|
/**
|
|
147
155
|
* Verifies an intermediate condition in debug mode only.
|
|
148
156
|
*
|
|
@@ -159,11 +167,12 @@ declare class Contracts {
|
|
|
159
167
|
* @param isOk
|
|
160
168
|
* Condition result to verify.
|
|
161
169
|
*
|
|
162
|
-
* @param
|
|
170
|
+
* @param ngMsg
|
|
163
171
|
* Failure message.
|
|
164
172
|
*
|
|
165
|
-
* @param
|
|
173
|
+
* @param ErrorClass
|
|
166
174
|
* Error constructor used when the check fails.
|
|
175
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
167
176
|
*
|
|
168
177
|
* Supported values:
|
|
169
178
|
* - `Error` (default)
|
|
@@ -172,7 +181,10 @@ declare class Contracts {
|
|
|
172
181
|
* - Custom Error subclasses
|
|
173
182
|
* - `null` to skip throwing and log the failure.
|
|
174
183
|
*
|
|
175
|
-
* @param
|
|
184
|
+
* @param eParams
|
|
185
|
+
* Parameter options following the message passed to the Error constructor.
|
|
186
|
+
*
|
|
187
|
+
* @param eProps
|
|
176
188
|
* Additional properties assigned to the error object.
|
|
177
189
|
*
|
|
178
190
|
* @returns
|
|
@@ -184,7 +196,11 @@ declare class Contracts {
|
|
|
184
196
|
* 'Intermediate value must not be null'
|
|
185
197
|
* );
|
|
186
198
|
*/
|
|
187
|
-
static VERIFY_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
199
|
+
static VERIFY_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
200
|
+
[key: string]: any;
|
|
201
|
+
} | null, eProps?: {
|
|
202
|
+
[key: string]: any;
|
|
203
|
+
} | null): boolean;
|
|
188
204
|
/**
|
|
189
205
|
* Checks a precondition before execution.
|
|
190
206
|
*
|
|
@@ -201,11 +217,12 @@ declare class Contracts {
|
|
|
201
217
|
* @param isOk
|
|
202
218
|
* Condition result to verify.
|
|
203
219
|
*
|
|
204
|
-
* @param
|
|
220
|
+
* @param ngMsg
|
|
205
221
|
* Failure message.
|
|
206
222
|
*
|
|
207
|
-
* @param
|
|
223
|
+
* @param ErrorClass
|
|
208
224
|
* Error constructor used when the check fails.
|
|
225
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
209
226
|
*
|
|
210
227
|
* Supported values:
|
|
211
228
|
* - `Error` (default)
|
|
@@ -214,7 +231,10 @@ declare class Contracts {
|
|
|
214
231
|
* - Custom Error subclasses
|
|
215
232
|
* - `null` to skip throwing and log the failure.
|
|
216
233
|
*
|
|
217
|
-
* @param
|
|
234
|
+
* @param eParams
|
|
235
|
+
* Parameter options following the message passed to the Error constructor.
|
|
236
|
+
*
|
|
237
|
+
* @param eProps
|
|
218
238
|
* Additional properties assigned to the error object.
|
|
219
239
|
*
|
|
220
240
|
* @returns
|
|
@@ -235,7 +255,11 @@ declare class Contracts {
|
|
|
235
255
|
* return a / b;
|
|
236
256
|
* }
|
|
237
257
|
*/
|
|
238
|
-
static REQUIRE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
258
|
+
static REQUIRE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
259
|
+
[key: string]: any;
|
|
260
|
+
} | null, eProps?: {
|
|
261
|
+
[key: string]: any;
|
|
262
|
+
} | null): boolean;
|
|
239
263
|
/**
|
|
240
264
|
* Checks a precondition in debug mode only.
|
|
241
265
|
*
|
|
@@ -252,11 +276,12 @@ declare class Contracts {
|
|
|
252
276
|
* @param isOk
|
|
253
277
|
* Condition result to verify.
|
|
254
278
|
*
|
|
255
|
-
* @param
|
|
279
|
+
* @param ngMsg
|
|
256
280
|
* Failure message.
|
|
257
281
|
*
|
|
258
|
-
* @param
|
|
282
|
+
* @param ErrorClass
|
|
259
283
|
* Error constructor used when the check fails.
|
|
284
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
260
285
|
*
|
|
261
286
|
* Supported values:
|
|
262
287
|
* - `Error` (default)
|
|
@@ -265,7 +290,10 @@ declare class Contracts {
|
|
|
265
290
|
* - Custom Error subclasses
|
|
266
291
|
* - `null` to skip throwing and log the failure.
|
|
267
292
|
*
|
|
268
|
-
* @param
|
|
293
|
+
* @param eParams
|
|
294
|
+
* Parameter options following the message passed to the Error constructor.
|
|
295
|
+
*
|
|
296
|
+
* @param eProps
|
|
269
297
|
* Additional properties assigned to the error object.
|
|
270
298
|
*
|
|
271
299
|
* @returns
|
|
@@ -277,7 +305,11 @@ declare class Contracts {
|
|
|
277
305
|
* 'User must exist during debugging'
|
|
278
306
|
* );
|
|
279
307
|
*/
|
|
280
|
-
static REQUIRE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
308
|
+
static REQUIRE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
309
|
+
[key: string]: any;
|
|
310
|
+
} | null, eProps?: {
|
|
311
|
+
[key: string]: any;
|
|
312
|
+
} | null): boolean;
|
|
281
313
|
/**
|
|
282
314
|
* Checks a postcondition after execution.
|
|
283
315
|
*
|
|
@@ -295,11 +327,12 @@ declare class Contracts {
|
|
|
295
327
|
* @param isOk
|
|
296
328
|
* Condition result to verify.
|
|
297
329
|
*
|
|
298
|
-
* @param
|
|
330
|
+
* @param ngMsg
|
|
299
331
|
* Failure message.
|
|
300
332
|
*
|
|
301
|
-
* @param
|
|
333
|
+
* @param ErrorClass
|
|
302
334
|
* Error constructor used when the check fails.
|
|
335
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
303
336
|
*
|
|
304
337
|
* Supported values:
|
|
305
338
|
* - `Error` (default)
|
|
@@ -308,7 +341,10 @@ declare class Contracts {
|
|
|
308
341
|
* - Custom Error subclasses
|
|
309
342
|
* - `null` to skip throwing and log the failure.
|
|
310
343
|
*
|
|
311
|
-
* @param
|
|
344
|
+
* @param eParams
|
|
345
|
+
* Parameter options following the message passed to the Error constructor.
|
|
346
|
+
*
|
|
347
|
+
* @param eProps
|
|
312
348
|
* Additional properties assigned to the error object.
|
|
313
349
|
*
|
|
314
350
|
* @returns
|
|
@@ -331,7 +367,11 @@ declare class Contracts {
|
|
|
331
367
|
* return result;
|
|
332
368
|
* }
|
|
333
369
|
*/
|
|
334
|
-
static ENSURE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
370
|
+
static ENSURE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
371
|
+
[key: string]: any;
|
|
372
|
+
} | null, eProps?: {
|
|
373
|
+
[key: string]: any;
|
|
374
|
+
} | null): boolean;
|
|
335
375
|
/**
|
|
336
376
|
* Checks a postcondition in debug mode only.
|
|
337
377
|
*
|
|
@@ -348,11 +388,12 @@ declare class Contracts {
|
|
|
348
388
|
* @param isOk
|
|
349
389
|
* Condition result to verify.
|
|
350
390
|
*
|
|
351
|
-
* @param
|
|
391
|
+
* @param ngMsg
|
|
352
392
|
* Failure message.
|
|
353
393
|
*
|
|
354
|
-
* @param
|
|
394
|
+
* @param ErrorClass
|
|
355
395
|
* Error constructor used when the check fails.
|
|
396
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
356
397
|
*
|
|
357
398
|
* Supported values:
|
|
358
399
|
* - `Error` (default)
|
|
@@ -361,7 +402,10 @@ declare class Contracts {
|
|
|
361
402
|
* - Custom Error subclasses
|
|
362
403
|
* - `null` to skip throwing and log the failure.
|
|
363
404
|
*
|
|
364
|
-
* @param
|
|
405
|
+
* @param eParams
|
|
406
|
+
* Parameter options following the message passed to the Error constructor.
|
|
407
|
+
*
|
|
408
|
+
* @param eProps
|
|
365
409
|
* Additional properties assigned to the error object.
|
|
366
410
|
*
|
|
367
411
|
* @returns
|
|
@@ -373,7 +417,11 @@ declare class Contracts {
|
|
|
373
417
|
* 'Result should exist during debugging'
|
|
374
418
|
* );
|
|
375
419
|
*/
|
|
376
|
-
static ENSURE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
420
|
+
static ENSURE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
421
|
+
[key: string]: any;
|
|
422
|
+
} | null, eProps?: {
|
|
423
|
+
[key: string]: any;
|
|
424
|
+
} | null): boolean;
|
|
377
425
|
/**
|
|
378
426
|
* Checks an invariant condition.
|
|
379
427
|
*
|
|
@@ -391,11 +439,12 @@ declare class Contracts {
|
|
|
391
439
|
* @param isOk
|
|
392
440
|
* Condition result to verify.
|
|
393
441
|
*
|
|
394
|
-
* @param
|
|
442
|
+
* @param ngMsg
|
|
395
443
|
* Failure message.
|
|
396
444
|
*
|
|
397
|
-
* @param
|
|
445
|
+
* @param ErrorClass
|
|
398
446
|
* Error constructor used when the check fails.
|
|
447
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
399
448
|
*
|
|
400
449
|
* Supported values:
|
|
401
450
|
* - `Error` (default)
|
|
@@ -404,7 +453,10 @@ declare class Contracts {
|
|
|
404
453
|
* - Custom Error subclasses
|
|
405
454
|
* - `null` to skip throwing and log the failure.
|
|
406
455
|
*
|
|
407
|
-
* @param
|
|
456
|
+
* @param eParams
|
|
457
|
+
* Parameter options following the message passed to the Error constructor.
|
|
458
|
+
*
|
|
459
|
+
* @param eProps
|
|
408
460
|
* Additional properties assigned to the error object.
|
|
409
461
|
*
|
|
410
462
|
* @returns
|
|
@@ -424,7 +476,11 @@ declare class Contracts {
|
|
|
424
476
|
*
|
|
425
477
|
* }
|
|
426
478
|
*/
|
|
427
|
-
static INVARIANT(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
479
|
+
static INVARIANT(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
480
|
+
[key: string]: any;
|
|
481
|
+
} | null, eProps?: {
|
|
482
|
+
[key: string]: any;
|
|
483
|
+
} | null): boolean;
|
|
428
484
|
/**
|
|
429
485
|
* Checks an invariant condition in debug mode only.
|
|
430
486
|
*
|
|
@@ -446,6 +502,7 @@ declare class Contracts {
|
|
|
446
502
|
*
|
|
447
503
|
* @param [ErrorClass=Error]
|
|
448
504
|
* Error constructor used when the check fails.
|
|
505
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
449
506
|
*
|
|
450
507
|
* Supported values:
|
|
451
508
|
* - `Error` (default)
|
|
@@ -454,6 +511,9 @@ declare class Contracts {
|
|
|
454
511
|
* - Custom Error subclasses
|
|
455
512
|
* - `null` to skip throwing and log the failure.
|
|
456
513
|
*
|
|
514
|
+
* @param eParams
|
|
515
|
+
* Parameter options following the message passed to the Error constructor.
|
|
516
|
+
*
|
|
457
517
|
* @param [eProps = {}]
|
|
458
518
|
* Additional properties assigned to the error object.
|
|
459
519
|
*
|
|
@@ -466,7 +526,11 @@ declare class Contracts {
|
|
|
466
526
|
* 'Cache size exceeded expected limit'
|
|
467
527
|
* );
|
|
468
528
|
*/
|
|
469
|
-
static INVARIANT_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null,
|
|
529
|
+
static INVARIANT_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
|
|
530
|
+
[key: string]: any;
|
|
531
|
+
} | null, eProps?: {
|
|
532
|
+
[key: string]: any;
|
|
533
|
+
} | null): boolean;
|
|
470
534
|
/**
|
|
471
535
|
* Core contract evaluation logic.
|
|
472
536
|
*
|
|
@@ -493,7 +557,18 @@ declare class Contracts {
|
|
|
493
557
|
* Failure message.
|
|
494
558
|
*
|
|
495
559
|
* @param ErrorClass
|
|
496
|
-
* Error constructor.
|
|
560
|
+
* Error constructor used when the check fails.
|
|
561
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
562
|
+
*
|
|
563
|
+
* Supported values:
|
|
564
|
+
* - `Error` (default)
|
|
565
|
+
* - `TypeError`
|
|
566
|
+
* - `RangeError`
|
|
567
|
+
* - Custom Error subclasses
|
|
568
|
+
* - `null` to skip throwing and log the failure.
|
|
569
|
+
*
|
|
570
|
+
* @param eParams
|
|
571
|
+
* Parameter options following the message passed to the Error constructor.
|
|
497
572
|
*
|
|
498
573
|
* @param eProps
|
|
499
574
|
* Additional properties assigned to the error object.
|
|
@@ -524,8 +599,19 @@ declare class Contracts {
|
|
|
524
599
|
* @param ngMsg
|
|
525
600
|
* Failure message.
|
|
526
601
|
*
|
|
527
|
-
* @param ErrorClass
|
|
528
|
-
* Error constructor.
|
|
602
|
+
* @param ErrorClass=Error
|
|
603
|
+
* Error constructor used when the check fails.
|
|
604
|
+
* This is used as follows: throw Object.assign(new ErrorClass(msg, eParams), eProps);
|
|
605
|
+
*
|
|
606
|
+
* Supported values:
|
|
607
|
+
* - `Error` (default)
|
|
608
|
+
* - `TypeError`
|
|
609
|
+
* - `RangeError`
|
|
610
|
+
* - Custom Error subclasses
|
|
611
|
+
* - `null` to skip throwing and log the failure.
|
|
612
|
+
*
|
|
613
|
+
* @param eParams
|
|
614
|
+
* Parameter options following the message passed to the Error constructor.
|
|
529
615
|
*
|
|
530
616
|
* @param eProps
|
|
531
617
|
* Additional properties assigned to the error object.
|