@ayapapa-npm/contracts-js 0.4.2 → 0.4.3

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 CHANGED
@@ -5,11 +5,18 @@
5
5
  ![Lines](https://raw.githubusercontent.com/ayapapa/contracts-js/main/badges/coverage-lines.svg)
6
6
  ![Statements](https://raw.githubusercontent.com/ayapapa/contracts-js/main/badges/coverage-statements.svg)
7
7
 
8
+ ## Table of contents
9
+ [Overview](#overview) | [API Reference](#api-reference) | [Installation](#installation) | [Contract Types](#contract-types) | [Usage](#usage)
10
+
8
11
  # contracts-js
12
+ ## Overview
9
13
  A lightweight Design by Contract library for JavaScript.</br>
10
14
  Provides runtime contract checks based on Design by Contract principles.</br>
11
15
  All check functions return the evaluated condition itself, so they can be used directly in control flow when exception throwing is suppressed.
12
16
 
17
+ ## API Reference
18
+ [API document](https://github.com/ayapapa/contracts-js/blob/main/docs/api.md)<br>
19
+ Implementation examples are also included.
13
20
 
14
21
  ## Installation
15
22
 
@@ -132,9 +139,6 @@ Contracts.INVARIANT(
132
139
  );
133
140
  ```
134
141
 
135
- ## API Reference
136
- [API document](https://raw.githubusercontent.com/ayapapa/contracts-js/main/docs/api.md)
137
-
138
142
  ## Usage
139
143
 
140
144
  ```javascript
package/dist/index.cjs CHANGED
@@ -43,8 +43,6 @@ var Contracts = class _Contracts {
43
43
  };
44
44
  /** Current config. */
45
45
  static #config = { ..._Contracts.#defaultConf };
46
- /** logger */
47
- //private static logger: LogProvider = console;
48
46
  /**
49
47
  * Configures contract checking behavior.
50
48
  *
@@ -65,7 +63,7 @@ var Contracts = class _Contracts {
65
63
  * it is used instead of the standard logger, `console`.
66
64
  * This module uses only the `error` method of the `logger`. <br>
67
65
  * <br>
68
- * Note: If the value of a property is `undefined`, it is treated as unspecified.
66
+ * Note: If the value of a property is `undefined` or `null`, it is treated as unspecified.
69
67
  *
70
68
  * @param reset
71
69
  * If `true`, unspecified values ​​are saved to the settings as default values. <br>
@@ -175,9 +173,9 @@ var Contracts = class _Contracts {
175
173
  * Verifies an intermediate condition in debug mode only.
176
174
  *
177
175
  * Performs the same validation as VERIFY only when
178
- * DEBUG_MODE is enabled.
176
+ * `debug_mode`(internal state) is enabled.
179
177
  *
180
- * When DEBUG_MODE is disabled,
178
+ * When `debug_mode`(internal state) is disabled,
181
179
  * no validation is performed.
182
180
  *
183
181
  * Typical usage:
@@ -294,9 +292,9 @@ var Contracts = class _Contracts {
294
292
  * Checks a precondition in debug mode only.
295
293
  *
296
294
  * Performs the same validation as REQUIRE only when
297
- * DEBUG_MODE is enabled.
295
+ * `debug_mode`(internal state) is enabled.
298
296
  *
299
- * When DEBUG_MODE is disabled,
297
+ * When `debug_mode`(internal state) is disabled,
300
298
  * no validation is performed.
301
299
  *
302
300
  * Typical usage:
@@ -416,9 +414,9 @@ var Contracts = class _Contracts {
416
414
  * Checks a postcondition in debug mode only.
417
415
  *
418
416
  * Performs the same validation as ENSURE only when
419
- * DEBUG_MODE is enabled.
417
+ * `debug_mode`(internal state) is enabled.
420
418
  *
421
- * When DEBUG_MODE is disabled,
419
+ * When `debug_mode`(internal state) is disabled,
422
420
  * no validation is performed.
423
421
  *
424
422
  * Typical usage:
@@ -535,9 +533,9 @@ var Contracts = class _Contracts {
535
533
  * Checks an invariant condition in debug mode only.
536
534
  *
537
535
  * Performs the same validation as INVARIANT only when
538
- * DEBUG_MODE is enabled.
536
+ * `debug_mode`(internal state) is enabled.
539
537
  *
540
- * When DEBUG_MODE is disabled,
538
+ * When `debug_mode`(internal state) is disabled,
541
539
  * no validation is performed.
542
540
  *
543
541
  * Typical usage:
@@ -635,9 +633,6 @@ var Contracts = class _Contracts {
635
633
  static check(isOk, prefix = "CHECK", ngMsg = "", ErrorClass = Error, eParams, eProps) {
636
634
  if (eProps === void 0) {
637
635
  eProps = eParams ?? {};
638
- eParams = null;
639
- } else {
640
- eProps ??= {};
641
636
  }
642
637
  if (!isOk) {
643
638
  const msg = `[${prefix}] ${ngMsg ?? ""}`;
@@ -647,7 +642,7 @@ var Contracts = class _Contracts {
647
642
  throw err;
648
643
  }
649
644
  if (ngMsg) {
650
- _Contracts.getLogger().error(msg, eProps);
645
+ _Contracts.#getLogger().error(msg, eProps);
651
646
  }
652
647
  }
653
648
  return isOk;
@@ -655,10 +650,9 @@ var Contracts = class _Contracts {
655
650
  /**
656
651
  * Debug-only contract evaluation logic.
657
652
  *
658
- * Executes contract validation only when DEBUG_MODE
659
- * is enabled.
653
+ * Executes contract validation only when `debug_mode`(internal state) is enabled.
660
654
  *
661
- * When DEBUG_MODE is disabled,
655
+ * When `debug_mode`(internal state) is disabled,
662
656
  * this method returns the original condition value
663
657
  * without performing any validation.
664
658
  *
@@ -705,11 +699,10 @@ var Contracts = class _Contracts {
705
699
  ) : isOk;
706
700
  }
707
701
  /**
708
- * Get logger
709
- *
710
702
  * @internal
703
+ * Get logger
711
704
  */
712
- static getLogger() {
705
+ static #getLogger() {
713
706
  return _Contracts.#config.logger;
714
707
  }
715
708
  };
package/dist/index.d.cts CHANGED
@@ -8,7 +8,7 @@ type LogProvider = Pick<Console, 'error'>;
8
8
  interface Config {
9
9
  /**
10
10
  * Debug mode state.
11
- * If `true`, `DEBUG_MODE` is enabled; otherwise, it is disabled.
11
+ * If `true`, `debug_mode`(internal state) is enabled; otherwise, it is disabled.
12
12
  * The default is `false`.
13
13
  */
14
14
  debug?: boolean;
@@ -49,9 +49,9 @@ type ConfigKey = keyof Config;
49
49
  * ## Debug Mode
50
50
  *
51
51
  * Methods ending with `_DEBUG` execute contract checks only
52
- * when `DEBUG_MODE` is enabled.
52
+ * when `debug_mode`(internal state) is enabled.
53
53
  *
54
- * When `DEBUG_MODE` is disabled,
54
+ * When `debug_mode`(internal state) is disabled,
55
55
  * these methods return the original condition value
56
56
  * without performing validation.
57
57
  *
@@ -68,7 +68,6 @@ declare class Contracts {
68
68
  * Please use `setConfig()` to change the debug mode.**
69
69
  */
70
70
  static DEBUG_MODE: boolean;
71
- /** logger */
72
71
  /**
73
72
  * Configures contract checking behavior.
74
73
  *
@@ -89,7 +88,7 @@ declare class Contracts {
89
88
  * it is used instead of the standard logger, `console`.
90
89
  * This module uses only the `error` method of the `logger`. <br>
91
90
  * <br>
92
- * Note: If the value of a property is `undefined`, it is treated as unspecified.
91
+ * Note: If the value of a property is `undefined` or `null`, it is treated as unspecified.
93
92
  *
94
93
  * @param reset
95
94
  * If `true`, unspecified values ​​are saved to the settings as default values. <br>
@@ -170,18 +169,14 @@ declare class Contracts {
170
169
  * 'Calculation result must not be negative'
171
170
  * );
172
171
  */
173
- static VERIFY(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
174
- [key: string]: any;
175
- } | null, eProps?: {
176
- [key: string]: any;
177
- } | null): boolean;
172
+ static VERIFY(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
178
173
  /**
179
174
  * Verifies an intermediate condition in debug mode only.
180
175
  *
181
176
  * Performs the same validation as VERIFY only when
182
- * DEBUG_MODE is enabled.
177
+ * `debug_mode`(internal state) is enabled.
183
178
  *
184
- * When DEBUG_MODE is disabled,
179
+ * When `debug_mode`(internal state) is disabled,
185
180
  * no validation is performed.
186
181
  *
187
182
  * Typical usage:
@@ -220,11 +215,7 @@ declare class Contracts {
220
215
  * 'Intermediate value must not be null'
221
216
  * );
222
217
  */
223
- static VERIFY_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
224
- [key: string]: any;
225
- } | null, eProps?: {
226
- [key: string]: any;
227
- } | null): boolean;
218
+ static VERIFY_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
228
219
  /**
229
220
  * Checks a precondition before execution.
230
221
  *
@@ -279,18 +270,14 @@ declare class Contracts {
279
270
  * return a / b;
280
271
  * }
281
272
  */
282
- static REQUIRE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
283
- [key: string]: any;
284
- } | null, eProps?: {
285
- [key: string]: any;
286
- } | null): boolean;
273
+ static REQUIRE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
287
274
  /**
288
275
  * Checks a precondition in debug mode only.
289
276
  *
290
277
  * Performs the same validation as REQUIRE only when
291
- * DEBUG_MODE is enabled.
278
+ * `debug_mode`(internal state) is enabled.
292
279
  *
293
- * When DEBUG_MODE is disabled,
280
+ * When `debug_mode`(internal state) is disabled,
294
281
  * no validation is performed.
295
282
  *
296
283
  * Typical usage:
@@ -329,11 +316,7 @@ declare class Contracts {
329
316
  * 'User must exist during debugging'
330
317
  * );
331
318
  */
332
- static REQUIRE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
333
- [key: string]: any;
334
- } | null, eProps?: {
335
- [key: string]: any;
336
- } | null): boolean;
319
+ static REQUIRE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
337
320
  /**
338
321
  * Checks a postcondition after execution.
339
322
  *
@@ -391,18 +374,14 @@ declare class Contracts {
391
374
  * return result;
392
375
  * }
393
376
  */
394
- static ENSURE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
395
- [key: string]: any;
396
- } | null, eProps?: {
397
- [key: string]: any;
398
- } | null): boolean;
377
+ static ENSURE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
399
378
  /**
400
379
  * Checks a postcondition in debug mode only.
401
380
  *
402
381
  * Performs the same validation as ENSURE only when
403
- * DEBUG_MODE is enabled.
382
+ * `debug_mode`(internal state) is enabled.
404
383
  *
405
- * When DEBUG_MODE is disabled,
384
+ * When `debug_mode`(internal state) is disabled,
406
385
  * no validation is performed.
407
386
  *
408
387
  * Typical usage:
@@ -441,11 +420,7 @@ declare class Contracts {
441
420
  * 'Result should exist during debugging'
442
421
  * );
443
422
  */
444
- static ENSURE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
445
- [key: string]: any;
446
- } | null, eProps?: {
447
- [key: string]: any;
448
- } | null): boolean;
423
+ static ENSURE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
449
424
  /**
450
425
  * Checks an invariant condition.
451
426
  *
@@ -500,18 +475,14 @@ declare class Contracts {
500
475
  *
501
476
  * }
502
477
  */
503
- static INVARIANT(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
504
- [key: string]: any;
505
- } | null, eProps?: {
506
- [key: string]: any;
507
- } | null): boolean;
478
+ static INVARIANT(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
508
479
  /**
509
480
  * Checks an invariant condition in debug mode only.
510
481
  *
511
482
  * Performs the same validation as INVARIANT only when
512
- * DEBUG_MODE is enabled.
483
+ * `debug_mode`(internal state) is enabled.
513
484
  *
514
- * When DEBUG_MODE is disabled,
485
+ * When `debug_mode`(internal state) is disabled,
515
486
  * no validation is performed.
516
487
  *
517
488
  * Typical usage:
@@ -550,11 +521,7 @@ declare class Contracts {
550
521
  * 'Cache size exceeded expected limit'
551
522
  * );
552
523
  */
553
- static INVARIANT_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
554
- [key: string]: any;
555
- } | null, eProps?: {
556
- [key: string]: any;
557
- } | null): boolean;
524
+ static INVARIANT_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
558
525
  /**
559
526
  * Core contract evaluation logic.
560
527
  *
@@ -605,10 +572,9 @@ declare class Contracts {
605
572
  /**
606
573
  * Debug-only contract evaluation logic.
607
574
  *
608
- * Executes contract validation only when DEBUG_MODE
609
- * is enabled.
575
+ * Executes contract validation only when `debug_mode`(internal state) is enabled.
610
576
  *
611
- * When DEBUG_MODE is disabled,
577
+ * When `debug_mode`(internal state) is disabled,
612
578
  * this method returns the original condition value
613
579
  * without performing any validation.
614
580
  *
@@ -645,12 +611,6 @@ declare class Contracts {
645
611
  *
646
612
  */
647
613
  private static checkDebug;
648
- /**
649
- * Get logger
650
- *
651
- * @internal
652
- */
653
- private static getLogger;
654
614
  }
655
615
 
656
616
  export { type Config, type ConfigKey, Contracts, type LogProvider, Contracts as default };
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ type LogProvider = Pick<Console, 'error'>;
8
8
  interface Config {
9
9
  /**
10
10
  * Debug mode state.
11
- * If `true`, `DEBUG_MODE` is enabled; otherwise, it is disabled.
11
+ * If `true`, `debug_mode`(internal state) is enabled; otherwise, it is disabled.
12
12
  * The default is `false`.
13
13
  */
14
14
  debug?: boolean;
@@ -49,9 +49,9 @@ type ConfigKey = keyof Config;
49
49
  * ## Debug Mode
50
50
  *
51
51
  * Methods ending with `_DEBUG` execute contract checks only
52
- * when `DEBUG_MODE` is enabled.
52
+ * when `debug_mode`(internal state) is enabled.
53
53
  *
54
- * When `DEBUG_MODE` is disabled,
54
+ * When `debug_mode`(internal state) is disabled,
55
55
  * these methods return the original condition value
56
56
  * without performing validation.
57
57
  *
@@ -68,7 +68,6 @@ declare class Contracts {
68
68
  * Please use `setConfig()` to change the debug mode.**
69
69
  */
70
70
  static DEBUG_MODE: boolean;
71
- /** logger */
72
71
  /**
73
72
  * Configures contract checking behavior.
74
73
  *
@@ -89,7 +88,7 @@ declare class Contracts {
89
88
  * it is used instead of the standard logger, `console`.
90
89
  * This module uses only the `error` method of the `logger`. <br>
91
90
  * <br>
92
- * Note: If the value of a property is `undefined`, it is treated as unspecified.
91
+ * Note: If the value of a property is `undefined` or `null`, it is treated as unspecified.
93
92
  *
94
93
  * @param reset
95
94
  * If `true`, unspecified values ​​are saved to the settings as default values. <br>
@@ -170,18 +169,14 @@ declare class Contracts {
170
169
  * 'Calculation result must not be negative'
171
170
  * );
172
171
  */
173
- static VERIFY(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
174
- [key: string]: any;
175
- } | null, eProps?: {
176
- [key: string]: any;
177
- } | null): boolean;
172
+ static VERIFY(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
178
173
  /**
179
174
  * Verifies an intermediate condition in debug mode only.
180
175
  *
181
176
  * Performs the same validation as VERIFY only when
182
- * DEBUG_MODE is enabled.
177
+ * `debug_mode`(internal state) is enabled.
183
178
  *
184
- * When DEBUG_MODE is disabled,
179
+ * When `debug_mode`(internal state) is disabled,
185
180
  * no validation is performed.
186
181
  *
187
182
  * Typical usage:
@@ -220,11 +215,7 @@ declare class Contracts {
220
215
  * 'Intermediate value must not be null'
221
216
  * );
222
217
  */
223
- static VERIFY_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
224
- [key: string]: any;
225
- } | null, eProps?: {
226
- [key: string]: any;
227
- } | null): boolean;
218
+ static VERIFY_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
228
219
  /**
229
220
  * Checks a precondition before execution.
230
221
  *
@@ -279,18 +270,14 @@ declare class Contracts {
279
270
  * return a / b;
280
271
  * }
281
272
  */
282
- static REQUIRE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
283
- [key: string]: any;
284
- } | null, eProps?: {
285
- [key: string]: any;
286
- } | null): boolean;
273
+ static REQUIRE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
287
274
  /**
288
275
  * Checks a precondition in debug mode only.
289
276
  *
290
277
  * Performs the same validation as REQUIRE only when
291
- * DEBUG_MODE is enabled.
278
+ * `debug_mode`(internal state) is enabled.
292
279
  *
293
- * When DEBUG_MODE is disabled,
280
+ * When `debug_mode`(internal state) is disabled,
294
281
  * no validation is performed.
295
282
  *
296
283
  * Typical usage:
@@ -329,11 +316,7 @@ declare class Contracts {
329
316
  * 'User must exist during debugging'
330
317
  * );
331
318
  */
332
- static REQUIRE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
333
- [key: string]: any;
334
- } | null, eProps?: {
335
- [key: string]: any;
336
- } | null): boolean;
319
+ static REQUIRE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
337
320
  /**
338
321
  * Checks a postcondition after execution.
339
322
  *
@@ -391,18 +374,14 @@ declare class Contracts {
391
374
  * return result;
392
375
  * }
393
376
  */
394
- static ENSURE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
395
- [key: string]: any;
396
- } | null, eProps?: {
397
- [key: string]: any;
398
- } | null): boolean;
377
+ static ENSURE(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
399
378
  /**
400
379
  * Checks a postcondition in debug mode only.
401
380
  *
402
381
  * Performs the same validation as ENSURE only when
403
- * DEBUG_MODE is enabled.
382
+ * `debug_mode`(internal state) is enabled.
404
383
  *
405
- * When DEBUG_MODE is disabled,
384
+ * When `debug_mode`(internal state) is disabled,
406
385
  * no validation is performed.
407
386
  *
408
387
  * Typical usage:
@@ -441,11 +420,7 @@ declare class Contracts {
441
420
  * 'Result should exist during debugging'
442
421
  * );
443
422
  */
444
- static ENSURE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
445
- [key: string]: any;
446
- } | null, eProps?: {
447
- [key: string]: any;
448
- } | null): boolean;
423
+ static ENSURE_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
449
424
  /**
450
425
  * Checks an invariant condition.
451
426
  *
@@ -500,18 +475,14 @@ declare class Contracts {
500
475
  *
501
476
  * }
502
477
  */
503
- static INVARIANT(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
504
- [key: string]: any;
505
- } | null, eProps?: {
506
- [key: string]: any;
507
- } | null): boolean;
478
+ static INVARIANT(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
508
479
  /**
509
480
  * Checks an invariant condition in debug mode only.
510
481
  *
511
482
  * Performs the same validation as INVARIANT only when
512
- * DEBUG_MODE is enabled.
483
+ * `debug_mode`(internal state) is enabled.
513
484
  *
514
- * When DEBUG_MODE is disabled,
485
+ * When `debug_mode`(internal state) is disabled,
515
486
  * no validation is performed.
516
487
  *
517
488
  * Typical usage:
@@ -550,11 +521,7 @@ declare class Contracts {
550
521
  * 'Cache size exceeded expected limit'
551
522
  * );
552
523
  */
553
- static INVARIANT_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: {
554
- [key: string]: any;
555
- } | null, eProps?: {
556
- [key: string]: any;
557
- } | null): boolean;
524
+ static INVARIANT_DEBUG(isOk: boolean, ngMsg: string | null, ErrorClass?: (new (...args: any[]) => Error) | null, eParams?: Record<string, unknown> | null, eProps?: Record<string, unknown> | null): boolean;
558
525
  /**
559
526
  * Core contract evaluation logic.
560
527
  *
@@ -605,10 +572,9 @@ declare class Contracts {
605
572
  /**
606
573
  * Debug-only contract evaluation logic.
607
574
  *
608
- * Executes contract validation only when DEBUG_MODE
609
- * is enabled.
575
+ * Executes contract validation only when `debug_mode`(internal state) is enabled.
610
576
  *
611
- * When DEBUG_MODE is disabled,
577
+ * When `debug_mode`(internal state) is disabled,
612
578
  * this method returns the original condition value
613
579
  * without performing any validation.
614
580
  *
@@ -645,12 +611,6 @@ declare class Contracts {
645
611
  *
646
612
  */
647
613
  private static checkDebug;
648
- /**
649
- * Get logger
650
- *
651
- * @internal
652
- */
653
- private static getLogger;
654
614
  }
655
615
 
656
616
  export { type Config, type ConfigKey, Contracts, type LogProvider, Contracts as default };
package/dist/index.js CHANGED
@@ -16,8 +16,6 @@ var Contracts = class _Contracts {
16
16
  };
17
17
  /** Current config. */
18
18
  static #config = { ..._Contracts.#defaultConf };
19
- /** logger */
20
- //private static logger: LogProvider = console;
21
19
  /**
22
20
  * Configures contract checking behavior.
23
21
  *
@@ -38,7 +36,7 @@ var Contracts = class _Contracts {
38
36
  * it is used instead of the standard logger, `console`.
39
37
  * This module uses only the `error` method of the `logger`. <br>
40
38
  * <br>
41
- * Note: If the value of a property is `undefined`, it is treated as unspecified.
39
+ * Note: If the value of a property is `undefined` or `null`, it is treated as unspecified.
42
40
  *
43
41
  * @param reset
44
42
  * If `true`, unspecified values ​​are saved to the settings as default values. <br>
@@ -148,9 +146,9 @@ var Contracts = class _Contracts {
148
146
  * Verifies an intermediate condition in debug mode only.
149
147
  *
150
148
  * Performs the same validation as VERIFY only when
151
- * DEBUG_MODE is enabled.
149
+ * `debug_mode`(internal state) is enabled.
152
150
  *
153
- * When DEBUG_MODE is disabled,
151
+ * When `debug_mode`(internal state) is disabled,
154
152
  * no validation is performed.
155
153
  *
156
154
  * Typical usage:
@@ -267,9 +265,9 @@ var Contracts = class _Contracts {
267
265
  * Checks a precondition in debug mode only.
268
266
  *
269
267
  * Performs the same validation as REQUIRE only when
270
- * DEBUG_MODE is enabled.
268
+ * `debug_mode`(internal state) is enabled.
271
269
  *
272
- * When DEBUG_MODE is disabled,
270
+ * When `debug_mode`(internal state) is disabled,
273
271
  * no validation is performed.
274
272
  *
275
273
  * Typical usage:
@@ -389,9 +387,9 @@ var Contracts = class _Contracts {
389
387
  * Checks a postcondition in debug mode only.
390
388
  *
391
389
  * Performs the same validation as ENSURE only when
392
- * DEBUG_MODE is enabled.
390
+ * `debug_mode`(internal state) is enabled.
393
391
  *
394
- * When DEBUG_MODE is disabled,
392
+ * When `debug_mode`(internal state) is disabled,
395
393
  * no validation is performed.
396
394
  *
397
395
  * Typical usage:
@@ -508,9 +506,9 @@ var Contracts = class _Contracts {
508
506
  * Checks an invariant condition in debug mode only.
509
507
  *
510
508
  * Performs the same validation as INVARIANT only when
511
- * DEBUG_MODE is enabled.
509
+ * `debug_mode`(internal state) is enabled.
512
510
  *
513
- * When DEBUG_MODE is disabled,
511
+ * When `debug_mode`(internal state) is disabled,
514
512
  * no validation is performed.
515
513
  *
516
514
  * Typical usage:
@@ -608,9 +606,6 @@ var Contracts = class _Contracts {
608
606
  static check(isOk, prefix = "CHECK", ngMsg = "", ErrorClass = Error, eParams, eProps) {
609
607
  if (eProps === void 0) {
610
608
  eProps = eParams ?? {};
611
- eParams = null;
612
- } else {
613
- eProps ??= {};
614
609
  }
615
610
  if (!isOk) {
616
611
  const msg = `[${prefix}] ${ngMsg ?? ""}`;
@@ -620,7 +615,7 @@ var Contracts = class _Contracts {
620
615
  throw err;
621
616
  }
622
617
  if (ngMsg) {
623
- _Contracts.getLogger().error(msg, eProps);
618
+ _Contracts.#getLogger().error(msg, eProps);
624
619
  }
625
620
  }
626
621
  return isOk;
@@ -628,10 +623,9 @@ var Contracts = class _Contracts {
628
623
  /**
629
624
  * Debug-only contract evaluation logic.
630
625
  *
631
- * Executes contract validation only when DEBUG_MODE
632
- * is enabled.
626
+ * Executes contract validation only when `debug_mode`(internal state) is enabled.
633
627
  *
634
- * When DEBUG_MODE is disabled,
628
+ * When `debug_mode`(internal state) is disabled,
635
629
  * this method returns the original condition value
636
630
  * without performing any validation.
637
631
  *
@@ -678,11 +672,10 @@ var Contracts = class _Contracts {
678
672
  ) : isOk;
679
673
  }
680
674
  /**
681
- * Get logger
682
- *
683
675
  * @internal
676
+ * Get logger
684
677
  */
685
- static getLogger() {
678
+ static #getLogger() {
686
679
  return _Contracts.#config.logger;
687
680
  }
688
681
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayapapa-npm/contracts-js",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "A lightweight Design by Contract library for JavaScript.",
5
5
  "license": "MIT",
6
6
  "author": "ayapapa",
@@ -26,7 +26,7 @@
26
26
  "test:ui": "vitest --ui",
27
27
  "coverage": "vitest run --coverage",
28
28
  "coverage:ui": "vitest run --coverage && start coverage/index.html",
29
- "check": "npm run typecheck && npm run build && npm run test",
29
+ "check": "npm run typecheck && npm run build && npm run build:doc && npm run coverage:ui",
30
30
  "prepublishOnly": "npm run check"
31
31
  },
32
32
  "devDependencies": {