typia 9.7.1 → 10.0.0-dev.20251107

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 (424) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +153 -153
  3. package/lib/AssertionGuard.d.mts +27 -25
  4. package/lib/AssertionGuard.d.ts +27 -25
  5. package/lib/CamelCase.d.mts +1 -1
  6. package/lib/CamelCase.d.ts +1 -1
  7. package/lib/IRandomGenerator.d.mts +44 -42
  8. package/lib/IRandomGenerator.d.ts +44 -42
  9. package/lib/IReadableURLSearchParams.d.mts +2 -2
  10. package/lib/IReadableURLSearchParams.d.ts +2 -2
  11. package/lib/PascalCase.d.mts +1 -1
  12. package/lib/PascalCase.d.ts +1 -1
  13. package/lib/Primitive.d.mts +20 -22
  14. package/lib/Primitive.d.ts +20 -22
  15. package/lib/Resolved.d.mts +16 -18
  16. package/lib/Resolved.d.ts +16 -18
  17. package/lib/SnakeCase.d.mts +3 -2
  18. package/lib/SnakeCase.d.ts +3 -2
  19. package/lib/TypeGuardError.d.mts +88 -61
  20. package/lib/TypeGuardError.d.ts +88 -61
  21. package/lib/TypeGuardError.js +40 -29
  22. package/lib/TypeGuardError.js.map +1 -1
  23. package/lib/TypeGuardError.mjs +70 -48
  24. package/lib/factories/MetadataCollection.js +4 -12
  25. package/lib/factories/MetadataCollection.js.map +1 -1
  26. package/lib/factories/MetadataCollection.mjs +4 -12
  27. package/lib/factories/MetadataCommentTagFactory.js +5 -15
  28. package/lib/factories/MetadataCommentTagFactory.js.map +1 -1
  29. package/lib/factories/MetadataCommentTagFactory.mjs +5 -15
  30. package/lib/factories/MetadataFactory.js +1 -3
  31. package/lib/factories/MetadataFactory.js.map +1 -1
  32. package/lib/factories/MetadataFactory.mjs +1 -3
  33. package/lib/factories/ProtobufFactory.js +2 -4
  34. package/lib/factories/ProtobufFactory.js.map +1 -1
  35. package/lib/factories/ProtobufFactory.mjs +2 -4
  36. package/lib/functional.d.mts +196 -195
  37. package/lib/functional.d.ts +196 -195
  38. package/lib/functional.js +18 -54
  39. package/lib/functional.js.map +1 -1
  40. package/lib/functional.mjs +18 -54
  41. package/lib/http.d.mts +303 -319
  42. package/lib/http.d.ts +303 -319
  43. package/lib/http.js +26 -78
  44. package/lib/http.js.map +1 -1
  45. package/lib/http.mjs +26 -78
  46. package/lib/internal/_ProtobufReader.d.mts +3 -9
  47. package/lib/internal/_ProtobufReader.d.ts +3 -9
  48. package/lib/internal/_ProtobufReader.js.map +1 -1
  49. package/lib/internal/_ProtobufReader.mjs +3 -9
  50. package/lib/internal/_ProtobufSizer.d.mts +4 -12
  51. package/lib/internal/_ProtobufSizer.d.ts +4 -12
  52. package/lib/internal/_ProtobufSizer.js.map +1 -1
  53. package/lib/internal/_ProtobufSizer.mjs +4 -12
  54. package/lib/internal/_ProtobufWriter.d.mts +5 -15
  55. package/lib/internal/_ProtobufWriter.d.ts +5 -15
  56. package/lib/internal/_ProtobufWriter.js.map +1 -1
  57. package/lib/internal/_ProtobufWriter.mjs +5 -15
  58. package/lib/internal/_jsonStringifyString.d.mts +4 -4
  59. package/lib/internal/_jsonStringifyString.d.ts +4 -4
  60. package/lib/internal/_jsonStringifyString.js +4 -4
  61. package/lib/internal/_jsonStringifyString.mjs +4 -4
  62. package/lib/json.d.mts +174 -195
  63. package/lib/json.d.ts +174 -195
  64. package/lib/json.js +16 -48
  65. package/lib/json.js.map +1 -1
  66. package/lib/json.mjs +16 -48
  67. package/lib/llm.d.mts +275 -192
  68. package/lib/llm.d.ts +275 -192
  69. package/lib/llm.js +4 -12
  70. package/lib/llm.js.map +1 -1
  71. package/lib/llm.mjs +4 -12
  72. package/lib/misc.d.mts +149 -172
  73. package/lib/misc.d.ts +149 -172
  74. package/lib/misc.js +17 -51
  75. package/lib/misc.js.map +1 -1
  76. package/lib/misc.mjs +17 -51
  77. package/lib/module.d.mts +263 -275
  78. package/lib/module.d.ts +263 -275
  79. package/lib/module.js +18 -54
  80. package/lib/module.js.map +1 -1
  81. package/lib/module.mjs +18 -54
  82. package/lib/notations.d.mts +153 -174
  83. package/lib/notations.d.ts +153 -174
  84. package/lib/notations.js +24 -72
  85. package/lib/notations.js.map +1 -1
  86. package/lib/notations.mjs +24 -72
  87. package/lib/programmers/FeatureProgrammer.d.mts +19 -41
  88. package/lib/programmers/FeatureProgrammer.d.ts +19 -41
  89. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  90. package/lib/programmers/ImportProgrammer.js +3 -9
  91. package/lib/programmers/ImportProgrammer.js.map +1 -1
  92. package/lib/programmers/ImportProgrammer.mjs +3 -9
  93. package/lib/programmers/RandomProgrammer.js +6 -0
  94. package/lib/programmers/RandomProgrammer.js.map +1 -1
  95. package/lib/programmers/RandomProgrammer.mjs +6 -0
  96. package/lib/programmers/helpers/ProtobufWire.d.mts +13 -13
  97. package/lib/programmers/helpers/ProtobufWire.d.ts +13 -13
  98. package/lib/programmers/internal/check_array_length.js +2 -6
  99. package/lib/programmers/internal/check_array_length.js.map +1 -1
  100. package/lib/programmers/internal/check_array_length.mjs +2 -6
  101. package/lib/programmers/internal/check_bigint.js +2 -6
  102. package/lib/programmers/internal/check_bigint.js.map +1 -1
  103. package/lib/programmers/internal/check_bigint.mjs +2 -6
  104. package/lib/programmers/internal/check_dynamic_key.js +2 -6
  105. package/lib/programmers/internal/check_dynamic_key.js.map +1 -1
  106. package/lib/programmers/internal/check_dynamic_key.mjs +2 -6
  107. package/lib/programmers/internal/check_dynamic_properties.js +3 -9
  108. package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
  109. package/lib/programmers/internal/check_dynamic_properties.mjs +3 -9
  110. package/lib/programmers/internal/check_everything.js +1 -3
  111. package/lib/programmers/internal/check_everything.js.map +1 -1
  112. package/lib/programmers/internal/check_everything.mjs +1 -3
  113. package/lib/programmers/internal/check_native.js +2 -6
  114. package/lib/programmers/internal/check_native.js.map +1 -1
  115. package/lib/programmers/internal/check_native.mjs +2 -6
  116. package/lib/programmers/internal/check_number.js +2 -6
  117. package/lib/programmers/internal/check_number.js.map +1 -1
  118. package/lib/programmers/internal/check_number.mjs +2 -6
  119. package/lib/programmers/internal/check_object.js +2 -6
  120. package/lib/programmers/internal/check_object.js.map +1 -1
  121. package/lib/programmers/internal/check_object.mjs +2 -6
  122. package/lib/programmers/internal/check_string.js +2 -6
  123. package/lib/programmers/internal/check_string.js.map +1 -1
  124. package/lib/programmers/internal/check_string.mjs +2 -6
  125. package/lib/programmers/internal/check_template.js +1 -3
  126. package/lib/programmers/internal/check_template.js.map +1 -1
  127. package/lib/programmers/internal/check_template.mjs +1 -3
  128. package/lib/programmers/internal/check_union_array_like.js +1 -3
  129. package/lib/programmers/internal/check_union_array_like.js.map +1 -1
  130. package/lib/programmers/internal/check_union_array_like.mjs +1 -3
  131. package/lib/programmers/internal/decode_union_object.js +2 -6
  132. package/lib/programmers/internal/decode_union_object.js.map +1 -1
  133. package/lib/programmers/internal/decode_union_object.mjs +2 -6
  134. package/lib/programmers/internal/feature_object_entries.js +1 -3
  135. package/lib/programmers/internal/feature_object_entries.js.map +1 -1
  136. package/lib/programmers/internal/feature_object_entries.mjs +1 -3
  137. package/lib/programmers/internal/json_schema_escaped.js +2 -6
  138. package/lib/programmers/internal/json_schema_escaped.js.map +1 -1
  139. package/lib/programmers/internal/json_schema_escaped.mjs +2 -6
  140. package/lib/programmers/internal/json_schema_object.js +3 -9
  141. package/lib/programmers/internal/json_schema_object.js.map +1 -1
  142. package/lib/programmers/internal/json_schema_object.mjs +3 -9
  143. package/lib/programmers/internal/json_schema_station.d.mts +2 -2
  144. package/lib/programmers/internal/json_schema_station.d.ts +2 -2
  145. package/lib/programmers/internal/metadata_to_pattern.js +1 -3
  146. package/lib/programmers/internal/metadata_to_pattern.js.map +1 -1
  147. package/lib/programmers/internal/metadata_to_pattern.mjs +1 -3
  148. package/lib/programmers/internal/postfix_of_tuple.js +1 -3
  149. package/lib/programmers/internal/postfix_of_tuple.js.map +1 -1
  150. package/lib/programmers/internal/postfix_of_tuple.mjs +1 -3
  151. package/lib/programmers/internal/prune_object_properties.js +1 -3
  152. package/lib/programmers/internal/prune_object_properties.js.map +1 -1
  153. package/lib/programmers/internal/prune_object_properties.mjs +1 -3
  154. package/lib/programmers/internal/stringify_dynamic_properties.js +2 -6
  155. package/lib/programmers/internal/stringify_dynamic_properties.js.map +1 -1
  156. package/lib/programmers/internal/stringify_dynamic_properties.mjs +2 -6
  157. package/lib/programmers/internal/stringify_native.js +1 -3
  158. package/lib/programmers/internal/stringify_native.js.map +1 -1
  159. package/lib/programmers/internal/stringify_native.mjs +1 -3
  160. package/lib/programmers/internal/stringify_regular_properties.js +2 -6
  161. package/lib/programmers/internal/stringify_regular_properties.js.map +1 -1
  162. package/lib/programmers/internal/stringify_regular_properties.mjs +2 -6
  163. package/lib/programmers/internal/template_to_pattern.js +1 -3
  164. package/lib/programmers/internal/template_to_pattern.js.map +1 -1
  165. package/lib/programmers/internal/template_to_pattern.mjs +1 -3
  166. package/lib/programmers/internal/wrap_metadata_rest_tuple.js +1 -3
  167. package/lib/programmers/internal/wrap_metadata_rest_tuple.js.map +1 -1
  168. package/lib/programmers/internal/wrap_metadata_rest_tuple.mjs +1 -3
  169. package/lib/programmers/json/JsonStringifyProgrammer.js +2 -2
  170. package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
  171. package/lib/programmers/json/JsonStringifyProgrammer.mjs +2 -2
  172. package/lib/programmers/llm/LlmApplicationProgrammer.js +5 -1
  173. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  174. package/lib/programmers/llm/LlmApplicationProgrammer.mjs +5 -1
  175. package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -4
  176. package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
  177. package/lib/programmers/llm/LlmSchemaProgrammer.mjs +1 -35
  178. package/lib/protobuf.d.mts +290 -297
  179. package/lib/protobuf.d.ts +290 -297
  180. package/lib/protobuf.js +17 -51
  181. package/lib/protobuf.js.map +1 -1
  182. package/lib/protobuf.mjs +17 -51
  183. package/lib/reflect.d.mts +2 -4
  184. package/lib/reflect.d.ts +2 -4
  185. package/lib/reflect.js +1 -3
  186. package/lib/reflect.js.map +1 -1
  187. package/lib/reflect.mjs +1 -3
  188. package/lib/schemas/json/IJsonApplication.d.mts +4 -4
  189. package/lib/schemas/json/IJsonApplication.d.ts +4 -4
  190. package/lib/schemas/json/IJsonSchemaCollection.d.mts +73 -56
  191. package/lib/schemas/json/IJsonSchemaCollection.d.ts +73 -56
  192. package/lib/schemas/json/IJsonSchemaUnit.d.mts +83 -70
  193. package/lib/schemas/json/IJsonSchemaUnit.d.ts +83 -70
  194. package/lib/schemas/metadata/Metadata.d.mts +1 -3
  195. package/lib/schemas/metadata/Metadata.d.ts +1 -3
  196. package/lib/schemas/metadata/Metadata.js +9 -27
  197. package/lib/schemas/metadata/Metadata.js.map +1 -1
  198. package/lib/schemas/metadata/Metadata.mjs +9 -27
  199. package/lib/schemas/metadata/MetadataAliasType.d.mts +1 -3
  200. package/lib/schemas/metadata/MetadataAliasType.d.ts +1 -3
  201. package/lib/schemas/metadata/MetadataAliasType.js +3 -9
  202. package/lib/schemas/metadata/MetadataAliasType.js.map +1 -1
  203. package/lib/schemas/metadata/MetadataAliasType.mjs +3 -9
  204. package/lib/schemas/metadata/MetadataApplication.d.mts +1 -3
  205. package/lib/schemas/metadata/MetadataApplication.d.ts +1 -3
  206. package/lib/schemas/metadata/MetadataApplication.js +2 -6
  207. package/lib/schemas/metadata/MetadataApplication.js.map +1 -1
  208. package/lib/schemas/metadata/MetadataApplication.mjs +2 -6
  209. package/lib/schemas/metadata/MetadataArray.d.mts +1 -3
  210. package/lib/schemas/metadata/MetadataArray.d.ts +1 -3
  211. package/lib/schemas/metadata/MetadataArray.js +1 -3
  212. package/lib/schemas/metadata/MetadataArray.js.map +1 -1
  213. package/lib/schemas/metadata/MetadataArray.mjs +1 -3
  214. package/lib/schemas/metadata/MetadataArrayType.d.mts +1 -3
  215. package/lib/schemas/metadata/MetadataArrayType.d.ts +1 -3
  216. package/lib/schemas/metadata/MetadataArrayType.js +3 -9
  217. package/lib/schemas/metadata/MetadataArrayType.js.map +1 -1
  218. package/lib/schemas/metadata/MetadataArrayType.mjs +3 -9
  219. package/lib/schemas/metadata/MetadataAtomic.js +1 -3
  220. package/lib/schemas/metadata/MetadataAtomic.js.map +1 -1
  221. package/lib/schemas/metadata/MetadataAtomic.mjs +1 -3
  222. package/lib/schemas/metadata/MetadataEscaped.d.mts +1 -3
  223. package/lib/schemas/metadata/MetadataEscaped.d.ts +1 -3
  224. package/lib/schemas/metadata/MetadataEscaped.js +3 -9
  225. package/lib/schemas/metadata/MetadataEscaped.js.map +1 -1
  226. package/lib/schemas/metadata/MetadataEscaped.mjs +3 -9
  227. package/lib/schemas/metadata/MetadataFunction.d.mts +1 -3
  228. package/lib/schemas/metadata/MetadataFunction.d.ts +1 -3
  229. package/lib/schemas/metadata/MetadataFunction.js +2 -6
  230. package/lib/schemas/metadata/MetadataFunction.js.map +1 -1
  231. package/lib/schemas/metadata/MetadataFunction.mjs +2 -6
  232. package/lib/schemas/metadata/MetadataObject.d.mts +1 -3
  233. package/lib/schemas/metadata/MetadataObject.d.ts +1 -3
  234. package/lib/schemas/metadata/MetadataObject.js +1 -3
  235. package/lib/schemas/metadata/MetadataObject.js.map +1 -1
  236. package/lib/schemas/metadata/MetadataObject.mjs +1 -3
  237. package/lib/schemas/metadata/MetadataObjectType.d.mts +1 -3
  238. package/lib/schemas/metadata/MetadataObjectType.d.ts +1 -3
  239. package/lib/schemas/metadata/MetadataObjectType.js +5 -15
  240. package/lib/schemas/metadata/MetadataObjectType.js.map +1 -1
  241. package/lib/schemas/metadata/MetadataObjectType.mjs +6 -18
  242. package/lib/schemas/metadata/MetadataParameter.js +1 -3
  243. package/lib/schemas/metadata/MetadataParameter.js.map +1 -1
  244. package/lib/schemas/metadata/MetadataParameter.mjs +1 -3
  245. package/lib/schemas/metadata/MetadataProperty.d.mts +1 -3
  246. package/lib/schemas/metadata/MetadataProperty.d.ts +1 -3
  247. package/lib/schemas/metadata/MetadataProperty.js +3 -9
  248. package/lib/schemas/metadata/MetadataProperty.js.map +1 -1
  249. package/lib/schemas/metadata/MetadataProperty.mjs +3 -9
  250. package/lib/schemas/metadata/MetadataTemplate.js +1 -3
  251. package/lib/schemas/metadata/MetadataTemplate.js.map +1 -1
  252. package/lib/schemas/metadata/MetadataTemplate.mjs +1 -3
  253. package/lib/schemas/metadata/MetadataTuple.d.mts +1 -3
  254. package/lib/schemas/metadata/MetadataTuple.d.ts +1 -3
  255. package/lib/schemas/metadata/MetadataTuple.js +2 -6
  256. package/lib/schemas/metadata/MetadataTuple.js.map +1 -1
  257. package/lib/schemas/metadata/MetadataTuple.mjs +2 -6
  258. package/lib/schemas/metadata/MetadataTupleType.js +2 -6
  259. package/lib/schemas/metadata/MetadataTupleType.js.map +1 -1
  260. package/lib/schemas/metadata/MetadataTupleType.mjs +3 -9
  261. package/lib/tags/Constant.d.mts +16 -16
  262. package/lib/tags/Constant.d.ts +16 -16
  263. package/lib/tags/ContentMediaType.d.mts +7 -7
  264. package/lib/tags/ContentMediaType.d.ts +7 -7
  265. package/lib/tags/Default.d.mts +19 -19
  266. package/lib/tags/Default.d.ts +19 -19
  267. package/lib/tags/Example.d.mts +18 -18
  268. package/lib/tags/Example.d.ts +18 -18
  269. package/lib/tags/Examples.d.mts +23 -23
  270. package/lib/tags/Examples.d.ts +23 -23
  271. package/lib/tags/ExclusiveMaximum.d.mts +8 -5
  272. package/lib/tags/ExclusiveMaximum.d.ts +8 -5
  273. package/lib/tags/ExclusiveMinimum.d.mts +8 -5
  274. package/lib/tags/ExclusiveMinimum.d.ts +8 -5
  275. package/lib/tags/Format.d.mts +12 -8
  276. package/lib/tags/Format.d.ts +12 -8
  277. package/lib/tags/JsonSchemaPlugin.d.mts +20 -18
  278. package/lib/tags/JsonSchemaPlugin.d.ts +20 -18
  279. package/lib/tags/MaxItems.d.mts +9 -9
  280. package/lib/tags/MaxItems.d.ts +9 -9
  281. package/lib/tags/MaxLength.d.mts +6 -5
  282. package/lib/tags/MaxLength.d.ts +6 -5
  283. package/lib/tags/Maximum.d.mts +9 -7
  284. package/lib/tags/Maximum.d.ts +9 -7
  285. package/lib/tags/MinItems.d.mts +9 -9
  286. package/lib/tags/MinItems.d.ts +9 -9
  287. package/lib/tags/MinLength.d.mts +6 -5
  288. package/lib/tags/MinLength.d.ts +6 -5
  289. package/lib/tags/Minimum.d.mts +9 -7
  290. package/lib/tags/Minimum.d.ts +9 -7
  291. package/lib/tags/MultipleOf.d.mts +10 -7
  292. package/lib/tags/MultipleOf.d.ts +10 -7
  293. package/lib/tags/Pattern.d.mts +7 -4
  294. package/lib/tags/Pattern.d.ts +7 -4
  295. package/lib/tags/Sequence.d.mts +19 -17
  296. package/lib/tags/Sequence.d.ts +19 -17
  297. package/lib/tags/TagBase.d.mts +21 -28
  298. package/lib/tags/TagBase.d.ts +21 -28
  299. package/lib/tags/Type.d.mts +12 -11
  300. package/lib/tags/Type.d.ts +12 -11
  301. package/lib/tags/UniqueItems.d.mts +10 -9
  302. package/lib/tags/UniqueItems.d.ts +10 -9
  303. package/lib/tags/internal/FormatCheatSheet.d.mts +1 -3
  304. package/lib/tags/internal/FormatCheatSheet.d.ts +1 -3
  305. package/lib/tags/internal/FormatCheatSheet.js +1 -3
  306. package/lib/tags/internal/FormatCheatSheet.js.map +1 -1
  307. package/lib/tags/internal/FormatCheatSheet.mjs +1 -3
  308. package/lib/transformers/ITransformOptions.d.mts +27 -19
  309. package/lib/transformers/ITransformOptions.d.ts +27 -19
  310. package/lib/transformers/ImportTransformer.js +5 -10
  311. package/lib/transformers/ImportTransformer.js.map +1 -1
  312. package/lib/transformers/ImportTransformer.mjs +5 -10
  313. package/lib/transformers/NoTransformConfigurationError.js +1 -3
  314. package/lib/transformers/NoTransformConfigurationError.js.map +1 -1
  315. package/lib/transformers/NoTransformConfigurationError.mjs +1 -3
  316. package/lib/transformers/features/llm/LlmApplicationTransformer.js +1 -3
  317. package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
  318. package/lib/transformers/features/llm/LlmApplicationTransformer.mjs +1 -3
  319. package/lib/typings/Equal.d.mts +6 -6
  320. package/lib/typings/Equal.d.ts +6 -6
  321. package/package.json +121 -120
  322. package/src/AssertionGuard.ts +41 -39
  323. package/src/CamelCase.ts +75 -75
  324. package/src/IRandomGenerator.ts +337 -335
  325. package/src/IReadableURLSearchParams.ts +9 -9
  326. package/src/PascalCase.ts +71 -71
  327. package/src/Primitive.ts +90 -92
  328. package/src/Resolved.ts +72 -74
  329. package/src/SnakeCase.ts +127 -126
  330. package/src/TypeGuardError.ts +216 -179
  331. package/src/factories/MetadataCollection.ts +270 -278
  332. package/src/factories/MetadataCommentTagFactory.ts +632 -648
  333. package/src/factories/MetadataFactory.ts +402 -404
  334. package/src/factories/ProtobufFactory.ts +873 -875
  335. package/src/functional.ts +705 -740
  336. package/src/http.ts +972 -1040
  337. package/src/internal/_ProtobufReader.ts +188 -194
  338. package/src/internal/_ProtobufSizer.ts +137 -145
  339. package/src/internal/_ProtobufWriter.ts +135 -145
  340. package/src/internal/_jsonStringifyString.ts +42 -42
  341. package/src/json.ts +643 -696
  342. package/src/llm.ts +615 -540
  343. package/src/misc.ts +594 -651
  344. package/src/module.ts +889 -937
  345. package/src/notations.ts +751 -820
  346. package/src/programmers/FeatureProgrammer.ts +605 -627
  347. package/src/programmers/ImportProgrammer.ts +179 -185
  348. package/src/programmers/RandomProgrammer.ts +1195 -1190
  349. package/src/programmers/helpers/ProtobufWire.ts +34 -34
  350. package/src/programmers/internal/check_array_length.ts +43 -47
  351. package/src/programmers/internal/check_bigint.ts +46 -50
  352. package/src/programmers/internal/check_dynamic_key.ts +197 -201
  353. package/src/programmers/internal/check_dynamic_properties.ts +231 -237
  354. package/src/programmers/internal/check_everything.ts +21 -23
  355. package/src/programmers/internal/check_native.ts +23 -27
  356. package/src/programmers/internal/check_number.ts +108 -112
  357. package/src/programmers/internal/check_object.ts +72 -78
  358. package/src/programmers/internal/check_string.ts +46 -50
  359. package/src/programmers/internal/check_template.ts +46 -48
  360. package/src/programmers/internal/check_union_array_like.ts +331 -335
  361. package/src/programmers/internal/decode_union_object.ts +110 -116
  362. package/src/programmers/internal/feature_object_entries.ts +59 -61
  363. package/src/programmers/internal/json_schema_escaped.ts +78 -82
  364. package/src/programmers/internal/json_schema_object.ts +150 -158
  365. package/src/programmers/internal/json_schema_station.ts +2 -2
  366. package/src/programmers/internal/metadata_to_pattern.ts +40 -42
  367. package/src/programmers/internal/postfix_of_tuple.ts +3 -5
  368. package/src/programmers/internal/prune_object_properties.ts +69 -71
  369. package/src/programmers/internal/stringify_dynamic_properties.ts +158 -162
  370. package/src/programmers/internal/stringify_native.ts +5 -7
  371. package/src/programmers/internal/stringify_regular_properties.ts +77 -81
  372. package/src/programmers/internal/template_to_pattern.ts +21 -23
  373. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +21 -23
  374. package/src/programmers/json/JsonStringifyProgrammer.ts +1124 -1124
  375. package/src/programmers/llm/LlmApplicationProgrammer.ts +10 -1
  376. package/src/programmers/llm/LlmSchemaProgrammer.ts +2 -7
  377. package/src/protobuf.ts +820 -861
  378. package/src/reflect.ts +46 -50
  379. package/src/schemas/json/IJsonApplication.ts +77 -77
  380. package/src/schemas/json/IJsonSchemaCollection.ts +212 -195
  381. package/src/schemas/json/IJsonSchemaUnit.ts +263 -250
  382. package/src/schemas/metadata/IMetadataTypeTag.ts +14 -16
  383. package/src/schemas/metadata/Metadata.ts +669 -687
  384. package/src/schemas/metadata/MetadataAliasType.ts +57 -63
  385. package/src/schemas/metadata/MetadataApplication.ts +40 -44
  386. package/src/schemas/metadata/MetadataArray.ts +47 -49
  387. package/src/schemas/metadata/MetadataArrayType.ts +51 -57
  388. package/src/schemas/metadata/MetadataAtomic.ts +85 -87
  389. package/src/schemas/metadata/MetadataEscaped.ts +45 -51
  390. package/src/schemas/metadata/MetadataFunction.ts +45 -49
  391. package/src/schemas/metadata/MetadataObject.ts +46 -48
  392. package/src/schemas/metadata/MetadataObjectType.ts +137 -149
  393. package/src/schemas/metadata/MetadataParameter.ts +52 -54
  394. package/src/schemas/metadata/MetadataProperty.ts +53 -59
  395. package/src/schemas/metadata/MetadataTemplate.ts +78 -80
  396. package/src/schemas/metadata/MetadataTuple.ts +28 -32
  397. package/src/schemas/metadata/MetadataTupleType.ts +61 -67
  398. package/src/tags/Constant.ts +47 -47
  399. package/src/tags/ContentMediaType.ts +27 -27
  400. package/src/tags/Default.ts +52 -52
  401. package/src/tags/Example.ts +56 -56
  402. package/src/tags/Examples.ts +56 -56
  403. package/src/tags/ExclusiveMaximum.ts +44 -41
  404. package/src/tags/ExclusiveMinimum.ts +44 -41
  405. package/src/tags/Format.ts +78 -74
  406. package/src/tags/JsonSchemaPlugin.ts +36 -34
  407. package/src/tags/MaxItems.ts +31 -31
  408. package/src/tags/MaxLength.ts +25 -24
  409. package/src/tags/Maximum.ts +39 -37
  410. package/src/tags/MinItems.ts +31 -31
  411. package/src/tags/MinLength.ts +25 -24
  412. package/src/tags/Minimum.ts +39 -37
  413. package/src/tags/MultipleOf.ts +42 -39
  414. package/src/tags/Pattern.ts +49 -46
  415. package/src/tags/Sequence.ts +37 -35
  416. package/src/tags/TagBase.ts +102 -109
  417. package/src/tags/Type.ts +64 -63
  418. package/src/tags/UniqueItems.ts +34 -33
  419. package/src/tags/internal/FormatCheatSheet.ts +71 -73
  420. package/src/transformers/ITransformOptions.ts +70 -62
  421. package/src/transformers/ImportTransformer.ts +253 -258
  422. package/src/transformers/NoTransformConfigurationError.ts +16 -18
  423. package/src/transformers/features/llm/LlmApplicationTransformer.ts +224 -226
  424. package/src/typings/Equal.ts +18 -18
package/src/functional.ts CHANGED
@@ -1,740 +1,705 @@
1
- import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
2
-
3
- import { IValidation } from "./IValidation";
4
- import { TypeGuardError } from "./TypeGuardError";
5
-
6
- /* ===========================================================
7
- FUNCTIONAL
8
- - ASSERT
9
- - IS
10
- - VALIDATE
11
- ==============================================================
12
- ASSERT
13
- ----------------------------------------------------------- */
14
- /**
15
- * Asserts a function.
16
- *
17
- * Asserts a function, by wrapping the function and checking its parameters and
18
- * return value through {@link assert} function. If some parameter or return value
19
- * does not match the expected type, it throws an {@link TypeGuardError} or a custom
20
- * error generated by the *errorFactory* parameter.
21
- *
22
- * For reference, {@link TypeGuardError.path} would be a little bit different with
23
- * individual {@link assert} function. If the {@link TypeGuardError} occurs from
24
- * some parameter, the path would start from `$input.parameters[number]`. Otherwise
25
- * the path would start from `$input.return`.
26
- *
27
- * - `$input.parameters[0].~`
28
- * - `$input.return.~`
29
- *
30
- * By the way, if what you want is not just finding the 1st type error through
31
- * assertion, but also finding every type errors, then use {@link validateFunction}
32
- * instead. Otherwise, what you want is just asserting parameters or return value
33
- * only, you can use {@link assertParameters} or {@link assertReturn} instead.
34
- *
35
- * On the other hand, if don't want to allow any superfluous properties, utilize
36
- * {@link assertEqualsFunction} or {@link validateEqualsFunction} instead.
37
- *
38
- * @template T Target function type
39
- * @param func Target function to assert
40
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
41
- * @returns The wrapper function with type assertions
42
- * @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
43
- *
44
- * @author Jeongho Nam - https://github.com/samchon
45
- */
46
- export function assertFunction<T extends (...args: any[]) => any>(
47
- func: T,
48
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
49
- ): T;
50
-
51
- /**
52
- * @internal
53
- */
54
- export function assertFunction(): never {
55
- NoTransformConfigurationError("functional.assertFunction");
56
- }
57
-
58
- /**
59
- * Asserts parameters.
60
- *
61
- * Asserts a function, by wrapping the function and checking its parameters through
62
- * {@link assert} function. If some parameter does not match the expected type, it
63
- * throws an {@link TypeGuardError} or a custom error generated by the *errorFactory*
64
- * parameter.
65
- *
66
- * For reference, {@link TypeGuardError.path} would be a little bit different with
67
- * individual {@link assert} function. If the {@link TypeGuardError} occurs from
68
- * some parameter, the path would start from `$input.parameters[number]`.
69
- *
70
- * By the way, if what you want is not just finding the 1st type error through
71
- * assertion, but also finding every type errors, then use {@link validateParameters}
72
- * instead. Otherwise, what you want is not only asserting parameters, but also
73
- * asserting return value, you can use {@link assertFunction} instead.
74
- *
75
- * On the other hand, if don't want to allow any superfluous properties, utilize
76
- * {@link assertEqualsParameters} or {@link validateEqualsParameters} instead.
77
- *
78
- * @template T Target function type
79
- * @param func Target function to assert
80
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
81
- * @returns The wrapper function with type assertions
82
- * @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
83
- *
84
- * @author Jeongho Nam - https://github.com/samchon
85
- */
86
- export function assertParameters<T extends (...args: any[]) => any>(
87
- func: T,
88
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
89
- ): T;
90
-
91
- /**
92
- * @internal
93
- */
94
- export function assertParameters(): never {
95
- NoTransformConfigurationError("functional.assertParameters");
96
- }
97
-
98
- /**
99
- * Asserts return value.
100
- *
101
- * Asserts a function, by wrapping the function and checking its return value through
102
- * {@link assert} function. If the return value does not match the expected type, it
103
- * throws an {@link TypeGuardError} or a custom error generated by the *errorFactory*
104
- * parameter.
105
- *
106
- * For reference, {@link TypeGuardError.path} would be a little bit different with
107
- * individual {@link assert} function. If the {@link TypeGuardError} occurs from
108
- * the return value, the path would start from `$input.return`.
109
- *
110
- * By the way, if what you want is not just finding the 1st type error through
111
- * assertion, but also finding every type errors, then use {@link validateReturn}
112
- * instead. Otherwise, what you want is not only asserting return value, but also
113
- * asserting parameters, you can use {@link assertFunction} instead.
114
- *
115
- * On the other hand, if don't want to allow any superfluous properties, utilize
116
- * {@link assertEqualsReturn} or {@link validateEqualsReturn} instead.
117
- *
118
- * @template T Target function type
119
- * @param func Target function to assert
120
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
121
- * @returns The wrapper function with type assertions
122
- * @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
123
- *
124
- * @author Jeongho Nam - https://github.com/samchon
125
- */
126
- export function assertReturn<T extends (...args: any[]) => any>(
127
- func: T,
128
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
129
- ): T;
130
-
131
- /**
132
- * @internal
133
- */
134
- export function assertReturn(): never {
135
- NoTransformConfigurationError("functional.assertReturn");
136
- }
137
-
138
- /**
139
- * Asserts a function with strict equality.
140
- *
141
- * Asserts a function with strict equality, by wrapping the function and checking
142
- * its parameters and return value through {@link assertEquals} function. If some
143
- * parameter or return value does not match the expected type, it throws an
144
- * {@link TypeGuardError} or a custom error generated by the *errorFactory* parameter.
145
- *
146
- * For reference, {@link TypeGuardError.path} would be a little bit different with
147
- * individual {@link assertEquals} function. If the {@link TypeGuardError} occurs from
148
- * some parameter, the path would start from `$input.parameters[number]`. Otherwise
149
- * the path would start from `$input.return`.
150
- *
151
- * - `$input.parameters[0].~`
152
- * - `$input.return.~`
153
- *
154
- * By the way, if what you want is not just finding the 1st type error through
155
- * assertion, but also finding every type errors, then use
156
- * {@link validateEqualsFunction} instead. Otherwise, what you want is just asserting
157
- * parameters or return value only, you can use {@link assertEqualsParameters} or
158
- * {@link assertEqualsReturn} instead.
159
- *
160
- * On the other hand, if you want to allow any superfluous properties, utilize
161
- * {@link assertFunction} or {@link validateFunction} instead.
162
- *
163
- * @template T Target function type
164
- * @param func Target function to assert
165
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
166
- * @returns The wrapper function with type assertions
167
- * @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
168
- *
169
- * @author Jeongho Nam - https://github.com/samchon
170
- */
171
- export function assertEqualsFunction<T extends (...args: any[]) => any>(
172
- func: T,
173
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
174
- ): T;
175
-
176
- /**
177
- * @internal
178
- */
179
- export function assertEqualsFunction(): never {
180
- NoTransformConfigurationError("functional.assertEqualsFunction");
181
- }
182
-
183
- /**
184
- * Asserts parameters with strict equality.
185
- *
186
- * Asserts a function, by wrapping the function and checking its parameters through
187
- * {@link assertEquals} function. If some parameter does not match the expected type,
188
- * it throws an {@link TypeGuardError} or a custom error generated by the *errorFactory*
189
- * parameter.
190
- *
191
- * For reference, {@link TypeGuardError.path} would be a little bit different with
192
- * individual {@link assertEquals} function. If the {@link TypeGuardError} occurs from
193
- * some parameter, the path would start from `$input.parameters[number]`.
194
- *
195
- * By the way, if what you want is not just finding the 1st type error through
196
- * assertion, but also finding every type errors, then use
197
- * {@link validateEqualsParameters} instead. Otherwise, what you want is not only
198
- * asserting parameters, but also asserting return value, you can use
199
- * {@link assertEqualsFunction} instead.
200
- *
201
- * On the other hand, if you want to allow any superfluous properties, utilize
202
- * {@link assertParameters} or {@link validateParameters} instead.
203
- *
204
- * @template T Target function type
205
- * @param func Target function to assert
206
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
207
- * @returns The wrapper function with type assertions
208
- * @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
209
- *
210
- * @author Jeongho Nam - https://github.com/samchon
211
- */
212
- export function assertEqualsParameters<T extends (...args: any[]) => any>(
213
- func: T,
214
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
215
- ): T;
216
-
217
- /**
218
- * @internal
219
- */
220
- export function assertEqualsParameters(): never {
221
- NoTransformConfigurationError("functional.assertEqualsParameters");
222
- }
223
-
224
- /**
225
- * Asserts return value with strict equality.
226
- *
227
- * Asserts a function, by wrapping the function and checking its return value through
228
- * {@link assertEquals} function. If the return value does not match the expected type,
229
- * it throws an {@link TypeGuardError} or a custom error generated by the *errorFactory*
230
- * parameter.
231
- *
232
- * For reference, {@link TypeGuardError.path} would be a little bit different with
233
- * individual {@link assertEquals} function. If the {@link TypeGuardError} occurs from
234
- * the return value, the path would start from `$input.return`.
235
- *
236
- * By the way, if what you want is not just finding the 1st type error through
237
- * assertion, but also finding every type errors, then use {@link validateEqualsReturn}
238
- * instead. Otherwise, what you want is not only asserting return value, but also
239
- * asserting parameters, you can use {@link assertEqualsFunction} instead.
240
- *
241
- * On the other hand, if you want to allow any superfluous properties, utilize
242
- * {@link assertReturn} or {@link validateReturn} instead.
243
- *
244
- * @template T Target function type
245
- * @param func Target function to assert
246
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
247
- * @returns The wrapper function with type assertions
248
- * @throws A {@link TypeGuardError} or a custom error generated by *errorFactory*
249
- *
250
- * @author Jeongho Nam - https://github.com/samchon
251
- */
252
- export function assertEqualsReturn<T extends (...args: any[]) => any>(
253
- func: T,
254
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
255
- ): T;
256
-
257
- /**
258
- * @internal
259
- */
260
- export function assertEqualsReturn(): never {
261
- NoTransformConfigurationError("functional.assertEqualsReturn");
262
- }
263
-
264
- /* -----------------------------------------------------------
265
- IS
266
- ----------------------------------------------------------- */
267
- /**
268
- * Tests a function.
269
- *
270
- * Tests a function, by wrapping the function and checking its parameters and
271
- * return value through {@link is} function. If some parameter or return value
272
- * does not match the expected type, it returns `null`. Otherwise there's no
273
- * type error, it returns the result of the function.
274
- *
275
- * By the way, if you want is not just testing type checking, but also finding
276
- * detailed type error reason(s), then use {@link assertFunction} or
277
- * {@link validateFunction} instead.
278
- *
279
- * On the other hand, if you don't want to allow any superfluous properties,
280
- * utilize {@link equalsFunction}, {@link assertEqualsFunction} or
281
- * {@link validateEqualsFunction} instead.
282
- *
283
- * @template T Target function type
284
- * @param func Target function to test
285
- * @returns The wrapper function with type tests
286
- *
287
- * @author Jeongho Nam - https://github.com/samchon
288
- */
289
- export function isFunction<T extends (...args: any[]) => any>(
290
- func: T,
291
- ): T extends (...args: infer Arguments) => infer Output
292
- ? Output extends Promise<infer R>
293
- ? (...args: Arguments) => Promise<R | null>
294
- : (...args: Arguments) => Output | null
295
- : never;
296
-
297
- /**
298
- * @internal
299
- */
300
- export function isFunction(): never {
301
- NoTransformConfigurationError("functional.isFunction");
302
- }
303
-
304
- /**
305
- * Tests parameters.
306
- *
307
- * Tests a function, by wrapping the function and checking its parameters through
308
- * {@link is} function. If some parameter does not match the expected type, it
309
- * returns `null`. Otherwise there's no type error, it returns the result of the
310
- * function.
311
- *
312
- * By the way, if you want is not just testing type checking, but also finding
313
- * detailed type error reason(s), then use {@link assertParameters} or
314
- * {@link validateParameters} instead.
315
- *
316
- * On the other hand, if you don't want to allow any superfluous properties,
317
- * utilize {@link equalsParameters}, {@link assertEqualsParameters} or
318
- * {@link validateEqualsParameters} instead.
319
- *
320
- * @template T Target function type
321
- * @param func Target function to test
322
- * @returns The wrapper function with type tests
323
- *
324
- * @author Jeongho Nam - https://github.com/samchon
325
- */
326
- export function isParameters<T extends (...args: any[]) => any>(
327
- func: T,
328
- ): T extends (...args: infer Arguments) => infer Output
329
- ? Output extends Promise<infer R>
330
- ? (...args: Arguments) => Promise<R | null>
331
- : (...args: Arguments) => Output | null
332
- : never;
333
-
334
- /**
335
- * @internal
336
- */
337
- export function isParameters(): never {
338
- NoTransformConfigurationError("functional.isParameters");
339
- }
340
-
341
- /**
342
- * Tests return value.
343
- *
344
- * Tests a function, by wrapping the function and checking its return value through
345
- * {@link is} function. If the return value does not match the expected type, it
346
- * returns `null`. Otherwise there's no type error, it returns the result of the
347
- * function.
348
- *
349
- * By the way, if you want is not just testing type checking, but also finding
350
- * detailed type error reason(s), then use {@link assertReturn} or
351
- * {@link validateReturn} instead.
352
- *
353
- * On the other hand, if you don't want to allow any superfluous properties,
354
- * utilize {@link equalsReturn}, {@link assertEqualsReturn} or
355
- * {@link validateEqualsReturn} instead.
356
- *
357
- * @template T Target function type
358
- * @param func Target function to test
359
- * @returns The wrapper function with type tests
360
- *
361
- * @author Jeongho Nam - https://github.com/samchon
362
- */
363
- export function isReturn<T extends (...args: any[]) => any>(
364
- func: T,
365
- ): T extends (...args: infer Arguments) => infer Output
366
- ? Output extends Promise<infer R>
367
- ? (...args: Arguments) => Promise<R | null>
368
- : (...args: Arguments) => Output | null
369
- : never;
370
-
371
- /**
372
- * @internal
373
- */
374
- export function isReturn(): never {
375
- NoTransformConfigurationError("functional.isReturn");
376
- }
377
-
378
- /**
379
- * Tests a function with strict equality.
380
- *
381
- * Tests a function with strict equality, by wrapping the function and checking its
382
- * parameters and return value through {@link isEquals} function. If some parameter
383
- * or return value does not match the expected type, it returns `null`. Otherwise
384
- * there's no type error, it returns the result of the function.
385
- *
386
- * By the way, if you want is not just testing type checking, but also finding
387
- * detailed type error reason(s), then use {@link assertEqualsFunction} or
388
- * {@link validateEqualsFunction} instead.
389
- *
390
- * On the other hand, if you want to allow any superfluous properties, utilize
391
- * {@link isFunction}, {@link assertFunction} or {@link validateFunction} instead.
392
- *
393
- * @template T Target function type
394
- * @param func Target function to test
395
- * @returns The wrapper function with type tests
396
- *
397
- * @author Jeongho Nam - https://github.com/samchon
398
- */
399
- export function equalsFunction<T extends (...args: any[]) => any>(
400
- func: T,
401
- ): T extends (...args: infer Arguments) => infer Output
402
- ? Output extends Promise<infer R>
403
- ? (...args: Arguments) => Promise<R | null>
404
- : (...args: Arguments) => Output | null
405
- : never;
406
-
407
- /**
408
- * @internal
409
- */
410
- export function equalsFunction(): never {
411
- NoTransformConfigurationError("functional.equalsFunction");
412
- }
413
-
414
- /**
415
- * Tests parameters with strict equality.
416
- *
417
- * Tests a function, by wrapping the function and checking its parameters through
418
- * {@link isEquals} function. If some parameter does not match the expected type,
419
- * it returns `null`. Otherwise there's no type error, it returns the result of the
420
- * function.
421
- *
422
- * By the way, if you want is not just testing type checking, but also finding
423
- * detailed type error reason(s), then use {@link assertEqualsParameters} or
424
- * {@link validateEqualsParameters} instead.
425
- *
426
- * @template T Target function type
427
- * @param func Target function to test
428
- * @returns The wrapper function with type tests
429
- *
430
- * @author Jeongho Nam - https://github.com/samchon
431
- */
432
- export function equalsParameters<T extends (...args: any[]) => any>(
433
- func: T,
434
- ): T extends (...args: infer Arguments) => infer Output
435
- ? Output extends Promise<infer R>
436
- ? (...args: Arguments) => Promise<R | null>
437
- : (...args: Arguments) => Output | null
438
- : never;
439
-
440
- /**
441
- * @internal
442
- */
443
- export function equalsParameters(): never {
444
- NoTransformConfigurationError("functional.equalsParameters");
445
- }
446
-
447
- /**
448
- * Tests return value with strict equality.
449
- *
450
- * Tests a function, by wrapping the function and checking its return value through
451
- * {@link isEquals} function. If the return value does not match the expected type,
452
- * it returns `null`. Otherwise there's no type error, it returns the result of the
453
- * function.
454
- *
455
- * By the way, if you want is not just testing type checking, but also finding
456
- * detailed type error reason(s), then use {@link assertEqualsReturn} or
457
- * {@link validateEqualsReturn} instead.
458
- *
459
- * On the other hand, if you want to allow any superfluous properties, utilize
460
- * {@link isReturn}, {@link assertReturn} or {@link validateReturn} instead.
461
- *
462
- * @template T Target function type
463
- * @param func Target function to test
464
- * @returns The wrapper function with type tests
465
- *
466
- * @author Jeongho Nam - https://github.com/samchon
467
- */
468
- export function equalsReturn<T extends (...args: any[]) => any>(
469
- func: T,
470
- ): T extends (...args: infer Arguments) => infer Output
471
- ? Output extends Promise<infer R>
472
- ? (...args: Arguments) => Promise<R | null>
473
- : (...args: Arguments) => Output | null
474
- : never;
475
-
476
- /**
477
- * @internal
478
- */
479
- export function equalsReturn(): never {
480
- NoTransformConfigurationError("functional.equalsReturn");
481
- }
482
-
483
- /* -----------------------------------------------------------
484
- VALIDATE
485
- ----------------------------------------------------------- */
486
- /**
487
- * Validates a function.
488
- *
489
- * Validates a function, by wrapping the function and checking its parameters and
490
- * return value through {@link validate} function. If some parameter or return value
491
- * does not match the expected type, it returns {@link IValidation.IError} typed
492
- * object. Otherwise there's no type error, it returns {@link IValidation.ISuccess}
493
- * typed object instead.
494
- *
495
- * For reference, {@link IValidation.IError.path} would be a little bit different with
496
- * individual {@link validate} function. If the {@link IValidation.IError} occurs from
497
- * some parameter, the path would start from `$input.parameters[number]`. Otherwise
498
- * the path would start from `$input.return`.
499
- *
500
- * - `$input.parameters[0].~`
501
- * - `$input.return.~`
502
- *
503
- * By the way, if what you want is not finding every type errors, but just finding
504
- * the 1st type error, then use {@link assertFunction} instead. Otherwise, what you
505
- * want is just validating parameters or return value only, you can use
506
- * {@link validateParameters} or {@link validateReturn} instead.
507
- *
508
- * On the other hand, if you don't want to allow any superfluous properties, utilize
509
- * {@link validateEqualsFunction} or {@link assertEqualsFunction} instead.
510
- *
511
- * @template T Target function type
512
- * @param func Target function to validate
513
- * @returns The wrapper function with type validations
514
- *
515
- * @author Jeongho Nam - https://github.com/samchon
516
- */
517
- export function validateFunction<T extends (...args: any[]) => any>(
518
- func: T,
519
- ): T extends (...args: infer Arguments) => infer Output
520
- ? Output extends Promise<infer R>
521
- ? (...args: Arguments) => Promise<IValidation<R>>
522
- : (...args: Arguments) => IValidation<Output>
523
- : never;
524
-
525
- /**
526
- * @internal
527
- */
528
- export function validateFunction(): never {
529
- NoTransformConfigurationError("functional.validateFunction");
530
- }
531
-
532
- /**
533
- * Validates parameters.
534
- *
535
- * Validates a function, by wrapping the function and checking its parameters through
536
- * {@link validate} function. If some parameter does not match the expected type, it
537
- * returns {@link IValidation.IError} typed object. Otherwise there's no type error,
538
- * it returns {@link IValidation.ISuccess} typed object instead.
539
- *
540
- * For reference, {@link IValidation.IError.path} would be a little bit different with
541
- * individual {@link validate} function. If the {@link IValidation.IError} occurs from
542
- * some parameter, the path would start from `$input.parameters[number]`.
543
- *
544
- * By the way, if what you want is not finding every type errors, but just finding
545
- * the 1st type error, then use {@link assertParameters} instead. Otherwise, what you
546
- * want is not only validating parameters, but also validating return value, you can
547
- * use {@link validateFunction} instead.
548
- *
549
- * On the other hand, if you don't want to allow any superfluous properties, utilize
550
- * {@link validateEqualsParameters} or {@link assertEqualsParameters} instead.
551
- *
552
- * @template T Target function type
553
- * @param func Target function to validate
554
- * @returns The wrapper function with type validations
555
- *
556
- * @author Jeongho Nam - https://github.com/samchon
557
- */
558
- export function validateParameters<T extends (...args: any[]) => any>(
559
- func: T,
560
- ): T extends (...args: infer Arguments) => infer Output
561
- ? Output extends Promise<infer R>
562
- ? (...args: Arguments) => Promise<IValidation<R>>
563
- : (...args: Arguments) => IValidation<Output>
564
- : never;
565
-
566
- /**
567
- * @internal
568
- */
569
- export function validateParameters(): never {
570
- NoTransformConfigurationError("functional.validateParameters");
571
- }
572
-
573
- /**
574
- * Validates return value.
575
- *
576
- * Validates a function, by wrapping the function and checking its return value through
577
- * {@link validate} function. If the return value does not match the expected type, it
578
- * returns {@link IValidation.IError} typed object. Otherwise there's no type error,
579
- * it returns {@link IValidation.ISuccess} typed object instead.
580
- *
581
- * For reference, {@link IValidation.IError.path} would be a little bit different with
582
- * individual {@link validate} function. If the {@link IValidation.IError} occurs from
583
- * the return value, the path would start from `$input.return`.
584
- *
585
- * By the way, if what you want is not finding every type errors, but just finding
586
- * the 1st type error, then use {@link assertReturn} instead. Otherwise, what you want
587
- * is not only validating return value, but also validating parameters, you can use
588
- * {@link validateFunction} instead.
589
- *
590
- * On the other hand, if you don't want to allow any superfluous properties, utilize
591
- * {@link validateEqualsReturn} or {@link assertEqualsReturn} instead.
592
- *
593
- * @template T Target function type
594
- * @param func Target function to validate
595
- * @returns The wrapper function with type validations
596
- *
597
- * @author Jeongho Nam - https://github.com/samchon
598
- */
599
- export function validateReturn<T extends (...args: any[]) => any>(
600
- func: T,
601
- ): T extends (...args: infer Arguments) => infer Output
602
- ? Output extends Promise<infer R>
603
- ? (...args: Arguments) => Promise<IValidation<R>>
604
- : (...args: Arguments) => IValidation<Output>
605
- : never;
606
-
607
- /**
608
- * @internal
609
- */
610
- export function validateReturn(): never {
611
- NoTransformConfigurationError("functional.validateReturn");
612
- }
613
-
614
- /**
615
- * Validates a function with strict equality.
616
- *
617
- * Validates a function with strict equality, by wrapping the function and checking
618
- * its parameters and return value through {@link validateEquals} function. If some
619
- * parameter or return value does not match the expected type, it returns
620
- * {@link IValidation.IError} typed object. Otherwise there's no type error, it
621
- * returns {@link IValidation.ISuccess} typed object instead.
622
- *
623
- * For reference, {@link IValidation.IError.path} would be a little bit different with
624
- * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
625
- * from some parameter, the path would start from `$input.parameters[number]`. Otherwise
626
- * the path would start from `$input.return`.
627
- *
628
- * - `$input.parameters[0].~`
629
- * - `$input.return.~`
630
- *
631
- * By the way, if what you want is not finding every type errors, but just finding
632
- * the 1st type error, then use {@link assertEqualsFunction} instead. Otherwise, what
633
- * you want is just validating parameters or return value only, you can use
634
- * {@link validateEqualsParameters} or {@link validateEqualsReturn} instead.
635
- *
636
- * On the other hand, if you want to allow any superfluous properties, utilize
637
- * {@link validateFunction} or {@link assertFunction} instead.
638
- *
639
- * @template T Target function type
640
- * @param func Target function to validate
641
- * @returns The wrapper function with type validations
642
- *
643
- * @author Jeongho Nam - https://github.com/samchon
644
- */
645
- export function validateEqualsFunction<T extends (...args: any[]) => any>(
646
- func: T,
647
- ): T extends (...args: infer Arguments) => infer Output
648
- ? Output extends Promise<infer R>
649
- ? (...args: Arguments) => Promise<IValidation<R>>
650
- : (...args: Arguments) => IValidation<Output>
651
- : never;
652
-
653
- /**
654
- * @internal
655
- */
656
- export function validateEqualsFunction(): never {
657
- NoTransformConfigurationError("functional.validateEqualsFunction");
658
- }
659
-
660
- /**
661
- * Validates parameters with strict equality.
662
- *
663
- * Validates a function, by wrapping the function and checking its parameters through
664
- * {@link validateEquals} function. If some parameter does not match the expected type,
665
- * it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
666
- * it returns {@link IValidation.ISuccess} typed object instead.
667
- *
668
- * For reference, {@link IValidation.IError.path} would be a little bit different with
669
- * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
670
- * from some parameter, the path would start from `$input.parameters[number]`.
671
- *
672
- * By the way, if what you want is not finding every type errors, but just finding
673
- * the 1st type error, then use {@link assertEqualsParameters} instead. Otherwise,
674
- * what you want is not only validating parameters, but also validating return value,
675
- * you can use {@link validateEqualsFunction} instead.
676
- *
677
- * On the other hand, if you want to allow any superfluous properties, utilize
678
- * {@link validateParameters} or {@link assertParameters} instead.
679
- *
680
- * @template T Target function type
681
- * @param func Target function to validate
682
- * @returns The wrapper function with type validations
683
- *
684
- * @author Jeongho Nam - https://github.com/samchon
685
- */
686
- export function validateEqualsParameters<T extends (...args: any[]) => any>(
687
- func: T,
688
- ): T extends (...args: infer Arguments) => infer Output
689
- ? Output extends Promise<infer R>
690
- ? (...args: Arguments) => Promise<IValidation<R>>
691
- : (...args: Arguments) => IValidation<Output>
692
- : never;
693
-
694
- /**
695
- * @internal
696
- */
697
- export function validateEqualsParameters(): never {
698
- NoTransformConfigurationError("functional.validateEqualsParameters");
699
- }
700
-
701
- /**
702
- * Validates return value with strict equality.
703
- *
704
- * Validates a function, by wrapping the function and checking its return value through
705
- * {@link validateEquals} function. If the return value does not match the expected type,
706
- * it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
707
- * it returns {@link IValidation.ISuccess} typed object instead.
708
- *
709
- * For reference, {@link IValidation.IError.path} would be a little bit different with
710
- * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
711
- * from the return value, the path would start from `$input.return`.
712
- *
713
- * By the way, if what you want is not finding every type errors, but just finding
714
- * the 1st type error, then use {@link assertEqualsReturn} instead. Otherwise, what you
715
- * want is not only validating return value, but also validating parameters, you can use
716
- * {@link validateEqualsFunction} instead.
717
- *
718
- * On the other hand, if you want to allow any superfluous properties, utilize
719
- * {@link validateReturn} or {@link assertReturn} instead.
720
- *
721
- * @template T Target function type
722
- * @param func Target function to validate
723
- * @returns The wrapper function with type validations
724
- *
725
- * @author Jeongho Nam - https://github.com/samchon
726
- */
727
- export function validateEqualsReturn<T extends (...args: any[]) => any>(
728
- func: T,
729
- ): T extends (...args: infer Arguments) => infer Output
730
- ? Output extends Promise<infer R>
731
- ? (...args: Arguments) => Promise<IValidation<R>>
732
- : (...args: Arguments) => IValidation<Output>
733
- : never;
734
-
735
- /**
736
- * @internal
737
- */
738
- export function validateEqualsReturn(): never {
739
- NoTransformConfigurationError("functional.validateEqualsReturn");
740
- }
1
+ import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
2
+
3
+ import { IValidation } from "./IValidation";
4
+ import { TypeGuardError } from "./TypeGuardError";
5
+
6
+ /* ===========================================================
7
+ FUNCTIONAL
8
+ - ASSERT
9
+ - IS
10
+ - VALIDATE
11
+ ==============================================================
12
+ ASSERT
13
+ ----------------------------------------------------------- */
14
+ /**
15
+ * Asserts a function.
16
+ *
17
+ * Asserts a function, by wrapping the function and checking its parameters and
18
+ * return value through {@link assert} function. If some parameter or return
19
+ * value does not match the expected type, it throws an {@link TypeGuardError} or
20
+ * a custom error generated by the _errorFactory_ parameter.
21
+ *
22
+ * For reference, {@link TypeGuardError.path} would be a little bit different
23
+ * with individual {@link assert} function. If the {@link TypeGuardError} occurs
24
+ * from some parameter, the path would start from `$input.parameters[number]`.
25
+ * Otherwise the path would start from `$input.return`.
26
+ *
27
+ * - `$input.parameters[0].~`
28
+ * - `$input.return.~`
29
+ *
30
+ * By the way, if what you want is not just finding the 1st type error through
31
+ * assertion, but also finding every type errors, then use
32
+ * {@link validateFunction} instead. Otherwise, what you want is just asserting
33
+ * parameters or return value only, you can use {@link assertParameters} or
34
+ * {@link assertReturn} instead.
35
+ *
36
+ * On the other hand, if don't want to allow any superfluous properties, utilize
37
+ * {@link assertEqualsFunction} or {@link validateEqualsFunction} instead.
38
+ *
39
+ * @author Jeongho Nam - https://github.com/samchon
40
+ * @template T Target function type
41
+ * @param func Target function to assert
42
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
43
+ * @returns The wrapper function with type assertions
44
+ * @throws A {@link TypeGuardError} or a custom error generated by _errorFactory_
45
+ */
46
+ export function assertFunction<T extends (...args: any[]) => any>(
47
+ func: T,
48
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
49
+ ): T;
50
+
51
+ /** @internal */
52
+ export function assertFunction(): never {
53
+ NoTransformConfigurationError("functional.assertFunction");
54
+ }
55
+
56
+ /**
57
+ * Asserts parameters.
58
+ *
59
+ * Asserts a function, by wrapping the function and checking its parameters
60
+ * through {@link assert} function. If some parameter does not match the expected
61
+ * type, it throws an {@link TypeGuardError} or a custom error generated by the
62
+ * _errorFactory_ parameter.
63
+ *
64
+ * For reference, {@link TypeGuardError.path} would be a little bit different
65
+ * with individual {@link assert} function. If the {@link TypeGuardError} occurs
66
+ * from some parameter, the path would start from `$input.parameters[number]`.
67
+ *
68
+ * By the way, if what you want is not just finding the 1st type error through
69
+ * assertion, but also finding every type errors, then use
70
+ * {@link validateParameters} instead. Otherwise, what you want is not only
71
+ * asserting parameters, but also asserting return value, you can use
72
+ * {@link assertFunction} instead.
73
+ *
74
+ * On the other hand, if don't want to allow any superfluous properties, utilize
75
+ * {@link assertEqualsParameters} or {@link validateEqualsParameters} instead.
76
+ *
77
+ * @author Jeongho Nam - https://github.com/samchon
78
+ * @template T Target function type
79
+ * @param func Target function to assert
80
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
81
+ * @returns The wrapper function with type assertions
82
+ * @throws A {@link TypeGuardError} or a custom error generated by _errorFactory_
83
+ */
84
+ export function assertParameters<T extends (...args: any[]) => any>(
85
+ func: T,
86
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
87
+ ): T;
88
+
89
+ /** @internal */
90
+ export function assertParameters(): never {
91
+ NoTransformConfigurationError("functional.assertParameters");
92
+ }
93
+
94
+ /**
95
+ * Asserts return value.
96
+ *
97
+ * Asserts a function, by wrapping the function and checking its return value
98
+ * through {@link assert} function. If the return value does not match the
99
+ * expected type, it throws an {@link TypeGuardError} or a custom error generated
100
+ * by the _errorFactory_ parameter.
101
+ *
102
+ * For reference, {@link TypeGuardError.path} would be a little bit different
103
+ * with individual {@link assert} function. If the {@link TypeGuardError} occurs
104
+ * from the return value, the path would start from `$input.return`.
105
+ *
106
+ * By the way, if what you want is not just finding the 1st type error through
107
+ * assertion, but also finding every type errors, then use {@link validateReturn}
108
+ * instead. Otherwise, what you want is not only asserting return value, but
109
+ * also asserting parameters, you can use {@link assertFunction} instead.
110
+ *
111
+ * On the other hand, if don't want to allow any superfluous properties, utilize
112
+ * {@link assertEqualsReturn} or {@link validateEqualsReturn} instead.
113
+ *
114
+ * @author Jeongho Nam - https://github.com/samchon
115
+ * @template T Target function type
116
+ * @param func Target function to assert
117
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
118
+ * @returns The wrapper function with type assertions
119
+ * @throws A {@link TypeGuardError} or a custom error generated by _errorFactory_
120
+ */
121
+ export function assertReturn<T extends (...args: any[]) => any>(
122
+ func: T,
123
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
124
+ ): T;
125
+
126
+ /** @internal */
127
+ export function assertReturn(): never {
128
+ NoTransformConfigurationError("functional.assertReturn");
129
+ }
130
+
131
+ /**
132
+ * Asserts a function with strict equality.
133
+ *
134
+ * Asserts a function with strict equality, by wrapping the function and
135
+ * checking its parameters and return value through {@link assertEquals}
136
+ * function. If some parameter or return value does not match the expected type,
137
+ * it throws an {@link TypeGuardError} or a custom error generated by the
138
+ * _errorFactory_ parameter.
139
+ *
140
+ * For reference, {@link TypeGuardError.path} would be a little bit different
141
+ * with individual {@link assertEquals} function. If the {@link TypeGuardError}
142
+ * occurs from some parameter, the path would start from
143
+ * `$input.parameters[number]`. Otherwise the path would start from
144
+ * `$input.return`.
145
+ *
146
+ * - `$input.parameters[0].~`
147
+ * - `$input.return.~`
148
+ *
149
+ * By the way, if what you want is not just finding the 1st type error through
150
+ * assertion, but also finding every type errors, then use
151
+ * {@link validateEqualsFunction} instead. Otherwise, what you want is just
152
+ * asserting parameters or return value only, you can use
153
+ * {@link assertEqualsParameters} or {@link assertEqualsReturn} instead.
154
+ *
155
+ * On the other hand, if you want to allow any superfluous properties, utilize
156
+ * {@link assertFunction} or {@link validateFunction} instead.
157
+ *
158
+ * @author Jeongho Nam - https://github.com/samchon
159
+ * @template T Target function type
160
+ * @param func Target function to assert
161
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
162
+ * @returns The wrapper function with type assertions
163
+ * @throws A {@link TypeGuardError} or a custom error generated by _errorFactory_
164
+ */
165
+ export function assertEqualsFunction<T extends (...args: any[]) => any>(
166
+ func: T,
167
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
168
+ ): T;
169
+
170
+ /** @internal */
171
+ export function assertEqualsFunction(): never {
172
+ NoTransformConfigurationError("functional.assertEqualsFunction");
173
+ }
174
+
175
+ /**
176
+ * Asserts parameters with strict equality.
177
+ *
178
+ * Asserts a function, by wrapping the function and checking its parameters
179
+ * through {@link assertEquals} function. If some parameter does not match the
180
+ * expected type, it throws an {@link TypeGuardError} or a custom error generated
181
+ * by the _errorFactory_ parameter.
182
+ *
183
+ * For reference, {@link TypeGuardError.path} would be a little bit different
184
+ * with individual {@link assertEquals} function. If the {@link TypeGuardError}
185
+ * occurs from some parameter, the path would start from
186
+ * `$input.parameters[number]`.
187
+ *
188
+ * By the way, if what you want is not just finding the 1st type error through
189
+ * assertion, but also finding every type errors, then use
190
+ * {@link validateEqualsParameters} instead. Otherwise, what you want is not only
191
+ * asserting parameters, but also asserting return value, you can use
192
+ * {@link assertEqualsFunction} instead.
193
+ *
194
+ * On the other hand, if you want to allow any superfluous properties, utilize
195
+ * {@link assertParameters} or {@link validateParameters} instead.
196
+ *
197
+ * @author Jeongho Nam - https://github.com/samchon
198
+ * @template T Target function type
199
+ * @param func Target function to assert
200
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
201
+ * @returns The wrapper function with type assertions
202
+ * @throws A {@link TypeGuardError} or a custom error generated by _errorFactory_
203
+ */
204
+ export function assertEqualsParameters<T extends (...args: any[]) => any>(
205
+ func: T,
206
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
207
+ ): T;
208
+
209
+ /** @internal */
210
+ export function assertEqualsParameters(): never {
211
+ NoTransformConfigurationError("functional.assertEqualsParameters");
212
+ }
213
+
214
+ /**
215
+ * Asserts return value with strict equality.
216
+ *
217
+ * Asserts a function, by wrapping the function and checking its return value
218
+ * through {@link assertEquals} function. If the return value does not match the
219
+ * expected type, it throws an {@link TypeGuardError} or a custom error generated
220
+ * by the _errorFactory_ parameter.
221
+ *
222
+ * For reference, {@link TypeGuardError.path} would be a little bit different
223
+ * with individual {@link assertEquals} function. If the {@link TypeGuardError}
224
+ * occurs from the return value, the path would start from `$input.return`.
225
+ *
226
+ * By the way, if what you want is not just finding the 1st type error through
227
+ * assertion, but also finding every type errors, then use
228
+ * {@link validateEqualsReturn} instead. Otherwise, what you want is not only
229
+ * asserting return value, but also asserting parameters, you can use
230
+ * {@link assertEqualsFunction} instead.
231
+ *
232
+ * On the other hand, if you want to allow any superfluous properties, utilize
233
+ * {@link assertReturn} or {@link validateReturn} instead.
234
+ *
235
+ * @author Jeongho Nam - https://github.com/samchon
236
+ * @template T Target function type
237
+ * @param func Target function to assert
238
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
239
+ * @returns The wrapper function with type assertions
240
+ * @throws A {@link TypeGuardError} or a custom error generated by _errorFactory_
241
+ */
242
+ export function assertEqualsReturn<T extends (...args: any[]) => any>(
243
+ func: T,
244
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
245
+ ): T;
246
+
247
+ /** @internal */
248
+ export function assertEqualsReturn(): never {
249
+ NoTransformConfigurationError("functional.assertEqualsReturn");
250
+ }
251
+
252
+ /* -----------------------------------------------------------
253
+ IS
254
+ ----------------------------------------------------------- */
255
+ /**
256
+ * Tests a function.
257
+ *
258
+ * Tests a function, by wrapping the function and checking its parameters and
259
+ * return value through {@link is} function. If some parameter or return value
260
+ * does not match the expected type, it returns `null`. Otherwise there's no
261
+ * type error, it returns the result of the function.
262
+ *
263
+ * By the way, if you want is not just testing type checking, but also finding
264
+ * detailed type error reason(s), then use {@link assertFunction} or
265
+ * {@link validateFunction} instead.
266
+ *
267
+ * On the other hand, if you don't want to allow any superfluous properties,
268
+ * utilize {@link equalsFunction}, {@link assertEqualsFunction} or
269
+ * {@link validateEqualsFunction} instead.
270
+ *
271
+ * @author Jeongho Nam - https://github.com/samchon
272
+ * @template T Target function type
273
+ * @param func Target function to test
274
+ * @returns The wrapper function with type tests
275
+ */
276
+ export function isFunction<T extends (...args: any[]) => any>(
277
+ func: T,
278
+ ): T extends (...args: infer Arguments) => infer Output
279
+ ? Output extends Promise<infer R>
280
+ ? (...args: Arguments) => Promise<R | null>
281
+ : (...args: Arguments) => Output | null
282
+ : never;
283
+
284
+ /** @internal */
285
+ export function isFunction(): never {
286
+ NoTransformConfigurationError("functional.isFunction");
287
+ }
288
+
289
+ /**
290
+ * Tests parameters.
291
+ *
292
+ * Tests a function, by wrapping the function and checking its parameters
293
+ * through {@link is} function. If some parameter does not match the expected
294
+ * type, it returns `null`. Otherwise there's no type error, it returns the
295
+ * result of the function.
296
+ *
297
+ * By the way, if you want is not just testing type checking, but also finding
298
+ * detailed type error reason(s), then use {@link assertParameters} or
299
+ * {@link validateParameters} instead.
300
+ *
301
+ * On the other hand, if you don't want to allow any superfluous properties,
302
+ * utilize {@link equalsParameters}, {@link assertEqualsParameters} or
303
+ * {@link validateEqualsParameters} instead.
304
+ *
305
+ * @author Jeongho Nam - https://github.com/samchon
306
+ * @template T Target function type
307
+ * @param func Target function to test
308
+ * @returns The wrapper function with type tests
309
+ */
310
+ export function isParameters<T extends (...args: any[]) => any>(
311
+ func: T,
312
+ ): T extends (...args: infer Arguments) => infer Output
313
+ ? Output extends Promise<infer R>
314
+ ? (...args: Arguments) => Promise<R | null>
315
+ : (...args: Arguments) => Output | null
316
+ : never;
317
+
318
+ /** @internal */
319
+ export function isParameters(): never {
320
+ NoTransformConfigurationError("functional.isParameters");
321
+ }
322
+
323
+ /**
324
+ * Tests return value.
325
+ *
326
+ * Tests a function, by wrapping the function and checking its return value
327
+ * through {@link is} function. If the return value does not match the expected
328
+ * type, it returns `null`. Otherwise there's no type error, it returns the
329
+ * result of the function.
330
+ *
331
+ * By the way, if you want is not just testing type checking, but also finding
332
+ * detailed type error reason(s), then use {@link assertReturn} or
333
+ * {@link validateReturn} instead.
334
+ *
335
+ * On the other hand, if you don't want to allow any superfluous properties,
336
+ * utilize {@link equalsReturn}, {@link assertEqualsReturn} or
337
+ * {@link validateEqualsReturn} instead.
338
+ *
339
+ * @author Jeongho Nam - https://github.com/samchon
340
+ * @template T Target function type
341
+ * @param func Target function to test
342
+ * @returns The wrapper function with type tests
343
+ */
344
+ export function isReturn<T extends (...args: any[]) => any>(
345
+ func: T,
346
+ ): T extends (...args: infer Arguments) => infer Output
347
+ ? Output extends Promise<infer R>
348
+ ? (...args: Arguments) => Promise<R | null>
349
+ : (...args: Arguments) => Output | null
350
+ : never;
351
+
352
+ /** @internal */
353
+ export function isReturn(): never {
354
+ NoTransformConfigurationError("functional.isReturn");
355
+ }
356
+
357
+ /**
358
+ * Tests a function with strict equality.
359
+ *
360
+ * Tests a function with strict equality, by wrapping the function and checking
361
+ * its parameters and return value through {@link isEquals} function. If some
362
+ * parameter or return value does not match the expected type, it returns
363
+ * `null`. Otherwise there's no type error, it returns the result of the
364
+ * function.
365
+ *
366
+ * By the way, if you want is not just testing type checking, but also finding
367
+ * detailed type error reason(s), then use {@link assertEqualsFunction} or
368
+ * {@link validateEqualsFunction} instead.
369
+ *
370
+ * On the other hand, if you want to allow any superfluous properties, utilize
371
+ * {@link isFunction}, {@link assertFunction} or {@link validateFunction} instead.
372
+ *
373
+ * @author Jeongho Nam - https://github.com/samchon
374
+ * @template T Target function type
375
+ * @param func Target function to test
376
+ * @returns The wrapper function with type tests
377
+ */
378
+ export function equalsFunction<T extends (...args: any[]) => any>(
379
+ func: T,
380
+ ): T extends (...args: infer Arguments) => infer Output
381
+ ? Output extends Promise<infer R>
382
+ ? (...args: Arguments) => Promise<R | null>
383
+ : (...args: Arguments) => Output | null
384
+ : never;
385
+
386
+ /** @internal */
387
+ export function equalsFunction(): never {
388
+ NoTransformConfigurationError("functional.equalsFunction");
389
+ }
390
+
391
+ /**
392
+ * Tests parameters with strict equality.
393
+ *
394
+ * Tests a function, by wrapping the function and checking its parameters
395
+ * through {@link isEquals} function. If some parameter does not match the
396
+ * expected type, it returns `null`. Otherwise there's no type error, it returns
397
+ * the result of the function.
398
+ *
399
+ * By the way, if you want is not just testing type checking, but also finding
400
+ * detailed type error reason(s), then use {@link assertEqualsParameters} or
401
+ * {@link validateEqualsParameters} instead.
402
+ *
403
+ * @author Jeongho Nam - https://github.com/samchon
404
+ * @template T Target function type
405
+ * @param func Target function to test
406
+ * @returns The wrapper function with type tests
407
+ */
408
+ export function equalsParameters<T extends (...args: any[]) => any>(
409
+ func: T,
410
+ ): T extends (...args: infer Arguments) => infer Output
411
+ ? Output extends Promise<infer R>
412
+ ? (...args: Arguments) => Promise<R | null>
413
+ : (...args: Arguments) => Output | null
414
+ : never;
415
+
416
+ /** @internal */
417
+ export function equalsParameters(): never {
418
+ NoTransformConfigurationError("functional.equalsParameters");
419
+ }
420
+
421
+ /**
422
+ * Tests return value with strict equality.
423
+ *
424
+ * Tests a function, by wrapping the function and checking its return value
425
+ * through {@link isEquals} function. If the return value does not match the
426
+ * expected type, it returns `null`. Otherwise there's no type error, it returns
427
+ * the result of the function.
428
+ *
429
+ * By the way, if you want is not just testing type checking, but also finding
430
+ * detailed type error reason(s), then use {@link assertEqualsReturn} or
431
+ * {@link validateEqualsReturn} instead.
432
+ *
433
+ * On the other hand, if you want to allow any superfluous properties, utilize
434
+ * {@link isReturn}, {@link assertReturn} or {@link validateReturn} instead.
435
+ *
436
+ * @author Jeongho Nam - https://github.com/samchon
437
+ * @template T Target function type
438
+ * @param func Target function to test
439
+ * @returns The wrapper function with type tests
440
+ */
441
+ export function equalsReturn<T extends (...args: any[]) => any>(
442
+ func: T,
443
+ ): T extends (...args: infer Arguments) => infer Output
444
+ ? Output extends Promise<infer R>
445
+ ? (...args: Arguments) => Promise<R | null>
446
+ : (...args: Arguments) => Output | null
447
+ : never;
448
+
449
+ /** @internal */
450
+ export function equalsReturn(): never {
451
+ NoTransformConfigurationError("functional.equalsReturn");
452
+ }
453
+
454
+ /* -----------------------------------------------------------
455
+ VALIDATE
456
+ ----------------------------------------------------------- */
457
+ /**
458
+ * Validates a function.
459
+ *
460
+ * Validates a function, by wrapping the function and checking its parameters
461
+ * and return value through {@link validate} function. If some parameter or
462
+ * return value does not match the expected type, it returns
463
+ * {@link IValidation.IError} typed object. Otherwise there's no type error, it
464
+ * returns {@link IValidation.ISuccess} typed object instead.
465
+ *
466
+ * For reference, {@link IValidation.IError.path} would be a little bit different
467
+ * with individual {@link validate} function. If the {@link IValidation.IError}
468
+ * occurs from some parameter, the path would start from
469
+ * `$input.parameters[number]`. Otherwise the path would start from
470
+ * `$input.return`.
471
+ *
472
+ * - `$input.parameters[0].~`
473
+ * - `$input.return.~`
474
+ *
475
+ * By the way, if what you want is not finding every type errors, but just
476
+ * finding the 1st type error, then use {@link assertFunction} instead.
477
+ * Otherwise, what you want is just validating parameters or return value only,
478
+ * you can use {@link validateParameters} or {@link validateReturn} instead.
479
+ *
480
+ * On the other hand, if you don't want to allow any superfluous properties,
481
+ * utilize {@link validateEqualsFunction} or {@link assertEqualsFunction}
482
+ * instead.
483
+ *
484
+ * @author Jeongho Nam - https://github.com/samchon
485
+ * @template T Target function type
486
+ * @param func Target function to validate
487
+ * @returns The wrapper function with type validations
488
+ */
489
+ export function validateFunction<T extends (...args: any[]) => any>(
490
+ func: T,
491
+ ): T extends (...args: infer Arguments) => infer Output
492
+ ? Output extends Promise<infer R>
493
+ ? (...args: Arguments) => Promise<IValidation<R>>
494
+ : (...args: Arguments) => IValidation<Output>
495
+ : never;
496
+
497
+ /** @internal */
498
+ export function validateFunction(): never {
499
+ NoTransformConfigurationError("functional.validateFunction");
500
+ }
501
+
502
+ /**
503
+ * Validates parameters.
504
+ *
505
+ * Validates a function, by wrapping the function and checking its parameters
506
+ * through {@link validate} function. If some parameter does not match the
507
+ * expected type, it returns {@link IValidation.IError} typed object. Otherwise
508
+ * there's no type error, it returns {@link IValidation.ISuccess} typed object
509
+ * instead.
510
+ *
511
+ * For reference, {@link IValidation.IError.path} would be a little bit different
512
+ * with individual {@link validate} function. If the {@link IValidation.IError}
513
+ * occurs from some parameter, the path would start from
514
+ * `$input.parameters[number]`.
515
+ *
516
+ * By the way, if what you want is not finding every type errors, but just
517
+ * finding the 1st type error, then use {@link assertParameters} instead.
518
+ * Otherwise, what you want is not only validating parameters, but also
519
+ * validating return value, you can use {@link validateFunction} instead.
520
+ *
521
+ * On the other hand, if you don't want to allow any superfluous properties,
522
+ * utilize {@link validateEqualsParameters} or {@link assertEqualsParameters}
523
+ * instead.
524
+ *
525
+ * @author Jeongho Nam - https://github.com/samchon
526
+ * @template T Target function type
527
+ * @param func Target function to validate
528
+ * @returns The wrapper function with type validations
529
+ */
530
+ export function validateParameters<T extends (...args: any[]) => any>(
531
+ func: T,
532
+ ): T extends (...args: infer Arguments) => infer Output
533
+ ? Output extends Promise<infer R>
534
+ ? (...args: Arguments) => Promise<IValidation<R>>
535
+ : (...args: Arguments) => IValidation<Output>
536
+ : never;
537
+
538
+ /** @internal */
539
+ export function validateParameters(): never {
540
+ NoTransformConfigurationError("functional.validateParameters");
541
+ }
542
+
543
+ /**
544
+ * Validates return value.
545
+ *
546
+ * Validates a function, by wrapping the function and checking its return value
547
+ * through {@link validate} function. If the return value does not match the
548
+ * expected type, it returns {@link IValidation.IError} typed object. Otherwise
549
+ * there's no type error, it returns {@link IValidation.ISuccess} typed object
550
+ * instead.
551
+ *
552
+ * For reference, {@link IValidation.IError.path} would be a little bit different
553
+ * with individual {@link validate} function. If the {@link IValidation.IError}
554
+ * occurs from the return value, the path would start from `$input.return`.
555
+ *
556
+ * By the way, if what you want is not finding every type errors, but just
557
+ * finding the 1st type error, then use {@link assertReturn} instead. Otherwise,
558
+ * what you want is not only validating return value, but also validating
559
+ * parameters, you can use {@link validateFunction} instead.
560
+ *
561
+ * On the other hand, if you don't want to allow any superfluous properties,
562
+ * utilize {@link validateEqualsReturn} or {@link assertEqualsReturn} instead.
563
+ *
564
+ * @author Jeongho Nam - https://github.com/samchon
565
+ * @template T Target function type
566
+ * @param func Target function to validate
567
+ * @returns The wrapper function with type validations
568
+ */
569
+ export function validateReturn<T extends (...args: any[]) => any>(
570
+ func: T,
571
+ ): T extends (...args: infer Arguments) => infer Output
572
+ ? Output extends Promise<infer R>
573
+ ? (...args: Arguments) => Promise<IValidation<R>>
574
+ : (...args: Arguments) => IValidation<Output>
575
+ : never;
576
+
577
+ /** @internal */
578
+ export function validateReturn(): never {
579
+ NoTransformConfigurationError("functional.validateReturn");
580
+ }
581
+
582
+ /**
583
+ * Validates a function with strict equality.
584
+ *
585
+ * Validates a function with strict equality, by wrapping the function and
586
+ * checking its parameters and return value through {@link validateEquals}
587
+ * function. If some parameter or return value does not match the expected type,
588
+ * it returns {@link IValidation.IError} typed object. Otherwise there's no type
589
+ * error, it returns {@link IValidation.ISuccess} typed object instead.
590
+ *
591
+ * For reference, {@link IValidation.IError.path} would be a little bit different
592
+ * with individual {@link validateEquals} function. If the
593
+ * {@link IValidation.IError} occurs from some parameter, the path would start
594
+ * from `$input.parameters[number]`. Otherwise the path would start from
595
+ * `$input.return`.
596
+ *
597
+ * - `$input.parameters[0].~`
598
+ * - `$input.return.~`
599
+ *
600
+ * By the way, if what you want is not finding every type errors, but just
601
+ * finding the 1st type error, then use {@link assertEqualsFunction} instead.
602
+ * Otherwise, what you want is just validating parameters or return value only,
603
+ * you can use {@link validateEqualsParameters} or {@link validateEqualsReturn}
604
+ * instead.
605
+ *
606
+ * On the other hand, if you want to allow any superfluous properties, utilize
607
+ * {@link validateFunction} or {@link assertFunction} instead.
608
+ *
609
+ * @author Jeongho Nam - https://github.com/samchon
610
+ * @template T Target function type
611
+ * @param func Target function to validate
612
+ * @returns The wrapper function with type validations
613
+ */
614
+ export function validateEqualsFunction<T extends (...args: any[]) => any>(
615
+ func: T,
616
+ ): T extends (...args: infer Arguments) => infer Output
617
+ ? Output extends Promise<infer R>
618
+ ? (...args: Arguments) => Promise<IValidation<R>>
619
+ : (...args: Arguments) => IValidation<Output>
620
+ : never;
621
+
622
+ /** @internal */
623
+ export function validateEqualsFunction(): never {
624
+ NoTransformConfigurationError("functional.validateEqualsFunction");
625
+ }
626
+
627
+ /**
628
+ * Validates parameters with strict equality.
629
+ *
630
+ * Validates a function, by wrapping the function and checking its parameters
631
+ * through {@link validateEquals} function. If some parameter does not match the
632
+ * expected type, it returns {@link IValidation.IError} typed object. Otherwise
633
+ * there's no type error, it returns {@link IValidation.ISuccess} typed object
634
+ * instead.
635
+ *
636
+ * For reference, {@link IValidation.IError.path} would be a little bit different
637
+ * with individual {@link validateEquals} function. If the
638
+ * {@link IValidation.IError} occurs from some parameter, the path would start
639
+ * from `$input.parameters[number]`.
640
+ *
641
+ * By the way, if what you want is not finding every type errors, but just
642
+ * finding the 1st type error, then use {@link assertEqualsParameters} instead.
643
+ * Otherwise, what you want is not only validating parameters, but also
644
+ * validating return value, you can use {@link validateEqualsFunction} instead.
645
+ *
646
+ * On the other hand, if you want to allow any superfluous properties, utilize
647
+ * {@link validateParameters} or {@link assertParameters} instead.
648
+ *
649
+ * @author Jeongho Nam - https://github.com/samchon
650
+ * @template T Target function type
651
+ * @param func Target function to validate
652
+ * @returns The wrapper function with type validations
653
+ */
654
+ export function validateEqualsParameters<T extends (...args: any[]) => any>(
655
+ func: T,
656
+ ): T extends (...args: infer Arguments) => infer Output
657
+ ? Output extends Promise<infer R>
658
+ ? (...args: Arguments) => Promise<IValidation<R>>
659
+ : (...args: Arguments) => IValidation<Output>
660
+ : never;
661
+
662
+ /** @internal */
663
+ export function validateEqualsParameters(): never {
664
+ NoTransformConfigurationError("functional.validateEqualsParameters");
665
+ }
666
+
667
+ /**
668
+ * Validates return value with strict equality.
669
+ *
670
+ * Validates a function, by wrapping the function and checking its return value
671
+ * through {@link validateEquals} function. If the return value does not match
672
+ * the expected type, it returns {@link IValidation.IError} typed object.
673
+ * Otherwise there's no type error, it returns {@link IValidation.ISuccess} typed
674
+ * object instead.
675
+ *
676
+ * For reference, {@link IValidation.IError.path} would be a little bit different
677
+ * with individual {@link validateEquals} function. If the
678
+ * {@link IValidation.IError} occurs from the return value, the path would start
679
+ * from `$input.return`.
680
+ *
681
+ * By the way, if what you want is not finding every type errors, but just
682
+ * finding the 1st type error, then use {@link assertEqualsReturn} instead.
683
+ * Otherwise, what you want is not only validating return value, but also
684
+ * validating parameters, you can use {@link validateEqualsFunction} instead.
685
+ *
686
+ * On the other hand, if you want to allow any superfluous properties, utilize
687
+ * {@link validateReturn} or {@link assertReturn} instead.
688
+ *
689
+ * @author Jeongho Nam - https://github.com/samchon
690
+ * @template T Target function type
691
+ * @param func Target function to validate
692
+ * @returns The wrapper function with type validations
693
+ */
694
+ export function validateEqualsReturn<T extends (...args: any[]) => any>(
695
+ func: T,
696
+ ): T extends (...args: infer Arguments) => infer Output
697
+ ? Output extends Promise<infer R>
698
+ ? (...args: Arguments) => Promise<IValidation<R>>
699
+ : (...args: Arguments) => IValidation<Output>
700
+ : never;
701
+
702
+ /** @internal */
703
+ export function validateEqualsReturn(): never {
704
+ NoTransformConfigurationError("functional.validateEqualsReturn");
705
+ }