typia 5.5.0-dev.20240304 → 5.5.0-dev.20240306

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 (129) hide show
  1. package/lib/functional.d.ts +329 -0
  2. package/lib/functional.js +99 -234
  3. package/lib/functional.js.map +1 -1
  4. package/lib/http.d.ts +15 -6
  5. package/lib/http.js.map +1 -1
  6. package/lib/json.d.ts +17 -8
  7. package/lib/json.js.map +1 -1
  8. package/lib/misc.d.ts +18 -8
  9. package/lib/misc.js.map +1 -1
  10. package/lib/module.d.ts +17 -0
  11. package/lib/module.js.map +1 -1
  12. package/lib/notations.d.ts +12 -0
  13. package/lib/notations.js.map +1 -1
  14. package/lib/programmers/AssertProgrammer.d.ts +1 -0
  15. package/lib/programmers/AssertProgrammer.js +5 -2
  16. package/lib/programmers/AssertProgrammer.js.map +1 -1
  17. package/lib/programmers/RandomProgrammer.js +3 -1
  18. package/lib/programmers/RandomProgrammer.js.map +1 -1
  19. package/lib/programmers/TypiaProgrammer.js +1 -8
  20. package/lib/programmers/TypiaProgrammer.js.map +1 -1
  21. package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.d.ts +8 -2
  22. package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.js +22 -16
  23. package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.js.map +1 -1
  24. package/lib/programmers/functional/FunctionalAssertParametersProgrammer.d.ts +1 -1
  25. package/lib/programmers/functional/FunctionalAssertParametersProgrammer.js +8 -4
  26. package/lib/programmers/functional/FunctionalAssertParametersProgrammer.js.map +1 -1
  27. package/lib/programmers/functional/FunctionalAssertReturnProgrammer.d.ts +1 -1
  28. package/lib/programmers/functional/FunctionalAssertReturnProgrammer.js +8 -7
  29. package/lib/programmers/functional/FunctionalAssertReturnProgrammer.js.map +1 -1
  30. package/lib/programmers/functional/FunctionalIsFunctionProgrammer.d.ts +6 -0
  31. package/lib/programmers/functional/FunctionalIsFunctionProgrammer.js +54 -0
  32. package/lib/programmers/functional/FunctionalIsFunctionProgrammer.js.map +1 -0
  33. package/lib/programmers/functional/FunctionalIsParametersProgrammer.d.ts +7 -0
  34. package/lib/programmers/functional/FunctionalIsParametersProgrammer.js +79 -0
  35. package/lib/programmers/functional/FunctionalIsParametersProgrammer.js.map +1 -0
  36. package/lib/programmers/functional/FunctionalIsReturnProgrammer.d.ts +10 -0
  37. package/lib/programmers/functional/FunctionalIsReturnProgrammer.js +71 -0
  38. package/lib/programmers/functional/FunctionalIsReturnProgrammer.js.map +1 -0
  39. package/lib/programmers/functional/FunctionalValidateFunctionProgrammer.d.ts +10 -0
  40. package/lib/programmers/functional/FunctionalValidateFunctionProgrammer.js +61 -0
  41. package/lib/programmers/functional/FunctionalValidateFunctionProgrammer.js.map +1 -0
  42. package/lib/programmers/functional/FunctionalValidateParametersProgrammer.d.ts +7 -0
  43. package/lib/programmers/functional/FunctionalValidateParametersProgrammer.js +104 -0
  44. package/lib/programmers/functional/FunctionalValidateParametersProgrammer.js.map +1 -0
  45. package/lib/programmers/functional/FunctionalValidateReturnProgrammer.d.ts +10 -0
  46. package/lib/programmers/functional/FunctionalValidateReturnProgrammer.js +74 -0
  47. package/lib/programmers/functional/FunctionalValidateReturnProgrammer.js.map +1 -0
  48. package/lib/programmers/http/HttpAssertFormDataProgrammer.js +3 -1
  49. package/lib/programmers/http/HttpAssertFormDataProgrammer.js.map +1 -1
  50. package/lib/programmers/http/HttpAssertHeadersProgrammer.js +3 -1
  51. package/lib/programmers/http/HttpAssertHeadersProgrammer.js.map +1 -1
  52. package/lib/programmers/http/HttpAssertQueryProgrammer.js +3 -1
  53. package/lib/programmers/http/HttpAssertQueryProgrammer.js.map +1 -1
  54. package/lib/programmers/http/HttpFormDataProgrammer.js +3 -1
  55. package/lib/programmers/http/HttpFormDataProgrammer.js.map +1 -1
  56. package/lib/programmers/http/HttpHeadersProgrammer.js +3 -1
  57. package/lib/programmers/http/HttpHeadersProgrammer.js.map +1 -1
  58. package/lib/programmers/http/HttpIsFormDataProgrammer.js +3 -1
  59. package/lib/programmers/http/HttpIsFormDataProgrammer.js.map +1 -1
  60. package/lib/programmers/http/HttpIsHeadersProgrammer.js +3 -1
  61. package/lib/programmers/http/HttpIsHeadersProgrammer.js.map +1 -1
  62. package/lib/programmers/http/HttpIsQueryProgrammer.js +3 -1
  63. package/lib/programmers/http/HttpIsQueryProgrammer.js.map +1 -1
  64. package/lib/programmers/http/HttpQueryProgrammer.js +3 -1
  65. package/lib/programmers/http/HttpQueryProgrammer.js.map +1 -1
  66. package/lib/programmers/json/JsonAssertParseProgrammer.js +3 -1
  67. package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
  68. package/lib/programmers/json/JsonIsParseProgrammer.js +3 -1
  69. package/lib/programmers/json/JsonIsParseProgrammer.js.map +1 -1
  70. package/lib/programmers/misc/MiscAssertCloneProgrammer.js +3 -1
  71. package/lib/programmers/misc/MiscAssertCloneProgrammer.js.map +1 -1
  72. package/lib/programmers/misc/MiscCloneProgrammer.js +3 -1
  73. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  74. package/lib/programmers/misc/MiscIsCloneProgrammer.js +3 -1
  75. package/lib/programmers/misc/MiscIsCloneProgrammer.js.map +1 -1
  76. package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js +3 -1
  77. package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js.map +1 -1
  78. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +3 -1
  79. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
  80. package/lib/programmers/protobuf/ProtobufIsDecodeProgrammer.js +3 -1
  81. package/lib/programmers/protobuf/ProtobufIsDecodeProgrammer.js.map +1 -1
  82. package/lib/programmers/protobuf/ProtobufMessageProgrammer.js +1 -1
  83. package/lib/protobuf.d.ts +8 -0
  84. package/lib/protobuf.js.map +1 -1
  85. package/lib/transformers/CallExpressionTransformer.js +104 -12
  86. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  87. package/lib/utils/StringUtil/StringUtil.d.ts +1 -0
  88. package/lib/utils/StringUtil/StringUtil.js +7 -1
  89. package/lib/utils/StringUtil/StringUtil.js.map +1 -1
  90. package/package.json +2 -1
  91. package/src/functional.ts +542 -246
  92. package/src/http.ts +15 -6
  93. package/src/json.ts +17 -8
  94. package/src/misc.ts +18 -8
  95. package/src/module.ts +17 -0
  96. package/src/notations.ts +12 -0
  97. package/src/programmers/AssertProgrammer.ts +24 -22
  98. package/src/programmers/RandomProgrammer.ts +12 -4
  99. package/src/programmers/TypiaProgrammer.ts +1 -11
  100. package/src/programmers/functional/FunctionalAssertFunctionProgrammer.ts +64 -55
  101. package/src/programmers/functional/FunctionalAssertParametersProgrammer.ts +13 -5
  102. package/src/programmers/functional/FunctionalAssertReturnProgrammer.ts +10 -8
  103. package/src/programmers/functional/FunctionalIsFunctionProgrammer.ts +45 -0
  104. package/src/programmers/functional/FunctionalIsParametersProgrammer.ts +78 -0
  105. package/src/programmers/functional/FunctionalIsReturnProgrammer.ts +91 -0
  106. package/src/programmers/functional/FunctionalValidateFunctionProgrammer.ts +91 -0
  107. package/src/programmers/functional/FunctionalValidateParametersProgrammer.ts +212 -0
  108. package/src/programmers/functional/FunctionalValidateReturnProgrammer.ts +115 -0
  109. package/src/programmers/http/HttpAssertFormDataProgrammer.ts +12 -4
  110. package/src/programmers/http/HttpAssertHeadersProgrammer.ts +12 -4
  111. package/src/programmers/http/HttpAssertQueryProgrammer.ts +12 -4
  112. package/src/programmers/http/HttpFormDataProgrammer.ts +12 -4
  113. package/src/programmers/http/HttpHeadersProgrammer.ts +12 -4
  114. package/src/programmers/http/HttpIsFormDataProgrammer.ts +12 -4
  115. package/src/programmers/http/HttpIsHeadersProgrammer.ts +12 -4
  116. package/src/programmers/http/HttpIsQueryProgrammer.ts +12 -4
  117. package/src/programmers/http/HttpQueryProgrammer.ts +12 -4
  118. package/src/programmers/json/JsonAssertParseProgrammer.ts +12 -4
  119. package/src/programmers/json/JsonIsParseProgrammer.ts +12 -4
  120. package/src/programmers/misc/MiscAssertCloneProgrammer.ts +12 -4
  121. package/src/programmers/misc/MiscCloneProgrammer.ts +12 -4
  122. package/src/programmers/misc/MiscIsCloneProgrammer.ts +12 -4
  123. package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +12 -4
  124. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +12 -4
  125. package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +12 -4
  126. package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +1 -1
  127. package/src/protobuf.ts +8 -0
  128. package/src/transformers/CallExpressionTransformer.ts +95 -12
  129. package/src/utils/StringUtil/StringUtil.ts +5 -0
package/src/functional.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import * as Namespace from "./functional/Namespace";
2
2
 
3
- // import { IValidation } from "./IValidation";
3
+ import { IValidation } from "./IValidation";
4
4
  import { TypeGuardError } from "./TypeGuardError";
5
5
 
6
6
  /* ===========================================================
7
7
  FUNCTIONAL
8
- - ASSERTIONS
9
- - VALIDATIONS
8
+ - ASSERT
9
+ - IS
10
+ - VALIDATE
10
11
  ==============================================================
11
- ASSERTIONS
12
+ ASSERT
12
13
  ----------------------------------------------------------- */
13
14
  /**
14
15
  * Asserts a function.
@@ -320,248 +321,543 @@ const assertEqualsReturnPure = /** @__PURE__ */ Object.assign<
320
321
  );
321
322
  export { assertEqualsReturnPure as assertEqualsReturn };
322
323
 
323
- // /* -----------------------------------------------------------
324
- // VALIDATIONS
325
- // ----------------------------------------------------------- */
326
- // /**
327
- // * Validates a function.
328
- // *
329
- // * Validates a function, by wrapping the function and checking its parameters and
330
- // * return value through {@link validate} function. If some parameter or return value
331
- // * does not match the expected type, it returns {@link IValidation.IError} typed
332
- // * object. Otherwise there's no type error, it returns {@link IValidation.ISuccess}
333
- // * typed object instead.
334
- // *
335
- // * For reference, {@link IValidation.IError.path} would be a little bit different with
336
- // * individual {@link validate} function. If the {@link IValidation.IError} occurs from
337
- // * some parameter, the path would start from `$input.parameters[number]`. Otherwise
338
- // * the path would start from `$input.return`.
339
- // *
340
- // * - `$input.parameters[0].~`
341
- // * - `$input.return.~`
342
- // *
343
- // * By the way, if what you want is not finding every type errors, but just finding
344
- // * the 1st type error, then use {@link assertFunction} instead. Otherwise, what you
345
- // * want is just validating parameters or return value only, you can use
346
- // * {@link validateParameters} or {@link validateReturn} instead.
347
- // *
348
- // * On the other hand, if you don't want to allow any superfluous properties, utilize
349
- // * {@link validateEqualsFunction} or {@link assertEqualsFunction} instead.
350
- // *
351
- // * @template T Target function type
352
- // * @param func Target function to validate
353
- // * @returns The wrapper function with type validations
354
- // *
355
- // * @author Jeongho Nam - https://github.com/samchon
356
- // */
357
- // function validateFunction<T extends (...args: any[]) => any>(
358
- // func: T,
359
- // ): T extends (...args: infer Arguments) => infer Output
360
- // ? Output extends Promise<infer R>
361
- // ? (...args: Arguments) => Promise<IValidation<R>>
362
- // : (...args: Arguments) => IValidation<Output>
363
- // : never;
364
-
365
- // /**
366
- // * @internal
367
- // */
368
- // function validateFunction(): never {
369
- // halt("validateFunction");
370
- // }
371
- // const validateFunctionPure = /** @__PURE__ */ Object.assign<
372
- // typeof validateFunction,
373
- // {}
374
- // >(validateFunction, /** @__PURE__ */ Namespace.validate());
375
- // export { validateFunctionPure as validateFunction };
376
-
377
- // /**
378
- // * Validates parameters.
379
- // *
380
- // * Validates a function, by wrapping the function and checking its parameters through
381
- // * {@link validate} function. If some parameter does not match the expected type, it
382
- // * returns {@link IValidation.IError} typed object. Otherwise there's no type error,
383
- // * it returns {@link IValidation.ISuccess} typed object instead.
384
- // *
385
- // * For reference, {@link IValidation.IError.path} would be a little bit different with
386
- // * individual {@link validate} function. If the {@link IValidation.IError} occurs from
387
- // * some parameter, the path would start from `$input.parameters[number]`.
388
- // *
389
- // * By the way, if what you want is not finding every type errors, but just finding
390
- // * the 1st type error, then use {@link assertParameters} instead. Otherwise, what you
391
- // * want is not only validating parameters, but also validating return value, you can
392
- // * use {@link validateFunction} instead.
393
- // *
394
- // * On the other hand, if you don't want to allow any superfluous properties, utilize
395
- // * {@link validateEqualsParameters} or {@link assertEqualsParameters} instead.
396
- // *
397
- // * @template T Target function type
398
- // * @param func Target function to validate
399
- // * @returns The wrapper function with type validations
400
- // *
401
- // * @author Jeongho Nam - https://github.com/samchon
402
- // */
403
- // function validateReturn<T extends (...args: any[]) => any>(
404
- // func: T,
405
- // ): T extends (...args: infer Arguments) => infer Output
406
- // ? Output extends Promise<infer R>
407
- // ? (...args: Arguments) => Promise<IValidation<R>>
408
- // : (...args: Arguments) => IValidation<Output>
409
- // : never;
410
-
411
- // /**
412
- // * @internal
413
- // */
414
- // function validateReturn(): never {
415
- // halt("validateReturn");
416
- // }
417
- // const validateReturnPure = /** @__PURE__ */ Object.assign<
418
- // typeof validateReturn,
419
- // {}
420
- // >(validateReturn, /** @__PURE__ */ Namespace.validate());
421
- // export { validateReturnPure as validateReturn };
422
-
423
- // /**
424
- // * Validates a function with strict equality.
425
- // *
426
- // * Validates a function with strict equality, by wrapping the function and checking
427
- // * its parameters and return value through {@link validateEquals} function. If some
428
- // * parameter or return value does not match the expected type, it returns
429
- // * {@link IValidation.IError} typed object. Otherwise there's no type error, it
430
- // * returns {@link IValidation.ISuccess} typed object instead.
431
- // *
432
- // * For reference, {@link IValidation.IError.path} would be a little bit different with
433
- // * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
434
- // * from some parameter, the path would start from `$input.parameters[number]`. Otherwise
435
- // * the path would start from `$input.return`.
436
- // *
437
- // * - `$input.parameters[0].~`
438
- // * - `$input.return.~`
439
- // *
440
- // * By the way, if what you want is not finding every type errors, but just finding
441
- // * the 1st type error, then use {@link assertEqualsFunction} instead. Otherwise, what
442
- // * you want is just validating parameters or return value only, you can use
443
- // * {@link validateEqualsParameters} or {@link validateEqualsReturn} instead.
444
- // *
445
- // * On the other hand, if you want to allow any superfluous properties, utilize
446
- // * {@link validateFunction} or {@link assertFunction} instead.
447
- // *
448
- // * @template T Target function type
449
- // * @param func Target function to validate
450
- // * @returns The wrapper function with type validations
451
- // *
452
- // * @author Jeongho Nam - https://github.com/samchon
453
- // */
454
- // function validateEqualsFunction<T extends (...args: any[]) => any>(
455
- // func: T,
456
- // ): T extends (...args: infer Arguments) => infer Output
457
- // ? Output extends Promise<infer R>
458
- // ? (...args: Arguments) => Promise<IValidation<R>>
459
- // : (...args: Arguments) => IValidation<Output>
460
- // : never;
461
-
462
- // /**
463
- // * @internal
464
- // */
465
- // function validateEqualsFunction(): never {
466
- // halt("validateEqualsFunction");
467
- // }
468
- // const validateEqualsFunctionPure = /** @__PURE__ */ Object.assign<
469
- // typeof validateEqualsFunction,
470
- // {}
471
- // >(validateEqualsFunction, /** @__PURE__ */ Namespace.validate());
472
- // export { validateEqualsFunctionPure as validateEqualsFunction };
473
-
474
- // /**
475
- // * Validates parameters with strict equality.
476
- // *
477
- // * Validates a function, by wrapping the function and checking its parameters through
478
- // * {@link validateEquals} function. If some parameter does not match the expected type,
479
- // * it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
480
- // * it returns {@link IValidation.ISuccess} typed object instead.
481
- // *
482
- // * For reference, {@link IValidation.IError.path} would be a little bit different with
483
- // * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
484
- // * from some parameter, the path would start from `$input.parameters[number]`.
485
- // *
486
- // * By the way, if what you want is not finding every type errors, but just finding
487
- // * the 1st type error, then use {@link assertEqualsParameters} instead. Otherwise,
488
- // * what you want is not only validating parameters, but also validating return value,
489
- // * you can use {@link validateEqualsFunction} instead.
490
- // *
491
- // * On the other hand, if you want to allow any superfluous properties, utilize
492
- // * {@link validateParameters} or {@link assertParameters} instead.
493
- // *
494
- // * @template T Target function type
495
- // * @param func Target function to validate
496
- // * @returns The wrapper function with type validations
497
- // *
498
- // * @author Jeongho Nam - https://github.com/samchon
499
- // */
500
- // function validateEqualsParameters<T extends (...args: any[]) => any>(
501
- // func: T,
502
- // ): T extends (...args: infer Arguments) => infer Output
503
- // ? Output extends Promise<infer R>
504
- // ? (...args: Arguments) => Promise<IValidation<R>>
505
- // : (...args: Arguments) => IValidation<Output>
506
- // : never;
507
-
508
- // /**
509
- // * @internal
510
- // */
511
- // function validateEqualsParameters(): never {
512
- // halt("validateEqualsParameters");
513
- // }
514
- // const validateEqualsParametersPure = /** @__PURE__ */ Object.assign<
515
- // typeof validateEqualsParameters,
516
- // {}
517
- // >(validateEqualsParameters, /** @__PURE__ */ Namespace.validate());
518
- // export { validateEqualsParametersPure as validateEqualsParameters };
519
-
520
- // /**
521
- // * Validates return value with strict equality.
522
- // *
523
- // * Validates a function, by wrapping the function and checking its return value through
524
- // * {@link validateEquals} function. If the return value does not match the expected type,
525
- // * it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
526
- // * it returns {@link IValidation.ISuccess} typed object instead.
527
- // *
528
- // * For reference, {@link IValidation.IError.path} would be a little bit different with
529
- // * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
530
- // * from the return value, the path would start from `$input.return`.
531
- // *
532
- // * By the way, if what you want is not finding every type errors, but just finding
533
- // * the 1st type error, then use {@link assertEqualsReturn} instead. Otherwise, what you
534
- // * want is not only validating return value, but also validating parameters, you can use
535
- // * {@link validateEqualsFunction} instead.
536
- // *
537
- // * On the other hand, if you want to allow any superfluous properties, utilize
538
- // * {@link validateReturn} or {@link assertReturn} instead.
539
- // *
540
- // * @template T Target function type
541
- // * @param func Target function to validate
542
- // * @returns The wrapper function with type validations
543
- // *
544
- // * @author Jeongho Nam - https://github.com/samchon
545
- // */
546
- // function validateEqualsReturn<T extends (...args: any[]) => any>(
547
- // func: T,
548
- // ): T extends (...args: infer Arguments) => infer Output
549
- // ? Output extends Promise<infer R>
550
- // ? (...args: Arguments) => Promise<IValidation<R>>
551
- // : (...args: Arguments) => IValidation<Output>
552
- // : never;
553
-
554
- // /**
555
- // * @internal
556
- // */
557
- // function validateEqualsReturn(): never {
558
- // halt("validateEqualsReturn");
559
- // }
560
- // const validateEqualsReturnPure = /** @__PURE__ */ Object.assign<
561
- // typeof validateEqualsReturn,
562
- // {}
563
- // >(validateEqualsReturn, /** @__PURE__ */ Namespace.validate());
564
- // export { validateEqualsReturnPure as validateEqualsReturn };
324
+ /* -----------------------------------------------------------
325
+ IS
326
+ ----------------------------------------------------------- */
327
+ /**
328
+ * Tests a function.
329
+ *
330
+ * Tests a function, by wrapping the function and checking its parameters and
331
+ * return value through {@link is} function. If some parameter or return value
332
+ * does not match the expected type, it returns `null`. Otherwise there's no
333
+ * type error, it returns the result of the function.
334
+ *
335
+ * By the way, if you want is not just testing type checking, but also finding
336
+ * detailed type error reason(s), then use {@link assertFunction} or
337
+ * {@link validateFunction} instead.
338
+ *
339
+ * On the other hand, if you don't want to allow any superfluous properties,
340
+ * utilize {@link equalsFunction}, {@link assertEqualsFunction} or
341
+ * {@link validateEqualsFunction} instead.
342
+ *
343
+ * @template T Target function type
344
+ * @param func Target function to test
345
+ * @returns The wrapper function with type tests
346
+ *
347
+ * @author Jeongho Nam - https://github.com/samchon
348
+ */
349
+ function isFunction<T extends (...args: any[]) => any>(
350
+ func: T,
351
+ ): T extends (...args: infer Arguments) => infer Output
352
+ ? Output extends Promise<infer R>
353
+ ? (...args: Arguments) => Promise<R | null>
354
+ : (...args: Arguments) => Output | null
355
+ : never;
356
+
357
+ /**
358
+ * @internal
359
+ */
360
+ function isFunction(): never {
361
+ halt("isFunction");
362
+ }
363
+ const isFunctionPure = /** @__PURE__ */ Object.assign<typeof isFunction, {}>(
364
+ isFunction,
365
+ /** @__PURE__ */ Namespace.is(),
366
+ );
367
+ export { isFunctionPure as isFunction };
368
+
369
+ /**
370
+ * Tests parameters.
371
+ *
372
+ * Tests a function, by wrapping the function and checking its parameters through
373
+ * {@link is} function. If some parameter does not match the expected type, it
374
+ * returns `null`. Otherwise there's no type error, it returns the result of the
375
+ * function.
376
+ *
377
+ * By the way, if you want is not just testing type checking, but also finding
378
+ * detailed type error reason(s), then use {@link assertParameters} or
379
+ * {@link validateParameters} instead.
380
+ *
381
+ * On the other hand, if you don't want to allow any superfluous properties,
382
+ * utilize {@link equalsParameters}, {@link assertEqualsParameters} or
383
+ * {@link validateEqualsParameters} instead.
384
+ *
385
+ * @template T Target function type
386
+ * @param func Target function to test
387
+ * @returns The wrapper function with type tests
388
+ *
389
+ * @author Jeongho Nam - https://github.com/samchon
390
+ */
391
+ function isParameters<T extends (...args: any[]) => any>(
392
+ func: T,
393
+ ): T extends (...args: infer Arguments) => infer Output
394
+ ? Output extends Promise<infer R>
395
+ ? (...args: Arguments) => Promise<R | null>
396
+ : (...args: Arguments) => Output | null
397
+ : never;
398
+
399
+ /**
400
+ * @internal
401
+ */
402
+ function isParameters(): never {
403
+ halt("isParameters");
404
+ }
405
+ const isParametersPure = /** @__PURE__ */ Object.assign<
406
+ typeof isParameters,
407
+ {}
408
+ >(isParameters, /** @__PURE__ */ Namespace.is());
409
+ export { isParametersPure as isParameters };
410
+
411
+ /**
412
+ * Tests return value.
413
+ *
414
+ * Tests a function, by wrapping the function and checking its return value through
415
+ * {@link is} function. If the return value does not match the expected type, it
416
+ * returns `null`. Otherwise there's no type error, it returns the result of the
417
+ * function.
418
+ *
419
+ * By the way, if you want is not just testing type checking, but also finding
420
+ * detailed type error reason(s), then use {@link assertReturn} or
421
+ * {@link validateReturn} instead.
422
+ *
423
+ * On the other hand, if you don't want to allow any superfluous properties,
424
+ * utilize {@link equalsReturn}, {@link assertEqualsReturn} or
425
+ * {@link validateEqualsReturn} instead.
426
+ *
427
+ * @template T Target function type
428
+ * @param func Target function to test
429
+ * @returns The wrapper function with type tests
430
+ *
431
+ * @author Jeongho Nam - https://github.com/samchon
432
+ */
433
+ function isReturn<T extends (...args: any[]) => any>(
434
+ func: T,
435
+ ): T extends (...args: infer Arguments) => infer Output
436
+ ? Output extends Promise<infer R>
437
+ ? (...args: Arguments) => Promise<R | null>
438
+ : (...args: Arguments) => Output | null
439
+ : never;
440
+
441
+ /**
442
+ * @internal
443
+ */
444
+ function isReturn(): never {
445
+ halt("isReturn");
446
+ }
447
+ const isReturnPure = /** @__PURE__ */ Object.assign<typeof isReturn, {}>(
448
+ isReturn,
449
+ /** @__PURE__ */ Namespace.is(),
450
+ );
451
+ export { isReturnPure as isReturn };
452
+
453
+ /**
454
+ * Tests a function with strict equality.
455
+ *
456
+ * Tests a function with strict equality, by wrapping the function and checking its
457
+ * parameters and return value through {@link isEquals} function. If some parameter
458
+ * or return value does not match the expected type, it returns `null`. Otherwise
459
+ * there's no type error, it returns the result of the function.
460
+ *
461
+ * By the way, if you want is not just testing type checking, but also finding
462
+ * detailed type error reason(s), then use {@link assertEqualsFunction} or
463
+ * {@link validateEqualsFunction} instead.
464
+ *
465
+ * On the other hand, if you want to allow any superfluous properties, utilize
466
+ * {@link isFunction}, {@link assertFunction} or {@link validateFunction} instead.
467
+ *
468
+ * @template T Target function type
469
+ * @param func Target function to test
470
+ * @returns The wrapper function with type tests
471
+ *
472
+ * @author Jeongho Nam - https://github.com/samchon
473
+ */
474
+ function equalsFunction<T extends (...args: any[]) => any>(
475
+ func: T,
476
+ ): T extends (...args: infer Arguments) => infer Output
477
+ ? Output extends Promise<infer R>
478
+ ? (...args: Arguments) => Promise<R | null>
479
+ : (...args: Arguments) => Output | null
480
+ : never;
481
+
482
+ /**
483
+ * @internal
484
+ */
485
+ function equalsFunction(): never {
486
+ halt("equalsFunction");
487
+ }
488
+ const equalsFunctionPure = /** @__PURE__ */ Object.assign<
489
+ typeof equalsFunction,
490
+ {}
491
+ >(equalsFunction, /** @__PURE__ */ Namespace.is());
492
+ export { equalsFunctionPure as equalsFunction };
493
+
494
+ /**
495
+ * Tests parameters with strict equality.
496
+ *
497
+ * Tests a function, by wrapping the function and checking its parameters through
498
+ * {@link isEquals} function. If some parameter does not match the expected type,
499
+ * it returns `null`. Otherwise there's no type error, it returns the result of the
500
+ * function.
501
+ *
502
+ * By the way, if you want is not just testing type checking, but also finding
503
+ * detailed type error reason(s), then use {@link assertEqualsParameters} or
504
+ * {@link validateEqualsParameters} instead.
505
+ *
506
+ * @template T Target function type
507
+ * @param func Target function to test
508
+ * @returns The wrapper function with type tests
509
+ *
510
+ * @author Jeongho Nam - https://github.com/samchon
511
+ */
512
+ function equalsParameters<T extends (...args: any[]) => any>(
513
+ func: T,
514
+ ): T extends (...args: infer Arguments) => infer Output
515
+ ? Output extends Promise<infer R>
516
+ ? (...args: Arguments) => Promise<R | null>
517
+ : (...args: Arguments) => Output | null
518
+ : never;
519
+
520
+ /**
521
+ * @internal
522
+ */
523
+ function equalsParameters(): never {
524
+ halt("equalsParameters");
525
+ }
526
+ const equalsParametersPure = /** @__PURE__ */ Object.assign<
527
+ typeof equalsParameters,
528
+ {}
529
+ >(equalsParameters, /** @__PURE__ */ Namespace.is());
530
+ export { equalsParametersPure as equalsParameters };
531
+
532
+ /**
533
+ * Tests return value with strict equality.
534
+ *
535
+ * Tests a function, by wrapping the function and checking its return value through
536
+ * {@link isEquals} function. If the return value does not match the expected type,
537
+ * it returns `null`. Otherwise there's no type error, it returns the result of the
538
+ * function.
539
+ *
540
+ * By the way, if you want is not just testing type checking, but also finding
541
+ * detailed type error reason(s), then use {@link assertEqualsReturn} or
542
+ * {@link validateEqualsReturn} instead.
543
+ *
544
+ * On the other hand, if you want to allow any superfluous properties, utilize
545
+ * {@link isReturn}, {@link assertReturn} or {@link validateReturn} instead.
546
+ *
547
+ * @template T Target function type
548
+ * @param func Target function to test
549
+ * @returns The wrapper function with type tests
550
+ *
551
+ * @author Jeongho Nam - https://github.com/samchon
552
+ */
553
+ function equalsReturn<T extends (...args: any[]) => any>(
554
+ func: T,
555
+ ): T extends (...args: infer Arguments) => infer Output
556
+ ? Output extends Promise<infer R>
557
+ ? (...args: Arguments) => Promise<R | null>
558
+ : (...args: Arguments) => Output | null
559
+ : never;
560
+
561
+ /**
562
+ * @internal
563
+ */
564
+ function equalsReturn(): never {
565
+ halt("equalsReturn");
566
+ }
567
+ const equalsReturnPure = /** @__PURE__ */ Object.assign<
568
+ typeof equalsReturn,
569
+ {}
570
+ >(equalsReturn, /** @__PURE__ */ Namespace.is());
571
+ export { equalsReturnPure as equalsReturn };
572
+
573
+ /* -----------------------------------------------------------
574
+ VALIDATE
575
+ ----------------------------------------------------------- */
576
+ /**
577
+ * Validates a function.
578
+ *
579
+ * Validates a function, by wrapping the function and checking its parameters and
580
+ * return value through {@link validate} function. If some parameter or return value
581
+ * does not match the expected type, it returns {@link IValidation.IError} typed
582
+ * object. Otherwise there's no type error, it returns {@link IValidation.ISuccess}
583
+ * typed object instead.
584
+ *
585
+ * For reference, {@link IValidation.IError.path} would be a little bit different with
586
+ * individual {@link validate} function. If the {@link IValidation.IError} occurs from
587
+ * some parameter, the path would start from `$input.parameters[number]`. Otherwise
588
+ * the path would start from `$input.return`.
589
+ *
590
+ * - `$input.parameters[0].~`
591
+ * - `$input.return.~`
592
+ *
593
+ * By the way, if what you want is not finding every type errors, but just finding
594
+ * the 1st type error, then use {@link assertFunction} instead. Otherwise, what you
595
+ * want is just validating parameters or return value only, you can use
596
+ * {@link validateParameters} or {@link validateReturn} instead.
597
+ *
598
+ * On the other hand, if you don't want to allow any superfluous properties, utilize
599
+ * {@link validateEqualsFunction} or {@link assertEqualsFunction} instead.
600
+ *
601
+ * @template T Target function type
602
+ * @param func Target function to validate
603
+ * @returns The wrapper function with type validations
604
+ *
605
+ * @author Jeongho Nam - https://github.com/samchon
606
+ */
607
+ function validateFunction<T extends (...args: any[]) => any>(
608
+ func: T,
609
+ ): T extends (...args: infer Arguments) => infer Output
610
+ ? Output extends Promise<infer R>
611
+ ? (...args: Arguments) => Promise<IValidation<R>>
612
+ : (...args: Arguments) => IValidation<Output>
613
+ : never;
614
+
615
+ /**
616
+ * @internal
617
+ */
618
+ function validateFunction(): never {
619
+ halt("validateFunction");
620
+ }
621
+ const validateFunctionPure = /** @__PURE__ */ Object.assign<
622
+ typeof validateFunction,
623
+ {}
624
+ >(validateFunction, /** @__PURE__ */ Namespace.validate());
625
+ export { validateFunctionPure as validateFunction };
626
+
627
+ /**
628
+ * Validates parameters.
629
+ *
630
+ * Validates a function, by wrapping the function and checking its parameters through
631
+ * {@link validate} function. If some parameter does not match the expected type, it
632
+ * returns {@link IValidation.IError} typed object. Otherwise there's no type error,
633
+ * it returns {@link IValidation.ISuccess} typed object instead.
634
+ *
635
+ * For reference, {@link IValidation.IError.path} would be a little bit different with
636
+ * individual {@link validate} function. If the {@link IValidation.IError} occurs from
637
+ * some parameter, the path would start from `$input.parameters[number]`.
638
+ *
639
+ * By the way, if what you want is not finding every type errors, but just finding
640
+ * the 1st type error, then use {@link assertParameters} instead. Otherwise, what you
641
+ * want is not only validating parameters, but also validating return value, you can
642
+ * use {@link validateFunction} instead.
643
+ *
644
+ * On the other hand, if you don't want to allow any superfluous properties, utilize
645
+ * {@link validateEqualsParameters} or {@link assertEqualsParameters} instead.
646
+ *
647
+ * @template T Target function type
648
+ * @param func Target function to validate
649
+ * @returns The wrapper function with type validations
650
+ *
651
+ * @author Jeongho Nam - https://github.com/samchon
652
+ */
653
+ function validateParameters<T extends (...args: any[]) => any>(
654
+ func: T,
655
+ ): T extends (...args: infer Arguments) => infer Output
656
+ ? Output extends Promise<infer R>
657
+ ? (...args: Arguments) => Promise<IValidation<R>>
658
+ : (...args: Arguments) => IValidation<Output>
659
+ : never;
660
+
661
+ /**
662
+ * @internal
663
+ */
664
+ function validateParameters(): never {
665
+ halt("validateReturn");
666
+ }
667
+ const validateParametersPure = /** @__PURE__ */ Object.assign<
668
+ typeof validateParameters,
669
+ {}
670
+ >(validateParameters, /** @__PURE__ */ Namespace.validate());
671
+ export { validateParametersPure as validateParameters };
672
+
673
+ /**
674
+ * Validates return value.
675
+ *
676
+ * Validates a function, by wrapping the function and checking its return value through
677
+ * {@link validate} function. If the return value does not match the expected type, it
678
+ * returns {@link IValidation.IError} typed object. Otherwise there's no type error,
679
+ * it returns {@link IValidation.ISuccess} typed object instead.
680
+ *
681
+ * For reference, {@link IValidation.IError.path} would be a little bit different with
682
+ * individual {@link validate} function. If the {@link IValidation.IError} occurs from
683
+ * the return value, the path would start from `$input.return`.
684
+ *
685
+ * By the way, if what you want is not finding every type errors, but just finding
686
+ * the 1st type error, then use {@link assertReturn} instead. Otherwise, what you want
687
+ * is not only validating return value, but also validating parameters, you can use
688
+ * {@link validateFunction} instead.
689
+ *
690
+ * On the other hand, if you don't want to allow any superfluous properties, utilize
691
+ * {@link validateEqualsReturn} or {@link assertEqualsReturn} instead.
692
+ *
693
+ * @template T Target function type
694
+ * @param func Target function to validate
695
+ * @returns The wrapper function with type validations
696
+ *
697
+ * @author Jeongho Nam - https://github.com/samchon
698
+ */
699
+ function validateReturn<T extends (...args: any[]) => any>(
700
+ func: T,
701
+ ): T extends (...args: infer Arguments) => infer Output
702
+ ? Output extends Promise<infer R>
703
+ ? (...args: Arguments) => Promise<IValidation<R>>
704
+ : (...args: Arguments) => IValidation<Output>
705
+ : never;
706
+
707
+ /**
708
+ * @internal
709
+ */
710
+ function validateReturn(): never {
711
+ halt("validateReturn");
712
+ }
713
+ const validateReturnPure = /** @__PURE__ */ Object.assign<
714
+ typeof validateReturn,
715
+ {}
716
+ >(validateReturn, /** @__PURE__ */ Namespace.validate());
717
+ export { validateReturnPure as validateReturn };
718
+
719
+ /**
720
+ * Validates a function with strict equality.
721
+ *
722
+ * Validates a function with strict equality, by wrapping the function and checking
723
+ * its parameters and return value through {@link validateEquals} function. If some
724
+ * parameter or return value does not match the expected type, it returns
725
+ * {@link IValidation.IError} typed object. Otherwise there's no type error, it
726
+ * returns {@link IValidation.ISuccess} typed object instead.
727
+ *
728
+ * For reference, {@link IValidation.IError.path} would be a little bit different with
729
+ * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
730
+ * from some parameter, the path would start from `$input.parameters[number]`. Otherwise
731
+ * the path would start from `$input.return`.
732
+ *
733
+ * - `$input.parameters[0].~`
734
+ * - `$input.return.~`
735
+ *
736
+ * By the way, if what you want is not finding every type errors, but just finding
737
+ * the 1st type error, then use {@link assertEqualsFunction} instead. Otherwise, what
738
+ * you want is just validating parameters or return value only, you can use
739
+ * {@link validateEqualsParameters} or {@link validateEqualsReturn} instead.
740
+ *
741
+ * On the other hand, if you want to allow any superfluous properties, utilize
742
+ * {@link validateFunction} or {@link assertFunction} instead.
743
+ *
744
+ * @template T Target function type
745
+ * @param func Target function to validate
746
+ * @returns The wrapper function with type validations
747
+ *
748
+ * @author Jeongho Nam - https://github.com/samchon
749
+ */
750
+ function validateEqualsFunction<T extends (...args: any[]) => any>(
751
+ func: T,
752
+ ): T extends (...args: infer Arguments) => infer Output
753
+ ? Output extends Promise<infer R>
754
+ ? (...args: Arguments) => Promise<IValidation<R>>
755
+ : (...args: Arguments) => IValidation<Output>
756
+ : never;
757
+
758
+ /**
759
+ * @internal
760
+ */
761
+ function validateEqualsFunction(): never {
762
+ halt("validateEqualsFunction");
763
+ }
764
+ const validateEqualsFunctionPure = /** @__PURE__ */ Object.assign<
765
+ typeof validateEqualsFunction,
766
+ {}
767
+ >(validateEqualsFunction, /** @__PURE__ */ Namespace.validate());
768
+ export { validateEqualsFunctionPure as validateEqualsFunction };
769
+
770
+ /**
771
+ * Validates parameters with strict equality.
772
+ *
773
+ * Validates a function, by wrapping the function and checking its parameters through
774
+ * {@link validateEquals} function. If some parameter does not match the expected type,
775
+ * it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
776
+ * it returns {@link IValidation.ISuccess} typed object instead.
777
+ *
778
+ * For reference, {@link IValidation.IError.path} would be a little bit different with
779
+ * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
780
+ * from some parameter, the path would start from `$input.parameters[number]`.
781
+ *
782
+ * By the way, if what you want is not finding every type errors, but just finding
783
+ * the 1st type error, then use {@link assertEqualsParameters} instead. Otherwise,
784
+ * what you want is not only validating parameters, but also validating return value,
785
+ * you can use {@link validateEqualsFunction} instead.
786
+ *
787
+ * On the other hand, if you want to allow any superfluous properties, utilize
788
+ * {@link validateParameters} or {@link assertParameters} instead.
789
+ *
790
+ * @template T Target function type
791
+ * @param func Target function to validate
792
+ * @returns The wrapper function with type validations
793
+ *
794
+ * @author Jeongho Nam - https://github.com/samchon
795
+ */
796
+ function validateEqualsParameters<T extends (...args: any[]) => any>(
797
+ func: T,
798
+ ): T extends (...args: infer Arguments) => infer Output
799
+ ? Output extends Promise<infer R>
800
+ ? (...args: Arguments) => Promise<IValidation<R>>
801
+ : (...args: Arguments) => IValidation<Output>
802
+ : never;
803
+
804
+ /**
805
+ * @internal
806
+ */
807
+ function validateEqualsParameters(): never {
808
+ halt("validateEqualsParameters");
809
+ }
810
+ const validateEqualsParametersPure = /** @__PURE__ */ Object.assign<
811
+ typeof validateEqualsParameters,
812
+ {}
813
+ >(validateEqualsParameters, /** @__PURE__ */ Namespace.validate());
814
+ export { validateEqualsParametersPure as validateEqualsParameters };
815
+
816
+ /**
817
+ * Validates return value with strict equality.
818
+ *
819
+ * Validates a function, by wrapping the function and checking its return value through
820
+ * {@link validateEquals} function. If the return value does not match the expected type,
821
+ * it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
822
+ * it returns {@link IValidation.ISuccess} typed object instead.
823
+ *
824
+ * For reference, {@link IValidation.IError.path} would be a little bit different with
825
+ * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
826
+ * from the return value, the path would start from `$input.return`.
827
+ *
828
+ * By the way, if what you want is not finding every type errors, but just finding
829
+ * the 1st type error, then use {@link assertEqualsReturn} instead. Otherwise, what you
830
+ * want is not only validating return value, but also validating parameters, you can use
831
+ * {@link validateEqualsFunction} instead.
832
+ *
833
+ * On the other hand, if you want to allow any superfluous properties, utilize
834
+ * {@link validateReturn} or {@link assertReturn} instead.
835
+ *
836
+ * @template T Target function type
837
+ * @param func Target function to validate
838
+ * @returns The wrapper function with type validations
839
+ *
840
+ * @author Jeongho Nam - https://github.com/samchon
841
+ */
842
+ function validateEqualsReturn<T extends (...args: any[]) => any>(
843
+ func: T,
844
+ ): T extends (...args: infer Arguments) => infer Output
845
+ ? Output extends Promise<infer R>
846
+ ? (...args: Arguments) => Promise<IValidation<R>>
847
+ : (...args: Arguments) => IValidation<Output>
848
+ : never;
849
+
850
+ /**
851
+ * @internal
852
+ */
853
+ function validateEqualsReturn(): never {
854
+ halt("validateEqualsReturn");
855
+ }
856
+ const validateEqualsReturnPure = /** @__PURE__ */ Object.assign<
857
+ typeof validateEqualsReturn,
858
+ {}
859
+ >(validateEqualsReturn, /** @__PURE__ */ Namespace.validate());
860
+ export { validateEqualsReturnPure as validateEqualsReturn };
565
861
 
566
862
  /* -----------------------------------------------------------
567
863
  HALTER