typia 3.8.2 → 3.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +1 -1
  2. package/lib/Primitive.d.ts +10 -10
  3. package/lib/factories/MetadataFactory.d.ts +1 -1
  4. package/lib/factories/MetadataFactory.js +1 -1
  5. package/lib/factories/MetadataFactory.js.map +1 -1
  6. package/lib/factories/internal/metadata/emplace_metadata_object.js +3 -1
  7. package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
  8. package/lib/factories/internal/metadata/iterate_metadata_tuple.js +2 -0
  9. package/lib/factories/internal/metadata/iterate_metadata_tuple.js.map +1 -1
  10. package/lib/metadata/IMetadata.d.ts +1 -0
  11. package/lib/metadata/Metadata.d.ts +1 -0
  12. package/lib/metadata/Metadata.js +5 -0
  13. package/lib/metadata/Metadata.js.map +1 -1
  14. package/lib/programmers/CheckerProgrammer.js +17 -6
  15. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  16. package/lib/programmers/internal/application_object.js +1 -0
  17. package/lib/programmers/internal/application_object.js.map +1 -1
  18. package/lib/programmers/internal/application_tuple.js +1 -1
  19. package/lib/programmers/internal/application_tuple.js.map +1 -1
  20. package/lib/schemas/IJsonSchema.d.ts +1 -0
  21. package/package.json +1 -1
  22. package/src/Primitive.ts +123 -120
  23. package/src/executable/TypiaGenerateWizard.ts +85 -85
  24. package/src/executable/TypiaSetupWizard.ts +133 -133
  25. package/src/executable/setup/CommandExecutor.ts +8 -8
  26. package/src/executable/setup/PackageManager.ts +71 -71
  27. package/src/executable/typia.ts +52 -52
  28. package/src/factories/CommentFactory.ts +14 -14
  29. package/src/factories/ExpressionFactory.ts +70 -70
  30. package/src/factories/IdentifierFactory.ts +63 -63
  31. package/src/factories/LiteralFactory.ts +39 -39
  32. package/src/factories/MetadataCollection.ts +121 -121
  33. package/src/factories/MetadataFactory.ts +62 -62
  34. package/src/factories/MetadataTagFactory.ts +297 -297
  35. package/src/factories/StatementFactory.ts +24 -24
  36. package/src/factories/TemplateFactory.ts +58 -58
  37. package/src/factories/TypeFactory.ts +124 -124
  38. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  39. package/src/factories/internal/metadata/emplace_metadata_object.ts +143 -140
  40. package/src/factories/internal/metadata/iterate_metadata.ts +67 -67
  41. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  42. package/src/factories/internal/metadata/iterate_metadata_native.ts +219 -219
  43. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
  44. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  45. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +48 -44
  46. package/src/factories/internal/metadata/iterate_metadata_union.ts +57 -57
  47. package/src/functional/$any.ts +2 -2
  48. package/src/functional/$is_between.ts +2 -2
  49. package/src/functional/$is_custom.ts +14 -14
  50. package/src/functional/$is_date.ts +3 -3
  51. package/src/functional/$is_datetime.ts +2 -2
  52. package/src/functional/$is_email.ts +4 -4
  53. package/src/functional/$is_ipv4.ts +4 -4
  54. package/src/functional/$is_ipv6.ts +4 -4
  55. package/src/functional/$is_url.ts +4 -4
  56. package/src/functional/$is_uuid.ts +4 -4
  57. package/src/functional/$join.ts +46 -46
  58. package/src/functional/$number.ts +12 -12
  59. package/src/functional/$rest.ts +3 -3
  60. package/src/functional/$string.ts +37 -37
  61. package/src/functional/$tail.ts +5 -5
  62. package/src/metadata/IMetadata.ts +1 -0
  63. package/src/metadata/Metadata.ts +539 -533
  64. package/src/metadata/MetadataConstant.ts +3 -3
  65. package/src/metadata/MetadataObject.ts +127 -127
  66. package/src/module.ts +2043 -2043
  67. package/src/programmers/ApplicationProgrammer.ts +62 -62
  68. package/src/programmers/AssertCloneProgrammer.ts +79 -79
  69. package/src/programmers/AssertParseProgrammer.ts +74 -74
  70. package/src/programmers/AssertProgrammer.ts +285 -285
  71. package/src/programmers/AssertPruneProgrammer.ts +76 -76
  72. package/src/programmers/AssertStringifyProgrammer.ts +74 -74
  73. package/src/programmers/CheckerProgrammer.ts +901 -875
  74. package/src/programmers/CloneProgrammer.ts +389 -389
  75. package/src/programmers/FeatureProgrammer.ts +500 -500
  76. package/src/programmers/IsCloneProgrammer.ts +86 -86
  77. package/src/programmers/IsParseProgrammer.ts +80 -80
  78. package/src/programmers/IsProgrammer.ts +212 -212
  79. package/src/programmers/IsPruneProgrammer.ts +81 -81
  80. package/src/programmers/IsStringifyProgrammer.ts +84 -84
  81. package/src/programmers/LiteralsProgrammer.ts +65 -65
  82. package/src/programmers/PruneProgrammer.ts +347 -347
  83. package/src/programmers/RandomProgrammer.ts +423 -423
  84. package/src/programmers/StringifyProgrammer.ts +798 -798
  85. package/src/programmers/TypiaProgrammer.ts +129 -129
  86. package/src/programmers/ValidateCloneProgrammer.ts +93 -93
  87. package/src/programmers/ValidateParseProgrammer.ts +78 -78
  88. package/src/programmers/ValidateProgrammer.ts +316 -316
  89. package/src/programmers/ValidatePruneProgrammer.ts +86 -86
  90. package/src/programmers/ValidateStringifyProgrammer.ts +92 -92
  91. package/src/programmers/helpers/CloneJoiner.ts +131 -131
  92. package/src/programmers/helpers/FunctionImporeter.ts +54 -54
  93. package/src/programmers/helpers/OptionPredicator.ts +15 -15
  94. package/src/programmers/helpers/PruneJoiner.ts +144 -144
  95. package/src/programmers/helpers/StringifyJoinder.ts +113 -113
  96. package/src/programmers/helpers/StringifyPredicator.ts +12 -12
  97. package/src/programmers/helpers/UnionExplorer.ts +275 -275
  98. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  99. package/src/programmers/internal/application_array.ts +36 -36
  100. package/src/programmers/internal/application_boolean.ts +17 -17
  101. package/src/programmers/internal/application_constant.ts +30 -30
  102. package/src/programmers/internal/application_default_string.ts +33 -33
  103. package/src/programmers/internal/application_native.ts +32 -32
  104. package/src/programmers/internal/application_number.ts +73 -73
  105. package/src/programmers/internal/application_object.ts +155 -154
  106. package/src/programmers/internal/application_schema.ts +213 -213
  107. package/src/programmers/internal/application_string.ts +45 -45
  108. package/src/programmers/internal/application_templates.ts +26 -26
  109. package/src/programmers/internal/application_tuple.ts +31 -29
  110. package/src/programmers/internal/check_array.ts +30 -30
  111. package/src/programmers/internal/check_custom.ts +31 -31
  112. package/src/programmers/internal/check_dynamic_properties.ts +194 -194
  113. package/src/programmers/internal/check_everything.ts +28 -28
  114. package/src/programmers/internal/check_native.ts +21 -21
  115. package/src/programmers/internal/check_string_tags.ts +67 -67
  116. package/src/programmers/internal/check_union_array_like.ts +271 -271
  117. package/src/programmers/internal/check_union_tuple.ts +33 -33
  118. package/src/programmers/internal/random_custom.ts +29 -29
  119. package/src/programmers/internal/stringify_dynamic_properties.ts +167 -167
  120. package/src/programmers/internal/stringify_native.ts +7 -7
  121. package/src/programmers/internal/stringify_regular_properties.ts +83 -83
  122. package/src/schemas/IJsonSchema.ts +130 -129
  123. package/src/transform.ts +17 -17
  124. package/src/transformers/CallExpressionTransformer.ts +177 -177
  125. package/src/transformers/FileTransformer.ts +47 -47
  126. package/src/transformers/NodeTransformer.ts +13 -13
  127. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +114 -114
  128. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  129. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  130. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  131. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  132. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  133. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  134. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  135. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  136. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  137. package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +39 -39
  138. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  139. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  140. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  141. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  142. package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +28 -28
  143. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +52 -52
  144. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  145. package/src/transformers/features/miscellaneous/RandomTransformer.ts +42 -42
  146. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  147. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  148. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  149. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  150. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  151. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  152. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  153. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  154. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  155. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +12 -12
  156. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  157. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  158. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +12 -12
  159. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  160. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  161. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  162. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  163. package/src/transformers/features/validators/CreateAssertTransformer.ts +13 -13
  164. package/src/transformers/features/validators/CreateIsTransformer.ts +11 -11
  165. package/src/transformers/features/validators/CreateValidateTransformer.ts +13 -13
  166. package/src/transformers/features/validators/IsTransformer.ts +11 -11
  167. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  168. package/src/transformers/internal/GenericTransformer.ts +97 -97
  169. package/src/utils/ArrayUtil.ts +44 -44
  170. package/src/utils/Escaper.ts +45 -45
  171. package/src/utils/MapUtil.ts +12 -12
  172. package/src/utils/PatternUtil.ts +30 -30
  173. package/src/utils/RandomGenerator.ts +81 -81
package/src/module.ts CHANGED
@@ -1,2043 +1,2043 @@
1
- import { $dictionary } from "./functional/$dictionary";
2
- import { Namespace } from "./functional/Namespace";
3
-
4
- import { IMetadataApplication } from "./metadata/IMetadataApplication";
5
- import { IJsonApplication } from "./schemas/IJsonApplication";
6
-
7
- import { Atomic } from "./typings/Atomic";
8
-
9
- import { MapUtil } from "./utils/MapUtil";
10
-
11
- import { CustomValidatorMap } from "./CustomValidatorMap";
12
- import { IRandomGenerator } from "./IRandomGenerator";
13
- import { IValidation } from "./IValidation";
14
- import { Primitive } from "./Primitive";
15
- import { TypeGuardError } from "./TypeGuardError";
16
-
17
- export * from "./schemas/IJsonApplication";
18
- export * from "./schemas/IJsonComponents";
19
- export * from "./schemas/IJsonSchema";
20
- export * from "./IRandomGenerator";
21
- export * from "./IValidation";
22
- export * from "./Primitive";
23
- export * from "./TypeGuardError";
24
-
25
- /* ===========================================================
26
- SINGLE FUNCTIONS
27
- - BASIC VALIDATORS
28
- - STRICT VALIDATORS
29
- - JSON FUNCTIONS
30
- - MISCELLANEOUS
31
- ==============================================================
32
- BASIC VALIDATORS
33
- ----------------------------------------------------------- */
34
- /**
35
- * Asserts a value type.
36
- *
37
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
38
- * reason, if the parametric value is not following the type `T`. Otherwise, the
39
- * value is following the type `T`, just input parameter would be returned.
40
- *
41
- * If what you want is not asserting but just knowing whether the parametric value is
42
- * following the type `T` or not, you can choose the {@link is} function instead.
43
- * Otherwise you want to know all the errors, {@link validate} is the way to go.
44
- *
45
- * On the other and, if you don't want to allow any superfluous property that is not
46
- * enrolled to the type `T`, you can use {@link assertEquals} function instead.
47
- *
48
- * @template T Type of the input value
49
- * @param input A value to be asserted
50
- * @returns Parametric input value
51
- * @throws A {@link TypeGuardError} instance with detailed reason
52
- *
53
- * @author Jeongho Nam - https://github.com/samchon
54
- */
55
- export function assert<T>(input: T): T;
56
-
57
- /**
58
- * Asserts a value type.
59
- *
60
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
61
- * reason, if the parametric value is not following the type `T`. Otherwise, the
62
- * value is following the type `T`, just input parameter would be returned.
63
- *
64
- * If what you want is not asserting but just knowing whether the parametric value is
65
- * following the type `T` or not, you can choose the {@link is} function instead.
66
- * Otherwise, you want to know all the errors, {@link validate} is the way to go.
67
- *
68
- * On the other and, if you don't want to allow any superfluous property that is not
69
- * enrolled to the type `T`, you can use {@link assertEquals} function instead.
70
- *
71
- * @template T Type of the input value
72
- * @param input A value to be asserted
73
- * @returns Parametric input value casted as `T`
74
- * @throws A {@link TypeGuardError} instance with detailed reason
75
- *
76
- * @author Jeongho Nam - https://github.com/samchon
77
- */
78
- export function assert<T>(input: unknown): T;
79
-
80
- /**
81
- * @internal
82
- */
83
- export function assert(): never {
84
- halt("assert");
85
- }
86
- Object.assign(assert, Namespace.assert("assert"));
87
-
88
- /**
89
- * Asserts a value type.
90
- *
91
- * Duplicated function of {@link assert} for `typescript-is` users.
92
- *
93
- * @template T Type of the input value
94
- * @param input A value to be asserted
95
- * @returns Parametric input value
96
- * @throws A {@link TypeGuardError} instance with detailed reason
97
- *
98
- * @author Jeongho Nam - https://github.com/samchon
99
- * @deprecated
100
- */
101
- export function assertType<T>(input: T): T;
102
-
103
- /**
104
- * Asserts a value type.
105
- *
106
- * Duplicated function of {@link assert} for `typescript-is` users.
107
- *
108
- * @template T Type of the input value
109
- * @param input A value to be asserted
110
- * @returns Parametric input value
111
- * @throws A {@link TypeGuardError} instance with detailed reason
112
- *
113
- * @author Jeongho Nam - https://github.com/samchon
114
- * @deprecated
115
- */
116
- export function assertType<T>(input: unknown): T;
117
-
118
- /**
119
- * @internal
120
- */
121
- export function assertType(): never {
122
- halt("assertType");
123
- }
124
- Object.assign(assertType, Namespace.assert("assertType"));
125
-
126
- /**
127
- * Tests a value type.
128
- *
129
- * Tests a parametric value type and returns whether it's following the type `T` or not.
130
- * If the parametric value is matched with the type `T`, `true` value would be returned.
131
- * Otherwise, the parametric value is not following the type `T`, `false` value would be
132
- * returned.
133
- *
134
- * If what you want is not just knowing whether the parametric value is following the
135
- * type `T` or not, but throwing an exception with detailed reason, you can choose
136
- * {@link assert} function instead. Also, if you want to know all the errors with
137
- * detailed reasons, {@link validate} function would be useful.
138
- *
139
- * On the other and, if you don't want to allow any superfluous property that is not
140
- * enrolled to the type `T`, you can use {@link equals} function instead.
141
- *
142
- * @template T Type of the input value
143
- * @param input A value to be tested
144
- * @returns Whether the parametric value is following the type `T` or not
145
- *
146
- * @author Jeongho Nam - https://github.com/samchon
147
- */
148
- export function is<T>(input: T): input is T;
149
-
150
- /**
151
- * Tests a value type.
152
- *
153
- * Tests a parametric value type and returns whether it's following the type `T` or not.
154
- * If the parametric value is matched with the type `T`, `true` value would be returned.
155
- * Otherwise, the parametric value is not following the type `T`, `false` value would be
156
- * returned.
157
- *
158
- * If what you want is not just knowing whether the parametric value is following the
159
- * type `T` or not, but throwing an exception with detailed reason, you can choose
160
- * {@link assert} function instead. Also, if you want to know all the errors with
161
- * detailed reasons, {@link validate} function would be useful.
162
- *
163
- * On the other and, if you don't want to allow any superfluous property that is not
164
- * enrolled to the type `T`, you can use {@link equals} function instead.
165
- *
166
- * @template T Type of the input value
167
- * @param input A value to be tested
168
- * @returns Whether the parametric value is following the type `T` or not
169
- *
170
- * @author Jeongho Nam - https://github.com/samchon
171
- */
172
- export function is<T>(input: unknown): input is T;
173
-
174
- /**
175
- * @internal
176
- */
177
- export function is(): never {
178
- halt("is");
179
- }
180
- Object.assign(is, Namespace.assert("is"));
181
-
182
- /**
183
- * Validates a value type.
184
- *
185
- * Validates a parametric value type and archives all the type errors into an
186
- * {@link IValidation.errors} array, if the parametric value is not following the
187
- * type `T`. Of course, if the parametric value is following the type `T`, the
188
- * {@link IValidation.errors} array would be empty and {@link IValidation.success}
189
- * would have the `true` value.
190
- *
191
- * If what you want is not finding all the error, but asserting the parametric value
192
- * type with exception throwing, you can choose {@link assert} function instead.
193
- * Otherwise, you just want to know whether the parametric value is matched with the
194
- * type `T`, {@link is} function is the way to go.
195
- *
196
- * On the other and, if you don't want to allow any superfluous property that is not
197
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
198
- *
199
- * @template Type of the input value
200
- * @param input A value to be validated
201
- * @returns Validation result
202
- *
203
- * @author Jeongho Nam - https://github.com/samchon
204
- */
205
- export function validate<T>(input: T): IValidation<T>;
206
-
207
- /**
208
- * Validates a value type.
209
- *
210
- * Validates a parametric value type and archives all the type errors into an
211
- * {@link IValidation.errors} array, if the parametric value is not following the
212
- * type `T`. Of course, if the parametric value is following the type `T`, the
213
- * {@link IValidation.errors} array would be empty and {@link IValidation.success}
214
- * would have the `true` value.
215
- *
216
- * If what you want is not finding all the error, but asserting the parametric value
217
- * type with exception throwing, you can choose {@link assert} function instead.
218
- * Otherwise, you just want to know whether the parametric value is matched with the
219
- * type `T`, {@link is} function is the way to go.
220
- *
221
- * On the other and, if you don't want to allow any superfluous property that is not
222
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
223
- *
224
- * @template Type of the input value
225
- * @param input A value to be validated
226
- * @returns Validation result
227
- *
228
- * @author Jeongho Nam - https://github.com/samchon
229
- */
230
- export function validate<T>(input: unknown): IValidation<T>;
231
-
232
- /**
233
- * @internal
234
- */
235
- export function validate(): never {
236
- halt("validate");
237
- }
238
- Object.assign(validate, Namespace.validate());
239
-
240
- /* -----------------------------------------------------------
241
- STRICT VALIDATORS
242
- ----------------------------------------------------------- */
243
- /**
244
- * Asserts equality between a value and its type.
245
- *
246
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
247
- * reason, if the parametric value is not following the type `T` or some superfluous
248
- * property that is not listed on the type `T` has been found. Otherwise, the value is
249
- * following the type `T` without any superfluous property, just input parameter would
250
- * be returned.
251
- *
252
- * If what you want is not asserting but just knowing whether the parametric value is
253
- * following the type `T` or not, you can choose the {@link equals} function instead.
254
- * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
255
- *
256
- * On the other hand, if you want to allow superfluous property that is not enrolled
257
- * to the type `T`, you can use {@link assert} function instead.
258
- *
259
- * @template T Type of the input value
260
- * @param input A value to be asserted
261
- * @returns Parametric input value
262
- * @throws A {@link TypeGuardError} instance with detailed reason
263
- *
264
- * @author Jeongho Nam - https://github.com/samchon
265
- */
266
- export function assertEquals<T>(input: T): T;
267
-
268
- /**
269
- * Asserts equality between a value and its type.
270
- *
271
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
272
- * reason, if the parametric value is not following the type `T` or some superfluous
273
- * property that is not listed on the type `T` has been found. Otherwise, the value is
274
- * following the type `T` without any superfluous property, just input parameter would
275
- * be returned.
276
- *
277
- * If what you want is not asserting but just knowing whether the parametric value is
278
- * following the type `T` or not, you can choose the {@link equals} function instead.
279
- * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
280
- *
281
- * On the other hand, if you want to allow superfluous property that is not enrolled
282
- * to the type `T`, you can use {@link assert} function instead.
283
- *
284
- * @template T Type of the input value
285
- * @param input A value to be asserted
286
- * @returns Parametric input value casted as `T`
287
- * @throws A {@link TypeGuardError} instance with detailed reason
288
- *
289
- * @author Jeongho Nam - https://github.com/samchon
290
- */
291
- export function assertEquals<T>(input: unknown): T;
292
-
293
- /**
294
- * @internal
295
- */
296
- export function assertEquals(): never {
297
- halt("assertEquals");
298
- }
299
- Object.assign(assertEquals, Namespace.assert("assertEquals"));
300
-
301
- /**
302
- * Tests equality between a value and its type.
303
- *
304
- * Tests a parametric value type and returns whether it's equivalent to the type `T`
305
- * or not. If the parametric value is matched with the type `T` and there's not any
306
- * superfluous property that is not listed on the type `T`, `true` value would be
307
- * returned. Otherwise, the parametric value is not following the type `T` or some
308
- * superfluous property exists, `false` value would be returned.
309
- *
310
- * If what you want is not just knowing whether the parametric value is following the
311
- * type `T` or not, but throwing an exception with detailed reason, you can choose
312
- * {@link assertEquals} function instead. Also, if you want to know all the errors with
313
- * detailed reasons, {@link validateEquals} function would be useful.
314
- *
315
- * On the other hand, if you want to allow superfluous property that is not enrolled
316
- * to the type `T`, you can use {@link is} function instead.
317
- *
318
- * @template T Type of the input value
319
- * @param input A value to be tested
320
- * @returns Whether the parametric value is equivalent to the type `T` or not
321
- *
322
- * @author Jeongho Nam - https://github.com/samchon
323
- */
324
- export function equals<T>(input: T): input is T;
325
-
326
- /**
327
- * Tests equality between a value and its type.
328
- *
329
- * Tests a parametric value type and returns whether it's equivalent to the type `T`
330
- * or not. If the parametric value is matched with the type `T` and there's not any
331
- * superfluous property that is not listed on the type `T`, `true` value would be
332
- * returned. Otherwise, the parametric value is not following the type `T` or some
333
- * superfluous property exists, `false` value would be returned.
334
- *
335
- * If what you want is not just knowing whether the parametric value is following the
336
- * type `T` or not, but throwing an exception with detailed reason, you can choose
337
- * {@link assertEquals} function instead. Also, if you want to know all the errors with
338
- * detailed reasons, {@link validateEquals} function would be useful.
339
- *
340
- * On the other hand, if you want to allow superfluous property that is not enrolled
341
- * to the type `T`, you can use {@link is} function instead.
342
- *
343
- * @template T Type of the input value
344
- * @param input A value to be tested
345
- * @returns Whether the parametric value is equivalent to the type `T` or not
346
- *
347
- * @author Jeongho Nam - https://github.com/samchon
348
- */
349
- export function equals<T>(input: unknown): input is T;
350
-
351
- /**
352
- * @internal
353
- */
354
- export function equals(): never {
355
- halt("equals");
356
- }
357
- Object.assign(equals, Namespace.is());
358
-
359
- /**
360
- * Validates equality between a value and its type.
361
- *
362
- * Validates a parametric value type and archives all the type errors into an
363
- * {@link IValidation.errors} array, if the parametric value is not following the
364
- * type `T` or some superfluous property that is not listed on the type `T` has been
365
- * found. Of course, if the parametric value is following the type `T` and no
366
- * superfluous property exists, the {@link IValidation.errors} array would be empty
367
- * and {@link IValidation.success} would have the `true` value.
368
- *
369
- * If what you want is not finding all the error, but asserting the parametric value
370
- * type with exception throwing, you can choose {@link assert} function instead.
371
- * Otherwise, you just want to know whether the parametric value is matched with the
372
- * type `T`, {@link is} function is the way to go.
373
- *
374
- * On the other and, if you don't want to allow any superfluous property that is not
375
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
376
- *
377
- * @template Type of the input value
378
- * @param input A value to be validated
379
- * @returns Validation result
380
- *
381
- * @author Jeongho Nam - https://github.com/samchon
382
- */
383
- export function validateEquals<T>(input: T): IValidation<T>;
384
-
385
- /**
386
- * Validates equality between a value and its type.
387
- *
388
- * Validates a parametric value type and archives all the type errors into an
389
- * {@link IValidation.errors} array, if the parametric value is not following the
390
- * type `T` or some superfluous property that is not listed on the type `T` has been
391
- * found. Of course, if the parametric value is following the type `T` and no
392
- * superfluous property exists, the {@link IValidation.errors} array would be empty
393
- * and {@link IValidation.success} would have the `true` value.
394
- *
395
- * If what you want is not finding all the error, but asserting the parametric value
396
- * type with exception throwing, you can choose {@link assert} function instead.
397
- * Otherwise, you just want to know whether the parametric value is matched with the
398
- * type `T`, {@link is} function is the way to go.
399
- *
400
- * On the other and, if you don't want to allow any superfluous property that is not
401
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
402
- *
403
- * @template Type of the input value
404
- * @param input A value to be validated
405
- * @returns Validation result
406
- *
407
- * @author Jeongho Nam - https://github.com/samchon
408
- */
409
- export function validateEquals<T>(input: unknown): IValidation<T>;
410
-
411
- /**
412
- * @internal
413
- */
414
- export function validateEquals(): never {
415
- halt("validateEquals");
416
- }
417
- Object.assign(validateEquals, Namespace.validate());
418
-
419
- /**
420
- * Custom validators.
421
- *
422
- * If you want to add a custom validation logic utilizing comment tags,
423
- * add a closure function with its tag and type name. Below example code
424
- * would helpful to understand how to use this instance.
425
- *
426
- * ```ts
427
- * typia.customValidators.insert("powerOf")("number")(
428
- * (text: string) => {
429
- * const denominator: number = Math.log(Number(text));
430
- * return (value: number) => {
431
- * value = Math.log(value) / denominator;
432
- * return value === Math.floor(value);
433
- * };
434
- * }
435
- * );
436
- * typia.customValidators.insert("dollar")("string")(
437
- * () => (value: string) => value.startsWith("$"),
438
- * );
439
- *
440
- * interface TagCustom {
441
- * /**
442
- * * @powerOf 10
443
- * *\/
444
- * powerOf: number;
445
- *
446
- * /**
447
- * * @dollar
448
- * *\/
449
- * dollar: string;
450
- * }
451
- * ```
452
- *
453
- * @author Jeongho Nam - https://github.com/samchon
454
- */
455
- export const customValidators: CustomValidatorMap = {
456
- size: (name?: string) =>
457
- name ? $dictionary.get(name)?.size ?? 0 : $dictionary.size,
458
- has: (name) => (type) => $dictionary.get(name)?.has(type) ?? false,
459
- get: (name) => (type) => $dictionary.get(name)?.get(type),
460
- insert: (name) => (type) => (closure) => {
461
- const internal = MapUtil.take($dictionary)(name, () => new Map());
462
- if (internal.has(type)) return false;
463
- internal.set(type, closure);
464
- return true;
465
- },
466
- erase: (name) => (type) => $dictionary.get(name)?.delete(type) ?? false,
467
- };
468
-
469
- /* -----------------------------------------------------------
470
- JSON FUNCTIONS
471
- ----------------------------------------------------------- */
472
- /**
473
- * > You must configure the generic argument `T`.
474
- *
475
- * JSON Schema Application.
476
- *
477
- * Creates a JSON schema application which contains both main JSON schemas and components.
478
- * Note that, all of the object types are stored in the {@link IJsonApplication.components}
479
- * property for the `$ref` referencing.
480
- *
481
- * Also, `typia.application()` has additional generic arguments, *Purpose*.
482
- * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
483
- * you should configure the *Purpose* appropriately.
484
- *
485
- * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
486
- * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
487
- * the tuple definition.
488
- *
489
- * @template Types Tuple of target types
490
- * @template Purpose Purpose of the JSON schema`
491
- * @template Prefix Prefix of the JSON components referenced by `$ref` tag
492
- * @return JSON schema application
493
- *
494
- * @author Jeongho Nam - https://github.com/samchon
495
- */
496
- export function application(): never;
497
-
498
- /**
499
- * JSON Schema Application.
500
- *
501
- * Creates a JSON schema application which contains both main JSON schemas and components.
502
- * Note that, all of the object types are stored in the {@link IJsonApplication.components}
503
- * property for the `$ref` referencing.
504
- *
505
- * Also, `typia.application()` has additional generic arguments, *Purpose*.
506
- * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
507
- * you should configure the *Purpose* appropriately.
508
- *
509
- * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
510
- * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
511
- * the tuple definition.
512
- *
513
- * @template Types Tuple of target types
514
- * @template Purpose Purpose of the JSON schema
515
- * @template Prefix Prefix of the JSON components referenced by `$ref` tag
516
- * @return JSON schema application
517
- *
518
- * @author Jeongho Nam - https://github.com/samchon
519
- */
520
- export function application<
521
- Types extends unknown[],
522
- Purpose extends "swagger" | "ajv" = "swagger",
523
- Prefix extends string = Purpose extends "swagger"
524
- ? "#/components/schemas"
525
- : "components#/schemas",
526
- >(): IJsonApplication;
527
-
528
- /**
529
- * @internal
530
- */
531
- export function application(): never {
532
- halt("application");
533
- }
534
-
535
- /**
536
- * > You must configure the generic argument `T`.
537
- *
538
- * Safe `JSON.parse()` function with type assertion.
539
- *
540
- * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
541
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
542
- * instance with type assertion.
543
- *
544
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
545
- * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
546
- * the parsed value would be returned.
547
- *
548
- * @template T Expected type of parsed value
549
- * @param input JSON string
550
- * @returns Parsed value
551
- *
552
- * @author Jeongho Nam - https://github.com/samchon
553
- */
554
- export function assertParse(input: string): never;
555
-
556
- /**
557
- * Safe `JSON.parse()` function with type assertion.
558
- *
559
- * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
560
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
561
- * instance with type assertion.
562
- *
563
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
564
- * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
565
- * the parsed value would be returned.
566
- *
567
- * @template T Expected type of parsed value
568
- * @param input JSON string
569
- * @returns Parsed value
570
- *
571
- * @author Jeongho Nam - https://github.com/samchon
572
- */
573
- export function assertParse<T>(input: string): Primitive<T>;
574
-
575
- /**
576
- * @internal
577
- */
578
- export function assertParse<T>(): Primitive<T> {
579
- halt("assertParse");
580
- }
581
- Object.assign(assertParse, Namespace.assert("assertParse"));
582
-
583
- /**
584
- * > You must configure the generic argument `T`.
585
- *
586
- * Safe `JSON.parse()` function with type checking.
587
- *
588
- * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
589
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
590
- * instance with type checking.
591
- *
592
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
593
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
594
- * value would be returned.
595
- *
596
- * @template T Expected type of parsed value
597
- * @param input JSON string
598
- * @returns Parsed value when exact type, otherwise `null`
599
- *
600
- * @author Jeongho Nam - https://github.com/samchon
601
- */
602
- export function isParse(input: string): never;
603
-
604
- /**
605
- * Safe `JSON.parse()` function with type checking.
606
- *
607
- * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
608
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
609
- * instance with type checking.
610
- *
611
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
612
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
613
- * value would be returned.
614
- *
615
- * @template T Expected type of parsed value
616
- * @param input JSON string
617
- * @returns Parsed value when exact type, otherwise `null`
618
- *
619
- * @author Jeongho Nam - https://github.com/samchon
620
- */
621
- export function isParse<T>(input: string): Primitive<T> | null;
622
-
623
- /**
624
- * @internal
625
- */
626
- export function isParse<T>(): Primitive<T> | null {
627
- halt("isParse");
628
- }
629
- Object.assign(isParse, is);
630
-
631
- /**
632
- * > You must configure the generic argument `T`.
633
- *
634
- * Safe `JSON.parse()` function with detailed type validation.
635
- *
636
- * `typia.validateParse()` is a combination function of `JSON.parse()` and
637
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
638
- * to a `T` typed instance with detailed type validation.
639
- *
640
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
641
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
642
- * there's no problem on the parsed value, the parsed value would be stored in `data`
643
- * property of the output {@link IValidation.ISuccess} instance.
644
- *
645
- * @template T Expected type of parsed value
646
- * @param input JSON string
647
- * @returns Validation result with JSON parsed value
648
- *
649
- * @author Jeongho Nam - https://github.com/samchon
650
- */
651
- export function validateParse(input: string): never;
652
-
653
- /**
654
- * Safe `JSON.parse()` function with detailed type validation.
655
- *
656
- * `typia.validateParse()` is a combination function of `JSON.parse()` and
657
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
658
- * to a `T` typed instance with detailed type validation.
659
- *
660
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
661
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
662
- * there's no problem on the parsed value, the parsed value would be stored in `data`
663
- * property of the output {@link IValidation.ISuccess} instance.
664
- *
665
- * @template T Expected type of parsed value
666
- * @param input JSON string
667
- * @returns Validation result with JSON parsed value
668
- *
669
- * @author Jeongho Nam - https://github.com/samchon
670
- */
671
- export function validateParse<T>(input: string): IValidation<Primitive<T>>;
672
-
673
- /**
674
- * @internal
675
- */
676
- export function validateParse<T>(): IValidation<Primitive<T>> {
677
- halt("validateParse");
678
- }
679
- Object.assign(validateParse, validate);
680
-
681
- /**
682
- * 8x faster `JSON.stringify()` function.
683
- *
684
- * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x faster
685
- * than the native `JSON.stringify()` function. The 5x faster principle is because
686
- * it writes an optimized JSON conversion plan, only for the type `T`.
687
- *
688
- * For reference, this `typia.stringify()` does not validate the input value type.
689
- * It just believes that the input value is following the type `T`. Therefore, if you
690
- * can't ensure the input value type, it would be better to call one of below functions
691
- * instead.
692
- *
693
- * - {@link assertStringify}
694
- * - {@link isStringify}
695
- * - {@link validateStringify}
696
- *
697
- * @template T Type of the input value
698
- * @param input A value to be converted
699
- * @return JSON string value
700
- *
701
- * @author Jeongho Nam - https://github.com/samchon
702
- */
703
- export function stringify<T>(input: T): string;
704
-
705
- /**
706
- * @internal
707
- */
708
- export function stringify(): never {
709
- halt("stringify");
710
- }
711
- Object.assign(stringify, Namespace.stringify("stringify"));
712
-
713
- /**
714
- * 5x faster `JSON.stringify()` function with type assertion.
715
- *
716
- * `typia.assertStringify()` is a combination function of {@link assert} and
717
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
718
- * Notation) string, with type assertion.
719
- *
720
- * In such reason, when `input` value is not matched with the type `T`, it throws an
721
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
722
- * string would be returned.
723
- *
724
- * For reference, with type assertion, it is even 5x times faster than the native
725
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
726
- * with confidence.
727
- *
728
- * @template T Type of the input value
729
- * @param input A value to be asserted and converted
730
- * @return JSON string value
731
- *
732
- * @author Jeongho Nam - https://github.com/samchon
733
- */
734
- export function assertStringify<T>(input: T): string;
735
-
736
- /**
737
- * 5x faster `JSON.stringify()` function with type assertion.
738
- *
739
- * `typia.assertStringify()` is a combination function of {@link assert} and
740
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
741
- * Notation) string, with type assertion.
742
- *
743
- * In such reason, when `input` value is not matched with the type `T`, it throws an
744
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
745
- * string would be returned.
746
- *
747
- * For reference, with type assertion, it is even 5x times faster than the native
748
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
749
- * with confidence.
750
- *
751
- * @template T Type of the input value
752
- * @param input A value to be asserted and converted
753
- * @return JSON string value
754
- *
755
- * @author Jeongho Nam - https://github.com/samchon
756
- */
757
- export function assertStringify<T>(input: T): unknown;
758
-
759
- /**
760
- * @internal
761
- */
762
- export function assertStringify(): string {
763
- halt("assertStringify");
764
- }
765
- Object.assign(assertStringify, Namespace.assert("assertStringify"));
766
- Object.assign(assertStringify, Namespace.stringify("assertStringify"));
767
-
768
- /**
769
- * 7x faster `JSON.stringify()` function with type checking.
770
- *
771
- * `typia.stringify()` is a combination function of {@link is} and
772
- * {@link stringify}. Therefore, it converts an input value to JSON
773
- * (JavaScript Object Notation) string, with type checking.
774
- *
775
- * In such reason, when `input` value is not matched with the type `T`, it returns
776
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
777
- * be returned.
778
- *
779
- * For reference, with type checking, it is even 7x times faster than the native
780
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
781
- * with confidence.
782
- *
783
- * @template T Type of the input value
784
- * @param input A value to be checked and converted
785
- * @return JSON string value when exact type, otherwise null
786
- *
787
- * @author Jeongho Nam - https://github.com/samchon
788
- */
789
- export function isStringify<T>(input: T): string | null;
790
-
791
- /**
792
- * 7x faster `JSON.stringify()` function with type checking.
793
- *
794
- * `typia.isStringify()` is a combination function of {@link is} and
795
- * {@link stringify}. Therefore, it converts an input value to JSON
796
- * (JavaScript Object Notation) string, with type checking.
797
- *f
798
- * In such reason, when `input` value is not matched with the type `T`, it returns
799
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
800
- * be returned.
801
- *
802
- * For reference, with type checking, it is even 7x times faster than the native
803
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
804
- * with confidence.
805
- *
806
- * @template T Type of the input value
807
- * @param input A value to be checked and converted
808
- * @return JSON string value when exact type, otherwise null
809
- *
810
- * @author Jeongho Nam - https://github.com/samchon
811
- */
812
- export function isStringify<T>(input: unknown): string | null;
813
-
814
- /**
815
- * @internal
816
- */
817
- export function isStringify(): string | null {
818
- halt("isStringify");
819
- }
820
-
821
- Object.assign(isStringify, Namespace.is());
822
- Object.assign(isStringify, Namespace.stringify("isStringify"));
823
-
824
- /**
825
- * 5x faster `JSON.stringify()` function with detailed type validation.
826
- *
827
- * `typia.validateStringify()` is a combination function of {@link validate} and
828
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
829
- * Notation) string, with detailed type validation.
830
- *
831
- * In such reason, when `input` value is not matched with the type `T`, it returns
832
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
833
- * problem on the `input` value, JSON string would be stored in `data` property of
834
- * the output {@link IValidation.ISuccess} instance.
835
- *
836
- * For reference, with detailed type validation, it is even 5x times faster than the
837
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
838
- * with confidence.
839
- *
840
- * @template T Type of the input value
841
- * @param input A value to be checked and converted
842
- * @returns Validation result with JSON string value
843
- *
844
- * @author Jeongho Nam - https://github.com/samchon
845
- */
846
- export function validateStringify<T>(input: T): IValidation<string>;
847
-
848
- /**
849
- * 5x faster `JSON.stringify()` function with detailed type validation.
850
- *
851
- * `typia.validateStringify()` is a combination function of {@link validate} and
852
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
853
- * Notation) string, with detailed type validation.
854
- *
855
- * In such reason, when `input` value is not matched with the type `T`, it returns
856
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
857
- * problem on the `input` value, JSON string would be stored in `data` property of
858
- * the output {@link IValidation.ISuccess} instance.
859
- *
860
- * For reference, with detailed type validation, it is even 5x times faster than the
861
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
862
- * with confidence.
863
- *
864
- * @template T Type of the input value
865
- * @param input A value to be checked and converted
866
- * @returns Validation result with JSON string value
867
- *
868
- * @author Jeongho Nam - https://github.com/samchon
869
- */
870
- export function validateStringify<T>(input: unknown): IValidation<string>;
871
-
872
- /**
873
- * @internal
874
- */
875
- export function validateStringify(): IValidation<string> {
876
- halt("validateStringify");
877
- }
878
- Object.assign(validateStringify, Namespace.validate());
879
- Object.assign(validateStringify, Namespace.stringify("validateStringify"));
880
-
881
- /* -----------------------------------------------------------
882
- MISCELLANEOUS
883
- ----------------------------------------------------------- */
884
- /**
885
- * @internal
886
- */
887
- export function metadata(): never;
888
-
889
- /**
890
- * @internal
891
- */
892
- export function metadata<Types extends unknown[]>(): IMetadataApplication;
893
-
894
- /**
895
- * @internal
896
- */
897
- export function metadata(): never {
898
- halt("metadata");
899
- }
900
-
901
- /**
902
- * > You must configure the generic argument `T`.
903
- *
904
- * Generate random data.
905
- *
906
- * Generates a random data following type the `T`.
907
- *
908
- * For reference, this `typia.random()` function generates only primitive type.
909
- * If there're some methods in the type `T` or its nested instances, those would
910
- * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
911
- * would be generated instead.
912
- *
913
- * @template T Type of data to generate
914
- * @param generator Random data generator
915
- * @return Randomly generated data
916
- *
917
- * @author Jeongho Nam - https://github.com/samchon
918
- */
919
- export function random(generator?: Partial<IRandomGenerator>): never;
920
-
921
- /**
922
- * Generate random data.
923
- *
924
- * Generates a random data following type the `T`.
925
- *
926
- * For reference, this `typia.random()` function generates only primitive type.
927
- * If there're some methods in the type `T` or its nested instances, those would
928
- * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
929
- * would be generated instead.
930
- *
931
- * @template T Type of data to generate
932
- * @param generator Random data generator
933
- * @return Randomly generated data
934
- *
935
- * @author Jeongho Nam - https://github.com/samchon
936
- */
937
- export function random<T>(generator?: Partial<IRandomGenerator>): Primitive<T>;
938
-
939
- /**
940
- * @internal
941
- */
942
- export function random(): never {
943
- halt("random");
944
- }
945
- Object.assign(random, Namespace.random());
946
-
947
- /**
948
- * > You must configure the generic argument `T`.
949
- *
950
- * Union literal type to array.
951
- *
952
- * Converts a union literal type to an array of its members.
953
- *
954
- * ```typescript
955
- * literals<"A" | "B" | 1>; // [1, 2, 3] as const
956
- * ```
957
- *
958
- * @template T Union literal type
959
- * @return Array of union literal type's members
960
- *
961
- * @author Jeongho Nam - https://github.com/samchon
962
- */
963
- export function literals(): never;
964
-
965
- /**
966
- * Union literal type to array.
967
- *
968
- * Converts a union literal type to an array of its members.
969
- *
970
- * ```typescript
971
- * literals<"A" | "B" | 1>; // [1, 2, 3] as const
972
- * ```
973
- *
974
- * @template T Union literal type
975
- * @return Array of union literal type's members
976
- *
977
- * @author Jeongho Nam - https://github.com/samchon
978
- */
979
- export function literals<T extends Atomic.Type>(): T[];
980
-
981
- /**
982
- * @internal
983
- */
984
- export function literals(): never {
985
- halt("literals");
986
- }
987
-
988
- /**
989
- * Clone a data.
990
- *
991
- * Clones an instance following type `T`. If the target *input* value or its member
992
- * variable contains a class instance that is having a `toJSON()` method, its return
993
- * value would be cloned.
994
- *
995
- * For reference, this `typia.clone()` function does not validate the input value type.
996
- * It just believes that the input value is following the type `T`. Therefore, if you
997
- * can't ensure the input value type, it would be better to call {@link assertClone}
998
- * function instead.
999
- *
1000
- * @template T Type of the input value
1001
- * @param input A value to be cloned
1002
- * @return Cloned data
1003
- *
1004
- * @author Jeongho Nam - https://github.com/samchon
1005
- */
1006
- export function clone<T>(input: T): Primitive<T>;
1007
-
1008
- /**
1009
- * @internal
1010
- */
1011
- export function clone(): never {
1012
- halt("clone");
1013
- }
1014
- Object.assign(clone, Namespace.clone("clone"));
1015
-
1016
- /**
1017
- * Clone a data with type assertion.
1018
- *
1019
- * Clones an instance following type `T`, with type assertion. If the target `input`
1020
- * value or its member variable contains a class instance that is having a `toJSON()`
1021
- * method, its return value would be cloned.
1022
- *
1023
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1024
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
1025
- * data would be returned.
1026
- *
1027
- * @template T Type of the input value
1028
- * @param input A value to be cloned
1029
- * @return Cloned data
1030
- *
1031
- * @author Jeongho Nam - https://github.com/samchon
1032
- */
1033
- export function assertClone<T>(input: T): Primitive<T>;
1034
-
1035
- /**
1036
- * Clone a data with type assertion.
1037
- *
1038
- * Clones an instance following type `T`, with type assertion. If the target `input`
1039
- * value or its member variable contains a class instance that is having a `toJSON()`
1040
- * method, its return value would be cloned.
1041
- *
1042
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1043
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
1044
- * data would be returned.
1045
- *
1046
- * @template T Type of the input value
1047
- * @param input A value to be cloned
1048
- * @return Cloned data
1049
- *
1050
- * @author Jeongho Nam - https://github.com/samchon
1051
- */
1052
- export function assertClone<T>(input: unknown): Primitive<T>;
1053
-
1054
- /**
1055
- * @internal
1056
- */
1057
- export function assertClone(): never {
1058
- halt("assertClone");
1059
- }
1060
- Object.assign(assertClone, Namespace.assert("assertClone"));
1061
- Object.assign(assertClone, Namespace.clone("assertClone"));
1062
-
1063
- /**
1064
- * Clone a data with type checking.
1065
- *
1066
- * Clones an instance following type `T`, with type checking. If the target `input`
1067
- * value or its member variable contains a class instance that is having a `toJSON()`
1068
- * method, its return value would be cloned.
1069
- *
1070
- * In such reason, when `input` value is not matched with the type `T`, it returns
1071
- * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
1072
- * data would be returned.
1073
- *
1074
- * @template T Type of the input value
1075
- * @param input A value to be cloned
1076
- * @return Cloned data when exact type, otherwise null
1077
- *
1078
- * @author Jeongho Nam - https://github.com/samchon
1079
- */
1080
- export function isClone<T>(input: T): Primitive<T> | null;
1081
-
1082
- /**
1083
- * Clone a data with type checking.
1084
- *
1085
- * Clones an instance following type `T`, with type checking. If the target `input`
1086
- * value or its member variable contains a class instance that is having a `toJSON()`
1087
- * method, its return value would be cloned.
1088
- *
1089
- * In such reason, when `input` value is not matched with the type `T`, it returns
1090
- * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
1091
- * data would be returned.
1092
- *
1093
- * @template T Type of the input value
1094
- * @param input A value to be cloned
1095
- * @return Cloned data when exact type, otherwise null
1096
- *
1097
- * @author Jeongho Nam - https://github.com/samchon
1098
- */
1099
- export function isClone<T>(input: unknown): Primitive<T> | null;
1100
-
1101
- /**
1102
- * @internal
1103
- */
1104
- export function isClone(): never {
1105
- halt("isClone");
1106
- }
1107
- Object.assign(isClone, Namespace.is());
1108
- Object.assign(isClone, Namespace.clone("isClone"));
1109
-
1110
- /**
1111
- * Clone a data with detailed type validation.
1112
- *
1113
- * Clones an instance following type `T`, with detailed type validation. If the target
1114
- * `input` value or its member variable contains a class instance that is having a
1115
- * `toJSON()` method, its return value would be cloned.
1116
- *
1117
- * In such reason, when `input` value is not matched with the type `T`, it returns
1118
- * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1119
- * value, cloned data would be stored in `data` property of the output
1120
- * {@link IValidation.Success} instance.
1121
- *
1122
- * @template T Type of the input value
1123
- * @param input A value to be cloned
1124
- * @returns Validation result with cloned value
1125
- */
1126
- export function validateClone<T>(input: T): IValidation<Primitive<T>>;
1127
-
1128
- /**
1129
- * Clone a data with detailed type validation.
1130
- *
1131
- * Clones an instance following type `T`, with detailed type validation. If the target
1132
- * `input` value or its member variable contains a class instance that is having a
1133
- * `toJSON()` method, its return value would be cloned.
1134
- *
1135
- * In such reason, when `input` value is not matched with the type `T`, it returns
1136
- * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1137
- * value, cloned data would be stored in `data` property of the output
1138
- * {@link IValidation.Success} instance.
1139
- *
1140
- * @template T Type of the input value
1141
- * @param input A value to be cloned
1142
- * @returns Validation result with cloned value
1143
- */
1144
- export function validateClone<T>(input: unknown): IValidation<Primitive<T>>;
1145
-
1146
- /**
1147
- * @internal
1148
- */
1149
- export function validateClone(): never {
1150
- halt("validateClone");
1151
- }
1152
- Object.assign(validateClone, Namespace.validate());
1153
- Object.assign(validateClone, Namespace.clone("validateClone"));
1154
-
1155
- /**
1156
- * Prune, erase superfluous properties.
1157
- *
1158
- * Remove every superfluous properties from the `input` object, even including nested
1159
- * objects. Note that, as every superfluous properties would be deleted, you never can
1160
- * read those superfluous properties after calling this `prune()` function.
1161
- *
1162
- * For reference, this `typia.prune()` function does not validate the input value type.
1163
- * It just believes that the input value is following the type `T`. Therefore, if you
1164
- * can't ensure the input value type, it would better to call one of below functions
1165
- * instead.
1166
- *
1167
- * - {@link assertPrune}
1168
- * - {@link isPrune}
1169
- * - {@link validatePrune}
1170
- *
1171
- * @template T Type of the input value
1172
- * @param input Target instance to prune
1173
- *
1174
- * @author Jeongho Nam - https://github.com/samchon
1175
- */
1176
- export function prune<T extends object>(input: T): void;
1177
-
1178
- /**
1179
- * @internal
1180
- */
1181
- export function prune(): never {
1182
- halt("prune");
1183
- }
1184
- Object.assign(prune, Namespace.prune("prune"));
1185
-
1186
- /**
1187
- * Prune, erase superfluous properties, with type assertion.
1188
- *
1189
- * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1190
- * Therefore, it removes every superfluous properties from the `input` object including
1191
- * nested objects, with type assertion.
1192
- *
1193
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1194
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1195
- * every superfluous properties would be removed, including nested objects.
1196
- *
1197
- * @template T Type of the input value
1198
- * @param input Target instance to assert and prune
1199
- *
1200
- * @author Jeongho Nam - https://github.com/samchon
1201
- */
1202
- export function assertPrune<T>(input: T): T;
1203
-
1204
- /**
1205
- * Prune, erase superfluous properties, with type assertion.
1206
- *
1207
- * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1208
- * Therefore, it removes every superfluous properties from the `input` object including
1209
- * nested objects, with type assertion.
1210
- *
1211
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1212
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1213
- * every superfluous properties would be removed, including nested objects.
1214
- *
1215
- * @template T Type of the input value
1216
- * @param input Target instance to assert and prune
1217
- *
1218
- * @author Jeongho Nam - https://github.com/samchon
1219
- */
1220
- export function assertPrune<T>(input: unknown): T;
1221
-
1222
- /**
1223
- * @internal
1224
- */
1225
- export function assertPrune(): unknown {
1226
- halt("assertPrune");
1227
- }
1228
- Object.assign(assertPrune, Namespace.assert("assertPrune"));
1229
- Object.assign(assertPrune, Namespace.prune("assertPrune"));
1230
-
1231
- /**
1232
- * Prune, erase superfluous properties, with type checking.
1233
- *
1234
- * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1235
- * Therefore, it removes every superfluous properties from the `input` object including
1236
- * nested objects, with type checking.
1237
- *
1238
- * In such reason, when `input` value is not matched with the type `T`, it returns
1239
- * `false` value. Otherwise, there's no problem on the `input` value, it returns
1240
- * `true` after removing every superfluous properties, including nested objects.
1241
- *
1242
- * @template T Type of the input value
1243
- * @param input Target instance to check and prune
1244
- * @returns Whether the parametric value is following the type `T` or not
1245
- *
1246
- * @author Jeongho Nam - https://github.com/samchon
1247
- */
1248
- export function isPrune<T>(input: T): input is T;
1249
-
1250
- /**
1251
- * Prune, erase superfluous properties, with type checking.
1252
- *
1253
- * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1254
- * Therefore, it removes every superfluous properties from the `input` object including
1255
- * nested objects, with type checking.
1256
- *
1257
- * In such reason, when `input` value is not matched with the type `T`, it returns
1258
- * `false` value. Otherwise, there's no problem on the `input` value, it returns
1259
- * `true` after removing every superfluous properties, including nested objects.
1260
- *
1261
- * @template T Type of the input value
1262
- * @param input Target instance to check and prune
1263
- * @returns Whether the parametric value is following the type `T` or not
1264
- *
1265
- * @author Jeongho Nam - https://github.com/samchon
1266
- */
1267
- export function isPrune<T>(input: unknown): input is T;
1268
-
1269
- /**
1270
- * @internal
1271
- */
1272
- export function isPrune(): never {
1273
- halt("isPrune");
1274
- }
1275
- Object.assign(isPrune, Namespace.is());
1276
- Object.assign(isPrune, Namespace.prune("isPrune"));
1277
-
1278
- /**
1279
- * Prune, erase superfluous properties, with type validation.
1280
- *
1281
- * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1282
- * Therefore, it removes every superfluous properties from the `input` object including
1283
- * nested objects, with type validation.
1284
- *
1285
- * In such reason, when `input` value is not matched with the type `T`, it returns
1286
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1287
- * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1288
- * removing every superfluous properties, including nested objects.
1289
- *
1290
- * @template T Type of the input value
1291
- * @param input Target instance to validate and prune
1292
- * @returns Validation result
1293
- *
1294
- * @author Jeongho Nam - https://github.com/samchon
1295
- */
1296
- export function validatePrune<T>(input: T): IValidation<T>;
1297
-
1298
- /**
1299
- * Prune, erase superfluous properties, with type validation.
1300
- *
1301
- * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1302
- * Therefore, it removes every superfluous properties from the `input` object including
1303
- * nested objects, with type validation.
1304
- *
1305
- * In such reason, when `input` value is not matched with the type `T`, it returns
1306
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1307
- * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1308
- * removing every superfluous properties, including nested objects.
1309
- *
1310
- * @template T Type of the input value
1311
- * @param input Target instance to validate and prune
1312
- * @returns Validation result
1313
- *
1314
- * @author Jeongho Nam - https://github.com/samchon
1315
- */
1316
- export function validatePrune<T>(input: unknown): IValidation<T>;
1317
-
1318
- /**
1319
- * @internal
1320
- */
1321
- export function validatePrune<T>(): IValidation<T> {
1322
- halt("validatePrune");
1323
- }
1324
- Object.assign(validatePrune, Namespace.prune("validatePrune"));
1325
- Object.assign(validatePrune, Namespace.validate());
1326
-
1327
- /* ===========================================================
1328
- FACTORY FUNCTIONS
1329
- - BASIC VALIDATORS
1330
- - STRICT VALIDATORS
1331
- - JSON FUNCTIONS
1332
- - MISCELLANEOUS
1333
- ==============================================================
1334
- BASIC VALIDATORS
1335
- ----------------------------------------------------------- */
1336
- /**
1337
- * Creates a reusable {@link assert} function.
1338
- *
1339
- * @danger You have to specify the generic argument `T`
1340
- * @return Nothing until specifying the generic argument `T`
1341
- * @throws compile error
1342
- *
1343
- * @author Jeongho Nam - https://github.com/samchon
1344
- */
1345
- export function createAssert(): never;
1346
-
1347
- /**
1348
- * Creates a reusable {@link assert} function.
1349
- *
1350
- * @template T Type of the input value
1351
- * @returns A reusable `assert` function
1352
- *
1353
- * @author Jeongho Nam - https://github.com/samchon
1354
- */
1355
- export function createAssert<T>(): (input: unknown) => T;
1356
-
1357
- /**
1358
- * @internal
1359
- */
1360
- export function createAssert<T>(): (input: unknown) => T {
1361
- halt("createAssert");
1362
- }
1363
- Object.assign(createAssert, assert);
1364
-
1365
- /**
1366
- * Creates a reusable {@link assertType} function.
1367
- *
1368
- * Duplicated function of {@link createAssert} for `typescript-is` users.
1369
- *
1370
- * @danger You have to specify the generic argument `T`
1371
- * @return Nothing until specifying the generic argument `T`
1372
- * @throws compile error
1373
- *
1374
- * @author Jeongho Nam - https://github.com/samchon
1375
- * @deprecated
1376
- */
1377
- export function createAssertType(): never;
1378
-
1379
- /**
1380
- * Creates a reusable {@link assertType} function.
1381
- *
1382
- * Duplicated function of {@link createAssert} for `typescript-is` users.
1383
- *
1384
- * @template T Type of the input value
1385
- * @returns A reusable `assert` function
1386
- *
1387
- * @author Jeongho Nam - https://github.com/samchon
1388
- * @deprecated
1389
- */
1390
- export function createAssertType<T>(): (input: unknown) => T;
1391
-
1392
- /**
1393
- * @internal
1394
- */
1395
- export function createAssertType<T>(): (input: unknown) => T {
1396
- halt("createAssertType");
1397
- }
1398
- Object.assign(createAssertType, assertType);
1399
-
1400
- /**
1401
- * Creates a reusable {@link is} function.
1402
- *
1403
- * @danger You have to specify the generic argument `T`
1404
- * @return Nothing until specifying the generic argument `T`
1405
- * @throws compile error
1406
- *
1407
- * @author Jeongho Nam - https://github.com/samchon
1408
- */
1409
- export function createIs(): never;
1410
-
1411
- /**
1412
- * Creates a reusable {@link is} function.
1413
- *
1414
- * @template T Type of the input value
1415
- * @returns A reusable `is` function
1416
- *
1417
- * @author Jeongho Nam - https://github.com/samchon
1418
- */
1419
- export function createIs<T>(): (input: unknown) => input is T;
1420
-
1421
- /**
1422
- * @internal
1423
- */
1424
- export function createIs<T>(): (input: unknown) => input is T {
1425
- halt("createIs");
1426
- }
1427
- Object.assign(createIs, is);
1428
-
1429
- /**
1430
- * Creates a reusable {@link validate} function.
1431
- *
1432
- * @danger You have to specify the generic argument `T`
1433
- * @return Nothing until specifying the generic argument `T`
1434
- * @throws compile error
1435
- *
1436
- * @author Jeongho Nam - https://github.com/samchon
1437
- */
1438
- export function createValidate(): never;
1439
-
1440
- /**
1441
- * Creates a reusable {@link validate} function.
1442
- *
1443
- * @template T Type of the input value
1444
- * @returns A reusable `validate` function
1445
- *
1446
- * @author Jeongho Nam - https://github.com/samchon
1447
- */
1448
- export function createValidate<T>(): (input: unknown) => IValidation<T>;
1449
-
1450
- /**
1451
- * @internal
1452
- */
1453
- export function createValidate(): (input: unknown) => IValidation {
1454
- halt("createValidate");
1455
- }
1456
- Object.assign(createValidate, validate);
1457
-
1458
- /* -----------------------------------------------------------
1459
- STRICT VALIDATORS
1460
- ----------------------------------------------------------- */
1461
- /**
1462
- * Creates a reusable {@link assertEquals} function.
1463
- *
1464
- * @danger You have to specify the generic argument `T`
1465
- * @return Nothing until specifying the generic argument `T`
1466
- * @throws compile error
1467
- *
1468
- * @author Jeongho Nam - https://github.com/samchon
1469
- */
1470
- export function createAssertEquals(): never;
1471
-
1472
- /**
1473
- * Creates a reusable {@link assertEquals} function.
1474
- *
1475
- * @template T Type of the input value
1476
- * @returns A reusable `assertEquals` function
1477
- *
1478
- * @author Jeongho Nam - https://github.com/samchon
1479
- */
1480
- export function createAssertEquals<T>(): (input: unknown) => T;
1481
-
1482
- /**
1483
- * @internal
1484
- */
1485
- export function createAssertEquals<T>(): (input: unknown) => T {
1486
- halt("createAssertEquals");
1487
- }
1488
- Object.assign(createAssertEquals, assertEquals);
1489
-
1490
- /**
1491
- * Creates a reusable {@link equals} function.
1492
- *
1493
- * @danger You have to specify the generic argument `T`
1494
- * @return Nothing until specifying the generic argument `T`
1495
- * @throws compile error
1496
- *
1497
- * @author Jeongho Nam - https://github.com/samchon
1498
- */
1499
- export function createEquals(): never;
1500
-
1501
- /**
1502
- * Creates a reusable {@link equals} function.
1503
- *
1504
- * @template T Type of the input value
1505
- * @returns A reusable `equals` function
1506
- *
1507
- * @author Jeongho Nam - https://github.com/samchon
1508
- */
1509
- export function createEquals<T>(): (input: unknown) => input is T;
1510
-
1511
- /**
1512
- * @internal
1513
- */
1514
- export function createEquals<T>(): (input: unknown) => input is T {
1515
- halt("createEquals");
1516
- }
1517
- Object.assign(createEquals, equals);
1518
-
1519
- /**
1520
- * Creates a reusable {@link validateEquals} function.
1521
- *
1522
- * @danger You have to specify the generic argument `T`
1523
- * @return Nothing until specifying the generic argument `T`
1524
- * @throws compile error
1525
- *
1526
- * @author Jeongho Nam - https://github.com/samchon
1527
- */
1528
- export function createValidateEquals(): never;
1529
-
1530
- /**
1531
- * Creates a reusable {@link validateEquals} function.
1532
- *
1533
- * @template T Type of the input value
1534
- * @returns A reusable `validateEquals` function
1535
- *
1536
- * @author Jeongho Nam - https://github.com/samchon
1537
- */
1538
- export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
1539
-
1540
- /**
1541
- * @internal
1542
- */
1543
- export function createValidateEquals(): (input: unknown) => IValidation {
1544
- halt("createValidateEquals");
1545
- }
1546
- Object.assign(createValidateEquals, validateEquals);
1547
-
1548
- /* -----------------------------------------------------------
1549
- JSON FUNCTIONS
1550
- ----------------------------------------------------------- */
1551
- /**
1552
- * Creates a reusable {@link isParse} function.
1553
- *
1554
- * @danger You have to specify the generic argument `T`
1555
- * @return Nothing until specifying the generic argument `T`
1556
- * @throws compile error
1557
- *
1558
- * @author Jeongho Nam - https://github.com/samchon
1559
- */
1560
- export function createIsParse(): never;
1561
-
1562
- /**
1563
- * Creates a reusable {@link isParse} function.
1564
- *
1565
- * @template T Expected type of parsed value
1566
- * @returns A reusable `isParse` function
1567
- *
1568
- * @author Jeongho Nam - https://github.com/samchon
1569
- */
1570
- export function createIsParse<T>(): (input: string) => Primitive<T> | null;
1571
-
1572
- /**
1573
- * @internal
1574
- */
1575
- export function createIsParse<T>(): (input: string) => Primitive<T> | null {
1576
- halt("createIsParse");
1577
- }
1578
- Object.assign(createIsParse, isParse);
1579
-
1580
- /**
1581
- * Creates a reusable {@link assertParse} function.
1582
- *
1583
- * @danger You have to specify the generic argument `T`
1584
- * @return Nothing until specifying the generic argument `T`
1585
- * @throws compile error
1586
- *
1587
- * @author Jeongho Nam - https://github.com/samchon
1588
- */
1589
- export function createAssertParse(): never;
1590
-
1591
- /**
1592
- * Creates a reusable {@link assertParse} function.
1593
- *
1594
- * @template T Expected type of parsed value
1595
- * @returns A reusable `assertParse` function
1596
- *
1597
- * @author Jeongho Nam - https://github.com/samchon
1598
- */
1599
- export function createAssertParse<T>(): (input: string) => Primitive<T>;
1600
-
1601
- /**
1602
- * @internal
1603
- */
1604
- export function createAssertParse<T>(): (input: string) => Primitive<T> {
1605
- halt("createAssertParse");
1606
- }
1607
- Object.assign(createAssertParse, assertParse);
1608
-
1609
- /**
1610
- * Creates a reusable {@link validateParse} function.
1611
- *
1612
- * @danger You have to specify the generic argument `T`
1613
- * @return Nothing until specifying the generic argument `T`
1614
- * @throws compile error
1615
- *
1616
- * @author Jeongho Nam - https://github.com/samchon
1617
- */
1618
- export function createValidateParse(): never;
1619
-
1620
- /**
1621
- * Creates a reusable {@link validateParse} function.
1622
- *
1623
- * @template T Expected type of parsed value
1624
- * @returns A reusable `validateParse` function
1625
- *
1626
- * @author Jeongho Nam - https://github.com/samchon
1627
- */
1628
- export function createValidateParse<T>(): (
1629
- input: string,
1630
- ) => IValidation<Primitive<T>>;
1631
-
1632
- /**
1633
- * @internal
1634
- */
1635
- export function createValidateParse<T>(): (
1636
- input: string,
1637
- ) => IValidation<Primitive<T>> {
1638
- halt("createValidateParse");
1639
- }
1640
- Object.assign(createValidateParse, validateParse);
1641
-
1642
- /**
1643
- * Creates a reusable {@link stringify} function.
1644
- *
1645
- * @danger You have to specify the generic argument `T`
1646
- * @return Nothing until specifying the generic argument `T`
1647
- * @throws compile error
1648
- *
1649
- * @author Jeongho Nam - https://github.com/samchon
1650
- */
1651
- export function createStringify(): never;
1652
-
1653
- /**
1654
- * Creates a reusable {@link stringify} function.
1655
- *
1656
- * @template T Type of the input value
1657
- * @returns A reusable `stringify` function
1658
- *
1659
- * @author Jeongho Nam - https://github.com/samchon
1660
- */
1661
- export function createStringify<T>(): (input: T) => string;
1662
-
1663
- /**
1664
- * @internal
1665
- */
1666
- export function createStringify<T>(): (input: T) => string {
1667
- halt("createStringify");
1668
- }
1669
- Object.assign(createStringify, stringify);
1670
-
1671
- /**
1672
- * Creates a reusable {@link assertStringify} function.
1673
- *
1674
- * @danger You have to specify the generic argument `T`
1675
- * @return Nothing until specifying the generic argument `T`
1676
- * @throws compile error
1677
- *
1678
- * @author Jeongho Nam - https://github.com/samchon
1679
- */
1680
- export function createAssertStringify(): never;
1681
-
1682
- /**
1683
- * Creates a reusable {@link assertStringify} function.
1684
- *
1685
- * @template T Type of the input value
1686
- * @returns A reusable `assertStringify` function
1687
- *
1688
- * @author Jeongho Nam - https://github.com/samchon
1689
- */
1690
- export function createAssertStringify<T>(): (input: unknown) => string;
1691
-
1692
- /**
1693
- * @internal
1694
- */
1695
- export function createAssertStringify(): (input: unknown) => string {
1696
- halt("createAssertStringify");
1697
- }
1698
- Object.assign(createAssertStringify, assertStringify);
1699
-
1700
- /**
1701
- * Creates a reusable {@link isStringify} function.
1702
- *
1703
- * @danger You have to specify the generic argument `T`
1704
- * @return Nothing until specifying the generic argument `T`
1705
- * @throws compile error
1706
- *
1707
- * @author Jeongho Nam - https://github.com/samchon
1708
- */
1709
- export function createIsStringify(): never;
1710
-
1711
- /**
1712
- * Creates a reusable {@link isStringify} function.
1713
- *
1714
- * @template T Type of the input value
1715
- * @returns A reusable `isStringify` function
1716
- *
1717
- * @author Jeongho Nam - https://github.com/samchon
1718
- */
1719
- export function createIsStringify<T>(): (input: unknown) => string | null;
1720
-
1721
- /**
1722
- * @internal
1723
- */
1724
- export function createIsStringify(): (input: unknown) => string | null {
1725
- halt("createIsStringify");
1726
- }
1727
- Object.assign(createIsStringify, isStringify);
1728
-
1729
- /**
1730
- * Creates a reusable {@link validateStringify} function.
1731
- *
1732
- * @danger You have to specify the generic argument `T`
1733
- * @return Nothing until specifying the generic argument `T`
1734
- * @throws compile error
1735
- *
1736
- * @author Jeongho Nam - https://github.com/samchon
1737
- */
1738
- export function createValidateStringify(): never;
1739
-
1740
- /**
1741
- * Creates a reusable {@link validateStringify} function.
1742
- *
1743
- * @template T Type of the input value
1744
- * @returns A reusable `validateStringify` function
1745
-
1746
- * @author Jeongho Nam - https://github.com/samchon
1747
- */
1748
- export function createValidateStringify<T>(): (
1749
- input: unknown,
1750
- ) => IValidation<string>;
1751
-
1752
- /**
1753
- * @internal
1754
- */
1755
- export function createValidateStringify(): (
1756
- input: unknown,
1757
- ) => IValidation<string> {
1758
- halt("createValidateStringify");
1759
- }
1760
- Object.assign(createValidateStringify, validateStringify);
1761
-
1762
- /* -----------------------------------------------------------
1763
- MISCELLANEOUS
1764
- ----------------------------------------------------------- */
1765
- /**
1766
- * Creates a reusable {@link random} function.
1767
- *
1768
- * @danger You have to specify the generic argument `T`
1769
- * @param generator Random data generator
1770
- * @return Nothing until specifying the generic argument `T`
1771
- * @throws compile error
1772
- *
1773
- * @author Jeongho Nam - https://github.com/samchon
1774
- */
1775
- export function createRandom(generator?: Partial<IRandomGenerator>): never;
1776
-
1777
- /**
1778
- * Creates a resuable {@link random} function.
1779
- *
1780
- * @template T Type of the input value
1781
- * @param generator Random data generator
1782
- * @returns A reusable `random` function
1783
- *
1784
- * @author Jeongho Nam - https://github.com/samchon
1785
- */
1786
- export function createRandom<T>(
1787
- generator?: Partial<IRandomGenerator>,
1788
- ): () => Primitive<T>;
1789
-
1790
- /**
1791
- * @internal
1792
- */
1793
- export function createRandom(): never {
1794
- halt("createRandom");
1795
- }
1796
- Object.assign(createRandom, random);
1797
-
1798
- /**
1799
- * Creates a reusable {@link clone} function.
1800
- *
1801
- * @danger You have to specify the generic argument `T`
1802
- * @return Nothing until specifying the generic argument `T`
1803
- * @throws compile error
1804
- *
1805
- * @author Jeongho Nam - https://github.com/samchon
1806
- */
1807
- export function createClone(): never;
1808
-
1809
- /**
1810
- * Creates a resuable {@link clone} function.
1811
- *
1812
- * @template T Type of the input value
1813
- * @returns A reusable `clone` function
1814
- *
1815
- * @author Jeongho Nam - https://github.com/samchon
1816
- */
1817
- export function createClone<T>(): (input: T) => Primitive<T>;
1818
-
1819
- /**
1820
- * @internal
1821
- */
1822
- export function createClone(): never {
1823
- halt("createClone");
1824
- }
1825
- Object.assign(createClone, clone);
1826
-
1827
- /**
1828
- * Creates a reusable {@link assertClone} function.
1829
- *
1830
- * @danger You have to specify the generic argument `T`
1831
- * @return Nothing until specifying the generic argument `T`
1832
- * @throws compile error
1833
- *
1834
- * @author Jeongho Nam - https://github.com/samchon
1835
- */
1836
- export function createAssertClone(): never;
1837
-
1838
- /**
1839
- * Creates a resuable {@link assertClone} function.
1840
- *
1841
- * @template T Type of the input value
1842
- * @returns A reusable `clone` function
1843
- *
1844
- * @author Jeongho Nam - https://github.com/samchon
1845
- */
1846
- export function createAssertClone<T>(): (input: unknown) => Primitive<T>;
1847
-
1848
- /**
1849
- * @internal
1850
- */
1851
- export function createAssertClone(): never {
1852
- halt("createAssertClone");
1853
- }
1854
- Object.assign(createAssertClone, assertClone);
1855
-
1856
- /**
1857
- * Creates a reusable {@link isClone} function.
1858
- *
1859
- * @danger You have to specify the generic argument `T`
1860
- * @return Nothing until specifying the generic argument `T`
1861
- * @throws compile error
1862
- *
1863
- * @author Jeongho Nam - https://github.com/samchon
1864
- */
1865
- export function createIsClone(): never;
1866
-
1867
- /**
1868
- * Creates a resuable {@link isClone} function.
1869
- *
1870
- * @template T Type of the input value
1871
- * @returns A reusable `clone` function
1872
- *
1873
- * @author Jeongho Nam - https://github.com/samchon
1874
- */
1875
- export function createIsClone<T>(): (input: unknown) => Primitive<T> | null;
1876
-
1877
- /**
1878
- * @internal
1879
- */
1880
- export function createIsClone(): never {
1881
- halt("createIsClone");
1882
- }
1883
- Object.assign(createIsClone, isClone);
1884
-
1885
- /**
1886
- * Creates a reusable {@link validateClone} function.
1887
- *
1888
- * @danger You have to specify the generic argument `T`
1889
- * @return Nothing until specifying the generic argument `T`
1890
- * @throws compile error
1891
- *
1892
- * @author Jeongho Nam - https://github.com/samchon
1893
- */
1894
- export function createValidateClone(): never;
1895
-
1896
- /**
1897
- * Creates a resuable {@link validateClone} function.
1898
- *
1899
- * @template T Type of the input value
1900
- * @returns A reusable `clone` function
1901
- *
1902
- * @author Jeongho Nam - https://github.com/samchon
1903
- */
1904
- export function createValidateClone<T>(): (
1905
- input: unknown,
1906
- ) => IValidation<Primitive<T>>;
1907
-
1908
- /**
1909
- * @internal
1910
- */
1911
- export function createValidateClone(): never {
1912
- halt("createValidateClone");
1913
- }
1914
- Object.assign(createValidateClone, validateClone);
1915
-
1916
- /**
1917
- * Creates a reusable {@link prune} function.
1918
- *
1919
- * @danger You have to specify the generic argument `T`
1920
- * @return Nothing until specifying the generic argument `T`
1921
- * @throws compile error
1922
- *
1923
- * @author Jeongho Nam - https://github.com/samchon
1924
- */
1925
- export function createPrune(): never;
1926
-
1927
- /**
1928
- * Creates a resuable {@link prune} function.
1929
- *
1930
- * @template T Type of the input value
1931
- * @returns A reusable `prune` function
1932
- *
1933
- * @author Jeongho Nam - https://github.com/samchon
1934
- */
1935
- export function createPrune<T extends object>(): (input: T) => void;
1936
-
1937
- /**
1938
- * @internal
1939
- */
1940
- export function createPrune<T extends object>(): (input: T) => void {
1941
- halt("createPrune");
1942
- }
1943
- Object.assign(createPrune, prune);
1944
-
1945
- /**
1946
- * Creates a reusable {@link assertPrune} function.
1947
- *
1948
- * @danger You have to specify the generic argument `T`
1949
- * @return Nothing until specifying the generic argument `T`
1950
- * @throws compile error
1951
- *
1952
- * @author Jeongho Nam - https://github.com/samchon
1953
- */
1954
- export function createAssertPrune(): never;
1955
-
1956
- /**
1957
- * Creates a resuable {@link assertPrune} function.
1958
- *
1959
- * @template T Type of the input value
1960
- * @returns A reusable `isPrune` function
1961
- *
1962
- * @author Jeongho Nam - https://github.com/samchon
1963
- */
1964
- export function createAssertPrune<T extends object>(): (input: T) => T;
1965
-
1966
- /**
1967
- * @internal
1968
- */
1969
- export function createAssertPrune<T extends object>(): (input: T) => T {
1970
- halt("createAssertPrune");
1971
- }
1972
- Object.assign(createAssertPrune, assertPrune);
1973
-
1974
- /**
1975
- * Creates a reusable {@link isPrune} function.
1976
- *
1977
- * @danger You have to specify the generic argument `T`
1978
- * @return Nothing until specifying the generic argument `T`
1979
- * @throws compile error
1980
- *
1981
- * @author Jeongho Nam - https://github.com/samchon
1982
- */
1983
- export function createIsPrune(): never;
1984
-
1985
- /**
1986
- * Creates a resuable {@link isPrune} function.
1987
- *
1988
- * @template T Type of the input value
1989
- * @returns A reusable `isPrune` function
1990
- *
1991
- * @author Jeongho Nam - https://github.com/samchon
1992
- */
1993
- export function createIsPrune<T extends object>(): (input: T) => input is T;
1994
-
1995
- /**
1996
- * @internal
1997
- */
1998
- export function createIsPrune<T extends object>(): (input: T) => input is T {
1999
- halt("createIsPrune");
2000
- }
2001
- Object.assign(createIsPrune, isPrune);
2002
-
2003
- /**
2004
- * Creates a reusable {@link validatePrune} function.
2005
- *
2006
- * @danger You have to specify the generic argument `T`
2007
- * @return Nothing until specifying the generic argument `T`
2008
- * @throws compile error
2009
- *
2010
- * @author Jeongho Nam - https://github.com/samchon
2011
- */
2012
- export function createValidatePrune(): never;
2013
-
2014
- /**
2015
- * Creates a resuable {@link validatePrune} function.
2016
- *
2017
- * @template T Type of the input value
2018
- * @returns A reusable `validatePrune` function
2019
- *
2020
- * @author Jeongho Nam - https://github.com/samchon
2021
- */
2022
- export function createValidatePrune<T extends object>(): (
2023
- input: T,
2024
- ) => IValidation<T>;
2025
-
2026
- /**
2027
- * @internal
2028
- */
2029
- export function createValidatePrune<T extends object>(): (
2030
- input: T,
2031
- ) => IValidation<T> {
2032
- halt("createValidatePrune");
2033
- }
2034
- Object.assign(createValidatePrune, validatePrune);
2035
-
2036
- /**
2037
- * @internal
2038
- */
2039
- function halt(name: string): never {
2040
- throw new Error(
2041
- `Error on typia.${name}(): no transform has been configured. Run "npx typia setup" command.`,
2042
- );
2043
- }
1
+ import { $dictionary } from "./functional/$dictionary";
2
+ import { Namespace } from "./functional/Namespace";
3
+
4
+ import { IMetadataApplication } from "./metadata/IMetadataApplication";
5
+ import { IJsonApplication } from "./schemas/IJsonApplication";
6
+
7
+ import { Atomic } from "./typings/Atomic";
8
+
9
+ import { MapUtil } from "./utils/MapUtil";
10
+
11
+ import { CustomValidatorMap } from "./CustomValidatorMap";
12
+ import { IRandomGenerator } from "./IRandomGenerator";
13
+ import { IValidation } from "./IValidation";
14
+ import { Primitive } from "./Primitive";
15
+ import { TypeGuardError } from "./TypeGuardError";
16
+
17
+ export * from "./schemas/IJsonApplication";
18
+ export * from "./schemas/IJsonComponents";
19
+ export * from "./schemas/IJsonSchema";
20
+ export * from "./IRandomGenerator";
21
+ export * from "./IValidation";
22
+ export * from "./Primitive";
23
+ export * from "./TypeGuardError";
24
+
25
+ /* ===========================================================
26
+ SINGLE FUNCTIONS
27
+ - BASIC VALIDATORS
28
+ - STRICT VALIDATORS
29
+ - JSON FUNCTIONS
30
+ - MISCELLANEOUS
31
+ ==============================================================
32
+ BASIC VALIDATORS
33
+ ----------------------------------------------------------- */
34
+ /**
35
+ * Asserts a value type.
36
+ *
37
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
38
+ * reason, if the parametric value is not following the type `T`. Otherwise, the
39
+ * value is following the type `T`, just input parameter would be returned.
40
+ *
41
+ * If what you want is not asserting but just knowing whether the parametric value is
42
+ * following the type `T` or not, you can choose the {@link is} function instead.
43
+ * Otherwise you want to know all the errors, {@link validate} is the way to go.
44
+ *
45
+ * On the other and, if you don't want to allow any superfluous property that is not
46
+ * enrolled to the type `T`, you can use {@link assertEquals} function instead.
47
+ *
48
+ * @template T Type of the input value
49
+ * @param input A value to be asserted
50
+ * @returns Parametric input value
51
+ * @throws A {@link TypeGuardError} instance with detailed reason
52
+ *
53
+ * @author Jeongho Nam - https://github.com/samchon
54
+ */
55
+ export function assert<T>(input: T): T;
56
+
57
+ /**
58
+ * Asserts a value type.
59
+ *
60
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
61
+ * reason, if the parametric value is not following the type `T`. Otherwise, the
62
+ * value is following the type `T`, just input parameter would be returned.
63
+ *
64
+ * If what you want is not asserting but just knowing whether the parametric value is
65
+ * following the type `T` or not, you can choose the {@link is} function instead.
66
+ * Otherwise, you want to know all the errors, {@link validate} is the way to go.
67
+ *
68
+ * On the other and, if you don't want to allow any superfluous property that is not
69
+ * enrolled to the type `T`, you can use {@link assertEquals} function instead.
70
+ *
71
+ * @template T Type of the input value
72
+ * @param input A value to be asserted
73
+ * @returns Parametric input value casted as `T`
74
+ * @throws A {@link TypeGuardError} instance with detailed reason
75
+ *
76
+ * @author Jeongho Nam - https://github.com/samchon
77
+ */
78
+ export function assert<T>(input: unknown): T;
79
+
80
+ /**
81
+ * @internal
82
+ */
83
+ export function assert(): never {
84
+ halt("assert");
85
+ }
86
+ Object.assign(assert, Namespace.assert("assert"));
87
+
88
+ /**
89
+ * Asserts a value type.
90
+ *
91
+ * Duplicated function of {@link assert} for `typescript-is` users.
92
+ *
93
+ * @template T Type of the input value
94
+ * @param input A value to be asserted
95
+ * @returns Parametric input value
96
+ * @throws A {@link TypeGuardError} instance with detailed reason
97
+ *
98
+ * @author Jeongho Nam - https://github.com/samchon
99
+ * @deprecated
100
+ */
101
+ export function assertType<T>(input: T): T;
102
+
103
+ /**
104
+ * Asserts a value type.
105
+ *
106
+ * Duplicated function of {@link assert} for `typescript-is` users.
107
+ *
108
+ * @template T Type of the input value
109
+ * @param input A value to be asserted
110
+ * @returns Parametric input value
111
+ * @throws A {@link TypeGuardError} instance with detailed reason
112
+ *
113
+ * @author Jeongho Nam - https://github.com/samchon
114
+ * @deprecated
115
+ */
116
+ export function assertType<T>(input: unknown): T;
117
+
118
+ /**
119
+ * @internal
120
+ */
121
+ export function assertType(): never {
122
+ halt("assertType");
123
+ }
124
+ Object.assign(assertType, Namespace.assert("assertType"));
125
+
126
+ /**
127
+ * Tests a value type.
128
+ *
129
+ * Tests a parametric value type and returns whether it's following the type `T` or not.
130
+ * If the parametric value is matched with the type `T`, `true` value would be returned.
131
+ * Otherwise, the parametric value is not following the type `T`, `false` value would be
132
+ * returned.
133
+ *
134
+ * If what you want is not just knowing whether the parametric value is following the
135
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
136
+ * {@link assert} function instead. Also, if you want to know all the errors with
137
+ * detailed reasons, {@link validate} function would be useful.
138
+ *
139
+ * On the other and, if you don't want to allow any superfluous property that is not
140
+ * enrolled to the type `T`, you can use {@link equals} function instead.
141
+ *
142
+ * @template T Type of the input value
143
+ * @param input A value to be tested
144
+ * @returns Whether the parametric value is following the type `T` or not
145
+ *
146
+ * @author Jeongho Nam - https://github.com/samchon
147
+ */
148
+ export function is<T>(input: T): input is T;
149
+
150
+ /**
151
+ * Tests a value type.
152
+ *
153
+ * Tests a parametric value type and returns whether it's following the type `T` or not.
154
+ * If the parametric value is matched with the type `T`, `true` value would be returned.
155
+ * Otherwise, the parametric value is not following the type `T`, `false` value would be
156
+ * returned.
157
+ *
158
+ * If what you want is not just knowing whether the parametric value is following the
159
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
160
+ * {@link assert} function instead. Also, if you want to know all the errors with
161
+ * detailed reasons, {@link validate} function would be useful.
162
+ *
163
+ * On the other and, if you don't want to allow any superfluous property that is not
164
+ * enrolled to the type `T`, you can use {@link equals} function instead.
165
+ *
166
+ * @template T Type of the input value
167
+ * @param input A value to be tested
168
+ * @returns Whether the parametric value is following the type `T` or not
169
+ *
170
+ * @author Jeongho Nam - https://github.com/samchon
171
+ */
172
+ export function is<T>(input: unknown): input is T;
173
+
174
+ /**
175
+ * @internal
176
+ */
177
+ export function is(): never {
178
+ halt("is");
179
+ }
180
+ Object.assign(is, Namespace.assert("is"));
181
+
182
+ /**
183
+ * Validates a value type.
184
+ *
185
+ * Validates a parametric value type and archives all the type errors into an
186
+ * {@link IValidation.errors} array, if the parametric value is not following the
187
+ * type `T`. Of course, if the parametric value is following the type `T`, the
188
+ * {@link IValidation.errors} array would be empty and {@link IValidation.success}
189
+ * would have the `true` value.
190
+ *
191
+ * If what you want is not finding all the error, but asserting the parametric value
192
+ * type with exception throwing, you can choose {@link assert} function instead.
193
+ * Otherwise, you just want to know whether the parametric value is matched with the
194
+ * type `T`, {@link is} function is the way to go.
195
+ *
196
+ * On the other and, if you don't want to allow any superfluous property that is not
197
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
198
+ *
199
+ * @template Type of the input value
200
+ * @param input A value to be validated
201
+ * @returns Validation result
202
+ *
203
+ * @author Jeongho Nam - https://github.com/samchon
204
+ */
205
+ export function validate<T>(input: T): IValidation<T>;
206
+
207
+ /**
208
+ * Validates a value type.
209
+ *
210
+ * Validates a parametric value type and archives all the type errors into an
211
+ * {@link IValidation.errors} array, if the parametric value is not following the
212
+ * type `T`. Of course, if the parametric value is following the type `T`, the
213
+ * {@link IValidation.errors} array would be empty and {@link IValidation.success}
214
+ * would have the `true` value.
215
+ *
216
+ * If what you want is not finding all the error, but asserting the parametric value
217
+ * type with exception throwing, you can choose {@link assert} function instead.
218
+ * Otherwise, you just want to know whether the parametric value is matched with the
219
+ * type `T`, {@link is} function is the way to go.
220
+ *
221
+ * On the other and, if you don't want to allow any superfluous property that is not
222
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
223
+ *
224
+ * @template Type of the input value
225
+ * @param input A value to be validated
226
+ * @returns Validation result
227
+ *
228
+ * @author Jeongho Nam - https://github.com/samchon
229
+ */
230
+ export function validate<T>(input: unknown): IValidation<T>;
231
+
232
+ /**
233
+ * @internal
234
+ */
235
+ export function validate(): never {
236
+ halt("validate");
237
+ }
238
+ Object.assign(validate, Namespace.validate());
239
+
240
+ /* -----------------------------------------------------------
241
+ STRICT VALIDATORS
242
+ ----------------------------------------------------------- */
243
+ /**
244
+ * Asserts equality between a value and its type.
245
+ *
246
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
247
+ * reason, if the parametric value is not following the type `T` or some superfluous
248
+ * property that is not listed on the type `T` has been found. Otherwise, the value is
249
+ * following the type `T` without any superfluous property, just input parameter would
250
+ * be returned.
251
+ *
252
+ * If what you want is not asserting but just knowing whether the parametric value is
253
+ * following the type `T` or not, you can choose the {@link equals} function instead.
254
+ * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
255
+ *
256
+ * On the other hand, if you want to allow superfluous property that is not enrolled
257
+ * to the type `T`, you can use {@link assert} function instead.
258
+ *
259
+ * @template T Type of the input value
260
+ * @param input A value to be asserted
261
+ * @returns Parametric input value
262
+ * @throws A {@link TypeGuardError} instance with detailed reason
263
+ *
264
+ * @author Jeongho Nam - https://github.com/samchon
265
+ */
266
+ export function assertEquals<T>(input: T): T;
267
+
268
+ /**
269
+ * Asserts equality between a value and its type.
270
+ *
271
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
272
+ * reason, if the parametric value is not following the type `T` or some superfluous
273
+ * property that is not listed on the type `T` has been found. Otherwise, the value is
274
+ * following the type `T` without any superfluous property, just input parameter would
275
+ * be returned.
276
+ *
277
+ * If what you want is not asserting but just knowing whether the parametric value is
278
+ * following the type `T` or not, you can choose the {@link equals} function instead.
279
+ * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
280
+ *
281
+ * On the other hand, if you want to allow superfluous property that is not enrolled
282
+ * to the type `T`, you can use {@link assert} function instead.
283
+ *
284
+ * @template T Type of the input value
285
+ * @param input A value to be asserted
286
+ * @returns Parametric input value casted as `T`
287
+ * @throws A {@link TypeGuardError} instance with detailed reason
288
+ *
289
+ * @author Jeongho Nam - https://github.com/samchon
290
+ */
291
+ export function assertEquals<T>(input: unknown): T;
292
+
293
+ /**
294
+ * @internal
295
+ */
296
+ export function assertEquals(): never {
297
+ halt("assertEquals");
298
+ }
299
+ Object.assign(assertEquals, Namespace.assert("assertEquals"));
300
+
301
+ /**
302
+ * Tests equality between a value and its type.
303
+ *
304
+ * Tests a parametric value type and returns whether it's equivalent to the type `T`
305
+ * or not. If the parametric value is matched with the type `T` and there's not any
306
+ * superfluous property that is not listed on the type `T`, `true` value would be
307
+ * returned. Otherwise, the parametric value is not following the type `T` or some
308
+ * superfluous property exists, `false` value would be returned.
309
+ *
310
+ * If what you want is not just knowing whether the parametric value is following the
311
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
312
+ * {@link assertEquals} function instead. Also, if you want to know all the errors with
313
+ * detailed reasons, {@link validateEquals} function would be useful.
314
+ *
315
+ * On the other hand, if you want to allow superfluous property that is not enrolled
316
+ * to the type `T`, you can use {@link is} function instead.
317
+ *
318
+ * @template T Type of the input value
319
+ * @param input A value to be tested
320
+ * @returns Whether the parametric value is equivalent to the type `T` or not
321
+ *
322
+ * @author Jeongho Nam - https://github.com/samchon
323
+ */
324
+ export function equals<T>(input: T): input is T;
325
+
326
+ /**
327
+ * Tests equality between a value and its type.
328
+ *
329
+ * Tests a parametric value type and returns whether it's equivalent to the type `T`
330
+ * or not. If the parametric value is matched with the type `T` and there's not any
331
+ * superfluous property that is not listed on the type `T`, `true` value would be
332
+ * returned. Otherwise, the parametric value is not following the type `T` or some
333
+ * superfluous property exists, `false` value would be returned.
334
+ *
335
+ * If what you want is not just knowing whether the parametric value is following the
336
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
337
+ * {@link assertEquals} function instead. Also, if you want to know all the errors with
338
+ * detailed reasons, {@link validateEquals} function would be useful.
339
+ *
340
+ * On the other hand, if you want to allow superfluous property that is not enrolled
341
+ * to the type `T`, you can use {@link is} function instead.
342
+ *
343
+ * @template T Type of the input value
344
+ * @param input A value to be tested
345
+ * @returns Whether the parametric value is equivalent to the type `T` or not
346
+ *
347
+ * @author Jeongho Nam - https://github.com/samchon
348
+ */
349
+ export function equals<T>(input: unknown): input is T;
350
+
351
+ /**
352
+ * @internal
353
+ */
354
+ export function equals(): never {
355
+ halt("equals");
356
+ }
357
+ Object.assign(equals, Namespace.is());
358
+
359
+ /**
360
+ * Validates equality between a value and its type.
361
+ *
362
+ * Validates a parametric value type and archives all the type errors into an
363
+ * {@link IValidation.errors} array, if the parametric value is not following the
364
+ * type `T` or some superfluous property that is not listed on the type `T` has been
365
+ * found. Of course, if the parametric value is following the type `T` and no
366
+ * superfluous property exists, the {@link IValidation.errors} array would be empty
367
+ * and {@link IValidation.success} would have the `true` value.
368
+ *
369
+ * If what you want is not finding all the error, but asserting the parametric value
370
+ * type with exception throwing, you can choose {@link assert} function instead.
371
+ * Otherwise, you just want to know whether the parametric value is matched with the
372
+ * type `T`, {@link is} function is the way to go.
373
+ *
374
+ * On the other and, if you don't want to allow any superfluous property that is not
375
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
376
+ *
377
+ * @template Type of the input value
378
+ * @param input A value to be validated
379
+ * @returns Validation result
380
+ *
381
+ * @author Jeongho Nam - https://github.com/samchon
382
+ */
383
+ export function validateEquals<T>(input: T): IValidation<T>;
384
+
385
+ /**
386
+ * Validates equality between a value and its type.
387
+ *
388
+ * Validates a parametric value type and archives all the type errors into an
389
+ * {@link IValidation.errors} array, if the parametric value is not following the
390
+ * type `T` or some superfluous property that is not listed on the type `T` has been
391
+ * found. Of course, if the parametric value is following the type `T` and no
392
+ * superfluous property exists, the {@link IValidation.errors} array would be empty
393
+ * and {@link IValidation.success} would have the `true` value.
394
+ *
395
+ * If what you want is not finding all the error, but asserting the parametric value
396
+ * type with exception throwing, you can choose {@link assert} function instead.
397
+ * Otherwise, you just want to know whether the parametric value is matched with the
398
+ * type `T`, {@link is} function is the way to go.
399
+ *
400
+ * On the other and, if you don't want to allow any superfluous property that is not
401
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
402
+ *
403
+ * @template Type of the input value
404
+ * @param input A value to be validated
405
+ * @returns Validation result
406
+ *
407
+ * @author Jeongho Nam - https://github.com/samchon
408
+ */
409
+ export function validateEquals<T>(input: unknown): IValidation<T>;
410
+
411
+ /**
412
+ * @internal
413
+ */
414
+ export function validateEquals(): never {
415
+ halt("validateEquals");
416
+ }
417
+ Object.assign(validateEquals, Namespace.validate());
418
+
419
+ /**
420
+ * Custom validators.
421
+ *
422
+ * If you want to add a custom validation logic utilizing comment tags,
423
+ * add a closure function with its tag and type name. Below example code
424
+ * would helpful to understand how to use this instance.
425
+ *
426
+ * ```ts
427
+ * typia.customValidators.insert("powerOf")("number")(
428
+ * (text: string) => {
429
+ * const denominator: number = Math.log(Number(text));
430
+ * return (value: number) => {
431
+ * value = Math.log(value) / denominator;
432
+ * return value === Math.floor(value);
433
+ * };
434
+ * }
435
+ * );
436
+ * typia.customValidators.insert("dollar")("string")(
437
+ * () => (value: string) => value.startsWith("$"),
438
+ * );
439
+ *
440
+ * interface TagCustom {
441
+ * /**
442
+ * * @powerOf 10
443
+ * *\/
444
+ * powerOf: number;
445
+ *
446
+ * /**
447
+ * * @dollar
448
+ * *\/
449
+ * dollar: string;
450
+ * }
451
+ * ```
452
+ *
453
+ * @author Jeongho Nam - https://github.com/samchon
454
+ */
455
+ export const customValidators: CustomValidatorMap = {
456
+ size: (name?: string) =>
457
+ name ? $dictionary.get(name)?.size ?? 0 : $dictionary.size,
458
+ has: (name) => (type) => $dictionary.get(name)?.has(type) ?? false,
459
+ get: (name) => (type) => $dictionary.get(name)?.get(type),
460
+ insert: (name) => (type) => (closure) => {
461
+ const internal = MapUtil.take($dictionary)(name, () => new Map());
462
+ if (internal.has(type)) return false;
463
+ internal.set(type, closure);
464
+ return true;
465
+ },
466
+ erase: (name) => (type) => $dictionary.get(name)?.delete(type) ?? false,
467
+ };
468
+
469
+ /* -----------------------------------------------------------
470
+ JSON FUNCTIONS
471
+ ----------------------------------------------------------- */
472
+ /**
473
+ * > You must configure the generic argument `T`.
474
+ *
475
+ * JSON Schema Application.
476
+ *
477
+ * Creates a JSON schema application which contains both main JSON schemas and components.
478
+ * Note that, all of the object types are stored in the {@link IJsonApplication.components}
479
+ * property for the `$ref` referencing.
480
+ *
481
+ * Also, `typia.application()` has additional generic arguments, *Purpose*.
482
+ * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
483
+ * you should configure the *Purpose* appropriately.
484
+ *
485
+ * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
486
+ * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
487
+ * the tuple definition.
488
+ *
489
+ * @template Types Tuple of target types
490
+ * @template Purpose Purpose of the JSON schema`
491
+ * @template Prefix Prefix of the JSON components referenced by `$ref` tag
492
+ * @return JSON schema application
493
+ *
494
+ * @author Jeongho Nam - https://github.com/samchon
495
+ */
496
+ export function application(): never;
497
+
498
+ /**
499
+ * JSON Schema Application.
500
+ *
501
+ * Creates a JSON schema application which contains both main JSON schemas and components.
502
+ * Note that, all of the object types are stored in the {@link IJsonApplication.components}
503
+ * property for the `$ref` referencing.
504
+ *
505
+ * Also, `typia.application()` has additional generic arguments, *Purpose*.
506
+ * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
507
+ * you should configure the *Purpose* appropriately.
508
+ *
509
+ * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
510
+ * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
511
+ * the tuple definition.
512
+ *
513
+ * @template Types Tuple of target types
514
+ * @template Purpose Purpose of the JSON schema
515
+ * @template Prefix Prefix of the JSON components referenced by `$ref` tag
516
+ * @return JSON schema application
517
+ *
518
+ * @author Jeongho Nam - https://github.com/samchon
519
+ */
520
+ export function application<
521
+ Types extends unknown[],
522
+ Purpose extends "swagger" | "ajv" = "swagger",
523
+ Prefix extends string = Purpose extends "swagger"
524
+ ? "#/components/schemas"
525
+ : "components#/schemas",
526
+ >(): IJsonApplication;
527
+
528
+ /**
529
+ * @internal
530
+ */
531
+ export function application(): never {
532
+ halt("application");
533
+ }
534
+
535
+ /**
536
+ * > You must configure the generic argument `T`.
537
+ *
538
+ * Safe `JSON.parse()` function with type assertion.
539
+ *
540
+ * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
541
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
542
+ * instance with type assertion.
543
+ *
544
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
545
+ * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
546
+ * the parsed value would be returned.
547
+ *
548
+ * @template T Expected type of parsed value
549
+ * @param input JSON string
550
+ * @returns Parsed value
551
+ *
552
+ * @author Jeongho Nam - https://github.com/samchon
553
+ */
554
+ export function assertParse(input: string): never;
555
+
556
+ /**
557
+ * Safe `JSON.parse()` function with type assertion.
558
+ *
559
+ * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
560
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
561
+ * instance with type assertion.
562
+ *
563
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
564
+ * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
565
+ * the parsed value would be returned.
566
+ *
567
+ * @template T Expected type of parsed value
568
+ * @param input JSON string
569
+ * @returns Parsed value
570
+ *
571
+ * @author Jeongho Nam - https://github.com/samchon
572
+ */
573
+ export function assertParse<T>(input: string): Primitive<T>;
574
+
575
+ /**
576
+ * @internal
577
+ */
578
+ export function assertParse<T>(): Primitive<T> {
579
+ halt("assertParse");
580
+ }
581
+ Object.assign(assertParse, Namespace.assert("assertParse"));
582
+
583
+ /**
584
+ * > You must configure the generic argument `T`.
585
+ *
586
+ * Safe `JSON.parse()` function with type checking.
587
+ *
588
+ * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
589
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
590
+ * instance with type checking.
591
+ *
592
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
593
+ * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
594
+ * value would be returned.
595
+ *
596
+ * @template T Expected type of parsed value
597
+ * @param input JSON string
598
+ * @returns Parsed value when exact type, otherwise `null`
599
+ *
600
+ * @author Jeongho Nam - https://github.com/samchon
601
+ */
602
+ export function isParse(input: string): never;
603
+
604
+ /**
605
+ * Safe `JSON.parse()` function with type checking.
606
+ *
607
+ * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
608
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
609
+ * instance with type checking.
610
+ *
611
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
612
+ * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
613
+ * value would be returned.
614
+ *
615
+ * @template T Expected type of parsed value
616
+ * @param input JSON string
617
+ * @returns Parsed value when exact type, otherwise `null`
618
+ *
619
+ * @author Jeongho Nam - https://github.com/samchon
620
+ */
621
+ export function isParse<T>(input: string): Primitive<T> | null;
622
+
623
+ /**
624
+ * @internal
625
+ */
626
+ export function isParse<T>(): Primitive<T> | null {
627
+ halt("isParse");
628
+ }
629
+ Object.assign(isParse, is);
630
+
631
+ /**
632
+ * > You must configure the generic argument `T`.
633
+ *
634
+ * Safe `JSON.parse()` function with detailed type validation.
635
+ *
636
+ * `typia.validateParse()` is a combination function of `JSON.parse()` and
637
+ * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
638
+ * to a `T` typed instance with detailed type validation.
639
+ *
640
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
641
+ * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
642
+ * there's no problem on the parsed value, the parsed value would be stored in `data`
643
+ * property of the output {@link IValidation.ISuccess} instance.
644
+ *
645
+ * @template T Expected type of parsed value
646
+ * @param input JSON string
647
+ * @returns Validation result with JSON parsed value
648
+ *
649
+ * @author Jeongho Nam - https://github.com/samchon
650
+ */
651
+ export function validateParse(input: string): never;
652
+
653
+ /**
654
+ * Safe `JSON.parse()` function with detailed type validation.
655
+ *
656
+ * `typia.validateParse()` is a combination function of `JSON.parse()` and
657
+ * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
658
+ * to a `T` typed instance with detailed type validation.
659
+ *
660
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
661
+ * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
662
+ * there's no problem on the parsed value, the parsed value would be stored in `data`
663
+ * property of the output {@link IValidation.ISuccess} instance.
664
+ *
665
+ * @template T Expected type of parsed value
666
+ * @param input JSON string
667
+ * @returns Validation result with JSON parsed value
668
+ *
669
+ * @author Jeongho Nam - https://github.com/samchon
670
+ */
671
+ export function validateParse<T>(input: string): IValidation<Primitive<T>>;
672
+
673
+ /**
674
+ * @internal
675
+ */
676
+ export function validateParse<T>(): IValidation<Primitive<T>> {
677
+ halt("validateParse");
678
+ }
679
+ Object.assign(validateParse, validate);
680
+
681
+ /**
682
+ * 8x faster `JSON.stringify()` function.
683
+ *
684
+ * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x faster
685
+ * than the native `JSON.stringify()` function. The 5x faster principle is because
686
+ * it writes an optimized JSON conversion plan, only for the type `T`.
687
+ *
688
+ * For reference, this `typia.stringify()` does not validate the input value type.
689
+ * It just believes that the input value is following the type `T`. Therefore, if you
690
+ * can't ensure the input value type, it would be better to call one of below functions
691
+ * instead.
692
+ *
693
+ * - {@link assertStringify}
694
+ * - {@link isStringify}
695
+ * - {@link validateStringify}
696
+ *
697
+ * @template T Type of the input value
698
+ * @param input A value to be converted
699
+ * @return JSON string value
700
+ *
701
+ * @author Jeongho Nam - https://github.com/samchon
702
+ */
703
+ export function stringify<T>(input: T): string;
704
+
705
+ /**
706
+ * @internal
707
+ */
708
+ export function stringify(): never {
709
+ halt("stringify");
710
+ }
711
+ Object.assign(stringify, Namespace.stringify("stringify"));
712
+
713
+ /**
714
+ * 5x faster `JSON.stringify()` function with type assertion.
715
+ *
716
+ * `typia.assertStringify()` is a combination function of {@link assert} and
717
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
718
+ * Notation) string, with type assertion.
719
+ *
720
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
721
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
722
+ * string would be returned.
723
+ *
724
+ * For reference, with type assertion, it is even 5x times faster than the native
725
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
726
+ * with confidence.
727
+ *
728
+ * @template T Type of the input value
729
+ * @param input A value to be asserted and converted
730
+ * @return JSON string value
731
+ *
732
+ * @author Jeongho Nam - https://github.com/samchon
733
+ */
734
+ export function assertStringify<T>(input: T): string;
735
+
736
+ /**
737
+ * 5x faster `JSON.stringify()` function with type assertion.
738
+ *
739
+ * `typia.assertStringify()` is a combination function of {@link assert} and
740
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
741
+ * Notation) string, with type assertion.
742
+ *
743
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
744
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
745
+ * string would be returned.
746
+ *
747
+ * For reference, with type assertion, it is even 5x times faster than the native
748
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
749
+ * with confidence.
750
+ *
751
+ * @template T Type of the input value
752
+ * @param input A value to be asserted and converted
753
+ * @return JSON string value
754
+ *
755
+ * @author Jeongho Nam - https://github.com/samchon
756
+ */
757
+ export function assertStringify<T>(input: T): unknown;
758
+
759
+ /**
760
+ * @internal
761
+ */
762
+ export function assertStringify(): string {
763
+ halt("assertStringify");
764
+ }
765
+ Object.assign(assertStringify, Namespace.assert("assertStringify"));
766
+ Object.assign(assertStringify, Namespace.stringify("assertStringify"));
767
+
768
+ /**
769
+ * 7x faster `JSON.stringify()` function with type checking.
770
+ *
771
+ * `typia.stringify()` is a combination function of {@link is} and
772
+ * {@link stringify}. Therefore, it converts an input value to JSON
773
+ * (JavaScript Object Notation) string, with type checking.
774
+ *
775
+ * In such reason, when `input` value is not matched with the type `T`, it returns
776
+ * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
777
+ * be returned.
778
+ *
779
+ * For reference, with type checking, it is even 7x times faster than the native
780
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
781
+ * with confidence.
782
+ *
783
+ * @template T Type of the input value
784
+ * @param input A value to be checked and converted
785
+ * @return JSON string value when exact type, otherwise null
786
+ *
787
+ * @author Jeongho Nam - https://github.com/samchon
788
+ */
789
+ export function isStringify<T>(input: T): string | null;
790
+
791
+ /**
792
+ * 7x faster `JSON.stringify()` function with type checking.
793
+ *
794
+ * `typia.isStringify()` is a combination function of {@link is} and
795
+ * {@link stringify}. Therefore, it converts an input value to JSON
796
+ * (JavaScript Object Notation) string, with type checking.
797
+ *f
798
+ * In such reason, when `input` value is not matched with the type `T`, it returns
799
+ * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
800
+ * be returned.
801
+ *
802
+ * For reference, with type checking, it is even 7x times faster than the native
803
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
804
+ * with confidence.
805
+ *
806
+ * @template T Type of the input value
807
+ * @param input A value to be checked and converted
808
+ * @return JSON string value when exact type, otherwise null
809
+ *
810
+ * @author Jeongho Nam - https://github.com/samchon
811
+ */
812
+ export function isStringify<T>(input: unknown): string | null;
813
+
814
+ /**
815
+ * @internal
816
+ */
817
+ export function isStringify(): string | null {
818
+ halt("isStringify");
819
+ }
820
+
821
+ Object.assign(isStringify, Namespace.is());
822
+ Object.assign(isStringify, Namespace.stringify("isStringify"));
823
+
824
+ /**
825
+ * 5x faster `JSON.stringify()` function with detailed type validation.
826
+ *
827
+ * `typia.validateStringify()` is a combination function of {@link validate} and
828
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
829
+ * Notation) string, with detailed type validation.
830
+ *
831
+ * In such reason, when `input` value is not matched with the type `T`, it returns
832
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
833
+ * problem on the `input` value, JSON string would be stored in `data` property of
834
+ * the output {@link IValidation.ISuccess} instance.
835
+ *
836
+ * For reference, with detailed type validation, it is even 5x times faster than the
837
+ * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
838
+ * with confidence.
839
+ *
840
+ * @template T Type of the input value
841
+ * @param input A value to be checked and converted
842
+ * @returns Validation result with JSON string value
843
+ *
844
+ * @author Jeongho Nam - https://github.com/samchon
845
+ */
846
+ export function validateStringify<T>(input: T): IValidation<string>;
847
+
848
+ /**
849
+ * 5x faster `JSON.stringify()` function with detailed type validation.
850
+ *
851
+ * `typia.validateStringify()` is a combination function of {@link validate} and
852
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
853
+ * Notation) string, with detailed type validation.
854
+ *
855
+ * In such reason, when `input` value is not matched with the type `T`, it returns
856
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
857
+ * problem on the `input` value, JSON string would be stored in `data` property of
858
+ * the output {@link IValidation.ISuccess} instance.
859
+ *
860
+ * For reference, with detailed type validation, it is even 5x times faster than the
861
+ * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
862
+ * with confidence.
863
+ *
864
+ * @template T Type of the input value
865
+ * @param input A value to be checked and converted
866
+ * @returns Validation result with JSON string value
867
+ *
868
+ * @author Jeongho Nam - https://github.com/samchon
869
+ */
870
+ export function validateStringify<T>(input: unknown): IValidation<string>;
871
+
872
+ /**
873
+ * @internal
874
+ */
875
+ export function validateStringify(): IValidation<string> {
876
+ halt("validateStringify");
877
+ }
878
+ Object.assign(validateStringify, Namespace.validate());
879
+ Object.assign(validateStringify, Namespace.stringify("validateStringify"));
880
+
881
+ /* -----------------------------------------------------------
882
+ MISCELLANEOUS
883
+ ----------------------------------------------------------- */
884
+ /**
885
+ * @internal
886
+ */
887
+ export function metadata(): never;
888
+
889
+ /**
890
+ * @internal
891
+ */
892
+ export function metadata<Types extends unknown[]>(): IMetadataApplication;
893
+
894
+ /**
895
+ * @internal
896
+ */
897
+ export function metadata(): never {
898
+ halt("metadata");
899
+ }
900
+
901
+ /**
902
+ * > You must configure the generic argument `T`.
903
+ *
904
+ * Generate random data.
905
+ *
906
+ * Generates a random data following type the `T`.
907
+ *
908
+ * For reference, this `typia.random()` function generates only primitive type.
909
+ * If there're some methods in the type `T` or its nested instances, those would
910
+ * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
911
+ * would be generated instead.
912
+ *
913
+ * @template T Type of data to generate
914
+ * @param generator Random data generator
915
+ * @return Randomly generated data
916
+ *
917
+ * @author Jeongho Nam - https://github.com/samchon
918
+ */
919
+ export function random(generator?: Partial<IRandomGenerator>): never;
920
+
921
+ /**
922
+ * Generate random data.
923
+ *
924
+ * Generates a random data following type the `T`.
925
+ *
926
+ * For reference, this `typia.random()` function generates only primitive type.
927
+ * If there're some methods in the type `T` or its nested instances, those would
928
+ * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
929
+ * would be generated instead.
930
+ *
931
+ * @template T Type of data to generate
932
+ * @param generator Random data generator
933
+ * @return Randomly generated data
934
+ *
935
+ * @author Jeongho Nam - https://github.com/samchon
936
+ */
937
+ export function random<T>(generator?: Partial<IRandomGenerator>): Primitive<T>;
938
+
939
+ /**
940
+ * @internal
941
+ */
942
+ export function random(): never {
943
+ halt("random");
944
+ }
945
+ Object.assign(random, Namespace.random());
946
+
947
+ /**
948
+ * > You must configure the generic argument `T`.
949
+ *
950
+ * Union literal type to array.
951
+ *
952
+ * Converts a union literal type to an array of its members.
953
+ *
954
+ * ```typescript
955
+ * literals<"A" | "B" | 1>; // [1, 2, 3] as const
956
+ * ```
957
+ *
958
+ * @template T Union literal type
959
+ * @return Array of union literal type's members
960
+ *
961
+ * @author Jeongho Nam - https://github.com/samchon
962
+ */
963
+ export function literals(): never;
964
+
965
+ /**
966
+ * Union literal type to array.
967
+ *
968
+ * Converts a union literal type to an array of its members.
969
+ *
970
+ * ```typescript
971
+ * literals<"A" | "B" | 1>; // [1, 2, 3] as const
972
+ * ```
973
+ *
974
+ * @template T Union literal type
975
+ * @return Array of union literal type's members
976
+ *
977
+ * @author Jeongho Nam - https://github.com/samchon
978
+ */
979
+ export function literals<T extends Atomic.Type>(): T[];
980
+
981
+ /**
982
+ * @internal
983
+ */
984
+ export function literals(): never {
985
+ halt("literals");
986
+ }
987
+
988
+ /**
989
+ * Clone a data.
990
+ *
991
+ * Clones an instance following type `T`. If the target *input* value or its member
992
+ * variable contains a class instance that is having a `toJSON()` method, its return
993
+ * value would be cloned.
994
+ *
995
+ * For reference, this `typia.clone()` function does not validate the input value type.
996
+ * It just believes that the input value is following the type `T`. Therefore, if you
997
+ * can't ensure the input value type, it would be better to call {@link assertClone}
998
+ * function instead.
999
+ *
1000
+ * @template T Type of the input value
1001
+ * @param input A value to be cloned
1002
+ * @return Cloned data
1003
+ *
1004
+ * @author Jeongho Nam - https://github.com/samchon
1005
+ */
1006
+ export function clone<T>(input: T): Primitive<T>;
1007
+
1008
+ /**
1009
+ * @internal
1010
+ */
1011
+ export function clone(): never {
1012
+ halt("clone");
1013
+ }
1014
+ Object.assign(clone, Namespace.clone("clone"));
1015
+
1016
+ /**
1017
+ * Clone a data with type assertion.
1018
+ *
1019
+ * Clones an instance following type `T`, with type assertion. If the target `input`
1020
+ * value or its member variable contains a class instance that is having a `toJSON()`
1021
+ * method, its return value would be cloned.
1022
+ *
1023
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
1024
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
1025
+ * data would be returned.
1026
+ *
1027
+ * @template T Type of the input value
1028
+ * @param input A value to be cloned
1029
+ * @return Cloned data
1030
+ *
1031
+ * @author Jeongho Nam - https://github.com/samchon
1032
+ */
1033
+ export function assertClone<T>(input: T): Primitive<T>;
1034
+
1035
+ /**
1036
+ * Clone a data with type assertion.
1037
+ *
1038
+ * Clones an instance following type `T`, with type assertion. If the target `input`
1039
+ * value or its member variable contains a class instance that is having a `toJSON()`
1040
+ * method, its return value would be cloned.
1041
+ *
1042
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
1043
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
1044
+ * data would be returned.
1045
+ *
1046
+ * @template T Type of the input value
1047
+ * @param input A value to be cloned
1048
+ * @return Cloned data
1049
+ *
1050
+ * @author Jeongho Nam - https://github.com/samchon
1051
+ */
1052
+ export function assertClone<T>(input: unknown): Primitive<T>;
1053
+
1054
+ /**
1055
+ * @internal
1056
+ */
1057
+ export function assertClone(): never {
1058
+ halt("assertClone");
1059
+ }
1060
+ Object.assign(assertClone, Namespace.assert("assertClone"));
1061
+ Object.assign(assertClone, Namespace.clone("assertClone"));
1062
+
1063
+ /**
1064
+ * Clone a data with type checking.
1065
+ *
1066
+ * Clones an instance following type `T`, with type checking. If the target `input`
1067
+ * value or its member variable contains a class instance that is having a `toJSON()`
1068
+ * method, its return value would be cloned.
1069
+ *
1070
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1071
+ * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
1072
+ * data would be returned.
1073
+ *
1074
+ * @template T Type of the input value
1075
+ * @param input A value to be cloned
1076
+ * @return Cloned data when exact type, otherwise null
1077
+ *
1078
+ * @author Jeongho Nam - https://github.com/samchon
1079
+ */
1080
+ export function isClone<T>(input: T): Primitive<T> | null;
1081
+
1082
+ /**
1083
+ * Clone a data with type checking.
1084
+ *
1085
+ * Clones an instance following type `T`, with type checking. If the target `input`
1086
+ * value or its member variable contains a class instance that is having a `toJSON()`
1087
+ * method, its return value would be cloned.
1088
+ *
1089
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1090
+ * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
1091
+ * data would be returned.
1092
+ *
1093
+ * @template T Type of the input value
1094
+ * @param input A value to be cloned
1095
+ * @return Cloned data when exact type, otherwise null
1096
+ *
1097
+ * @author Jeongho Nam - https://github.com/samchon
1098
+ */
1099
+ export function isClone<T>(input: unknown): Primitive<T> | null;
1100
+
1101
+ /**
1102
+ * @internal
1103
+ */
1104
+ export function isClone(): never {
1105
+ halt("isClone");
1106
+ }
1107
+ Object.assign(isClone, Namespace.is());
1108
+ Object.assign(isClone, Namespace.clone("isClone"));
1109
+
1110
+ /**
1111
+ * Clone a data with detailed type validation.
1112
+ *
1113
+ * Clones an instance following type `T`, with detailed type validation. If the target
1114
+ * `input` value or its member variable contains a class instance that is having a
1115
+ * `toJSON()` method, its return value would be cloned.
1116
+ *
1117
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1118
+ * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1119
+ * value, cloned data would be stored in `data` property of the output
1120
+ * {@link IValidation.Success} instance.
1121
+ *
1122
+ * @template T Type of the input value
1123
+ * @param input A value to be cloned
1124
+ * @returns Validation result with cloned value
1125
+ */
1126
+ export function validateClone<T>(input: T): IValidation<Primitive<T>>;
1127
+
1128
+ /**
1129
+ * Clone a data with detailed type validation.
1130
+ *
1131
+ * Clones an instance following type `T`, with detailed type validation. If the target
1132
+ * `input` value or its member variable contains a class instance that is having a
1133
+ * `toJSON()` method, its return value would be cloned.
1134
+ *
1135
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1136
+ * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1137
+ * value, cloned data would be stored in `data` property of the output
1138
+ * {@link IValidation.Success} instance.
1139
+ *
1140
+ * @template T Type of the input value
1141
+ * @param input A value to be cloned
1142
+ * @returns Validation result with cloned value
1143
+ */
1144
+ export function validateClone<T>(input: unknown): IValidation<Primitive<T>>;
1145
+
1146
+ /**
1147
+ * @internal
1148
+ */
1149
+ export function validateClone(): never {
1150
+ halt("validateClone");
1151
+ }
1152
+ Object.assign(validateClone, Namespace.validate());
1153
+ Object.assign(validateClone, Namespace.clone("validateClone"));
1154
+
1155
+ /**
1156
+ * Prune, erase superfluous properties.
1157
+ *
1158
+ * Remove every superfluous properties from the `input` object, even including nested
1159
+ * objects. Note that, as every superfluous properties would be deleted, you never can
1160
+ * read those superfluous properties after calling this `prune()` function.
1161
+ *
1162
+ * For reference, this `typia.prune()` function does not validate the input value type.
1163
+ * It just believes that the input value is following the type `T`. Therefore, if you
1164
+ * can't ensure the input value type, it would better to call one of below functions
1165
+ * instead.
1166
+ *
1167
+ * - {@link assertPrune}
1168
+ * - {@link isPrune}
1169
+ * - {@link validatePrune}
1170
+ *
1171
+ * @template T Type of the input value
1172
+ * @param input Target instance to prune
1173
+ *
1174
+ * @author Jeongho Nam - https://github.com/samchon
1175
+ */
1176
+ export function prune<T extends object>(input: T): void;
1177
+
1178
+ /**
1179
+ * @internal
1180
+ */
1181
+ export function prune(): never {
1182
+ halt("prune");
1183
+ }
1184
+ Object.assign(prune, Namespace.prune("prune"));
1185
+
1186
+ /**
1187
+ * Prune, erase superfluous properties, with type assertion.
1188
+ *
1189
+ * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1190
+ * Therefore, it removes every superfluous properties from the `input` object including
1191
+ * nested objects, with type assertion.
1192
+ *
1193
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
1194
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1195
+ * every superfluous properties would be removed, including nested objects.
1196
+ *
1197
+ * @template T Type of the input value
1198
+ * @param input Target instance to assert and prune
1199
+ *
1200
+ * @author Jeongho Nam - https://github.com/samchon
1201
+ */
1202
+ export function assertPrune<T>(input: T): T;
1203
+
1204
+ /**
1205
+ * Prune, erase superfluous properties, with type assertion.
1206
+ *
1207
+ * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1208
+ * Therefore, it removes every superfluous properties from the `input` object including
1209
+ * nested objects, with type assertion.
1210
+ *
1211
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
1212
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1213
+ * every superfluous properties would be removed, including nested objects.
1214
+ *
1215
+ * @template T Type of the input value
1216
+ * @param input Target instance to assert and prune
1217
+ *
1218
+ * @author Jeongho Nam - https://github.com/samchon
1219
+ */
1220
+ export function assertPrune<T>(input: unknown): T;
1221
+
1222
+ /**
1223
+ * @internal
1224
+ */
1225
+ export function assertPrune(): unknown {
1226
+ halt("assertPrune");
1227
+ }
1228
+ Object.assign(assertPrune, Namespace.assert("assertPrune"));
1229
+ Object.assign(assertPrune, Namespace.prune("assertPrune"));
1230
+
1231
+ /**
1232
+ * Prune, erase superfluous properties, with type checking.
1233
+ *
1234
+ * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1235
+ * Therefore, it removes every superfluous properties from the `input` object including
1236
+ * nested objects, with type checking.
1237
+ *
1238
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1239
+ * `false` value. Otherwise, there's no problem on the `input` value, it returns
1240
+ * `true` after removing every superfluous properties, including nested objects.
1241
+ *
1242
+ * @template T Type of the input value
1243
+ * @param input Target instance to check and prune
1244
+ * @returns Whether the parametric value is following the type `T` or not
1245
+ *
1246
+ * @author Jeongho Nam - https://github.com/samchon
1247
+ */
1248
+ export function isPrune<T>(input: T): input is T;
1249
+
1250
+ /**
1251
+ * Prune, erase superfluous properties, with type checking.
1252
+ *
1253
+ * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1254
+ * Therefore, it removes every superfluous properties from the `input` object including
1255
+ * nested objects, with type checking.
1256
+ *
1257
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1258
+ * `false` value. Otherwise, there's no problem on the `input` value, it returns
1259
+ * `true` after removing every superfluous properties, including nested objects.
1260
+ *
1261
+ * @template T Type of the input value
1262
+ * @param input Target instance to check and prune
1263
+ * @returns Whether the parametric value is following the type `T` or not
1264
+ *
1265
+ * @author Jeongho Nam - https://github.com/samchon
1266
+ */
1267
+ export function isPrune<T>(input: unknown): input is T;
1268
+
1269
+ /**
1270
+ * @internal
1271
+ */
1272
+ export function isPrune(): never {
1273
+ halt("isPrune");
1274
+ }
1275
+ Object.assign(isPrune, Namespace.is());
1276
+ Object.assign(isPrune, Namespace.prune("isPrune"));
1277
+
1278
+ /**
1279
+ * Prune, erase superfluous properties, with type validation.
1280
+ *
1281
+ * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1282
+ * Therefore, it removes every superfluous properties from the `input` object including
1283
+ * nested objects, with type validation.
1284
+ *
1285
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1286
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1287
+ * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1288
+ * removing every superfluous properties, including nested objects.
1289
+ *
1290
+ * @template T Type of the input value
1291
+ * @param input Target instance to validate and prune
1292
+ * @returns Validation result
1293
+ *
1294
+ * @author Jeongho Nam - https://github.com/samchon
1295
+ */
1296
+ export function validatePrune<T>(input: T): IValidation<T>;
1297
+
1298
+ /**
1299
+ * Prune, erase superfluous properties, with type validation.
1300
+ *
1301
+ * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1302
+ * Therefore, it removes every superfluous properties from the `input` object including
1303
+ * nested objects, with type validation.
1304
+ *
1305
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1306
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1307
+ * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1308
+ * removing every superfluous properties, including nested objects.
1309
+ *
1310
+ * @template T Type of the input value
1311
+ * @param input Target instance to validate and prune
1312
+ * @returns Validation result
1313
+ *
1314
+ * @author Jeongho Nam - https://github.com/samchon
1315
+ */
1316
+ export function validatePrune<T>(input: unknown): IValidation<T>;
1317
+
1318
+ /**
1319
+ * @internal
1320
+ */
1321
+ export function validatePrune<T>(): IValidation<T> {
1322
+ halt("validatePrune");
1323
+ }
1324
+ Object.assign(validatePrune, Namespace.prune("validatePrune"));
1325
+ Object.assign(validatePrune, Namespace.validate());
1326
+
1327
+ /* ===========================================================
1328
+ FACTORY FUNCTIONS
1329
+ - BASIC VALIDATORS
1330
+ - STRICT VALIDATORS
1331
+ - JSON FUNCTIONS
1332
+ - MISCELLANEOUS
1333
+ ==============================================================
1334
+ BASIC VALIDATORS
1335
+ ----------------------------------------------------------- */
1336
+ /**
1337
+ * Creates a reusable {@link assert} function.
1338
+ *
1339
+ * @danger You have to specify the generic argument `T`
1340
+ * @return Nothing until specifying the generic argument `T`
1341
+ * @throws compile error
1342
+ *
1343
+ * @author Jeongho Nam - https://github.com/samchon
1344
+ */
1345
+ export function createAssert(): never;
1346
+
1347
+ /**
1348
+ * Creates a reusable {@link assert} function.
1349
+ *
1350
+ * @template T Type of the input value
1351
+ * @returns A reusable `assert` function
1352
+ *
1353
+ * @author Jeongho Nam - https://github.com/samchon
1354
+ */
1355
+ export function createAssert<T>(): (input: unknown) => T;
1356
+
1357
+ /**
1358
+ * @internal
1359
+ */
1360
+ export function createAssert<T>(): (input: unknown) => T {
1361
+ halt("createAssert");
1362
+ }
1363
+ Object.assign(createAssert, assert);
1364
+
1365
+ /**
1366
+ * Creates a reusable {@link assertType} function.
1367
+ *
1368
+ * Duplicated function of {@link createAssert} for `typescript-is` users.
1369
+ *
1370
+ * @danger You have to specify the generic argument `T`
1371
+ * @return Nothing until specifying the generic argument `T`
1372
+ * @throws compile error
1373
+ *
1374
+ * @author Jeongho Nam - https://github.com/samchon
1375
+ * @deprecated
1376
+ */
1377
+ export function createAssertType(): never;
1378
+
1379
+ /**
1380
+ * Creates a reusable {@link assertType} function.
1381
+ *
1382
+ * Duplicated function of {@link createAssert} for `typescript-is` users.
1383
+ *
1384
+ * @template T Type of the input value
1385
+ * @returns A reusable `assert` function
1386
+ *
1387
+ * @author Jeongho Nam - https://github.com/samchon
1388
+ * @deprecated
1389
+ */
1390
+ export function createAssertType<T>(): (input: unknown) => T;
1391
+
1392
+ /**
1393
+ * @internal
1394
+ */
1395
+ export function createAssertType<T>(): (input: unknown) => T {
1396
+ halt("createAssertType");
1397
+ }
1398
+ Object.assign(createAssertType, assertType);
1399
+
1400
+ /**
1401
+ * Creates a reusable {@link is} function.
1402
+ *
1403
+ * @danger You have to specify the generic argument `T`
1404
+ * @return Nothing until specifying the generic argument `T`
1405
+ * @throws compile error
1406
+ *
1407
+ * @author Jeongho Nam - https://github.com/samchon
1408
+ */
1409
+ export function createIs(): never;
1410
+
1411
+ /**
1412
+ * Creates a reusable {@link is} function.
1413
+ *
1414
+ * @template T Type of the input value
1415
+ * @returns A reusable `is` function
1416
+ *
1417
+ * @author Jeongho Nam - https://github.com/samchon
1418
+ */
1419
+ export function createIs<T>(): (input: unknown) => input is T;
1420
+
1421
+ /**
1422
+ * @internal
1423
+ */
1424
+ export function createIs<T>(): (input: unknown) => input is T {
1425
+ halt("createIs");
1426
+ }
1427
+ Object.assign(createIs, is);
1428
+
1429
+ /**
1430
+ * Creates a reusable {@link validate} function.
1431
+ *
1432
+ * @danger You have to specify the generic argument `T`
1433
+ * @return Nothing until specifying the generic argument `T`
1434
+ * @throws compile error
1435
+ *
1436
+ * @author Jeongho Nam - https://github.com/samchon
1437
+ */
1438
+ export function createValidate(): never;
1439
+
1440
+ /**
1441
+ * Creates a reusable {@link validate} function.
1442
+ *
1443
+ * @template T Type of the input value
1444
+ * @returns A reusable `validate` function
1445
+ *
1446
+ * @author Jeongho Nam - https://github.com/samchon
1447
+ */
1448
+ export function createValidate<T>(): (input: unknown) => IValidation<T>;
1449
+
1450
+ /**
1451
+ * @internal
1452
+ */
1453
+ export function createValidate(): (input: unknown) => IValidation {
1454
+ halt("createValidate");
1455
+ }
1456
+ Object.assign(createValidate, validate);
1457
+
1458
+ /* -----------------------------------------------------------
1459
+ STRICT VALIDATORS
1460
+ ----------------------------------------------------------- */
1461
+ /**
1462
+ * Creates a reusable {@link assertEquals} function.
1463
+ *
1464
+ * @danger You have to specify the generic argument `T`
1465
+ * @return Nothing until specifying the generic argument `T`
1466
+ * @throws compile error
1467
+ *
1468
+ * @author Jeongho Nam - https://github.com/samchon
1469
+ */
1470
+ export function createAssertEquals(): never;
1471
+
1472
+ /**
1473
+ * Creates a reusable {@link assertEquals} function.
1474
+ *
1475
+ * @template T Type of the input value
1476
+ * @returns A reusable `assertEquals` function
1477
+ *
1478
+ * @author Jeongho Nam - https://github.com/samchon
1479
+ */
1480
+ export function createAssertEquals<T>(): (input: unknown) => T;
1481
+
1482
+ /**
1483
+ * @internal
1484
+ */
1485
+ export function createAssertEquals<T>(): (input: unknown) => T {
1486
+ halt("createAssertEquals");
1487
+ }
1488
+ Object.assign(createAssertEquals, assertEquals);
1489
+
1490
+ /**
1491
+ * Creates a reusable {@link equals} function.
1492
+ *
1493
+ * @danger You have to specify the generic argument `T`
1494
+ * @return Nothing until specifying the generic argument `T`
1495
+ * @throws compile error
1496
+ *
1497
+ * @author Jeongho Nam - https://github.com/samchon
1498
+ */
1499
+ export function createEquals(): never;
1500
+
1501
+ /**
1502
+ * Creates a reusable {@link equals} function.
1503
+ *
1504
+ * @template T Type of the input value
1505
+ * @returns A reusable `equals` function
1506
+ *
1507
+ * @author Jeongho Nam - https://github.com/samchon
1508
+ */
1509
+ export function createEquals<T>(): (input: unknown) => input is T;
1510
+
1511
+ /**
1512
+ * @internal
1513
+ */
1514
+ export function createEquals<T>(): (input: unknown) => input is T {
1515
+ halt("createEquals");
1516
+ }
1517
+ Object.assign(createEquals, equals);
1518
+
1519
+ /**
1520
+ * Creates a reusable {@link validateEquals} function.
1521
+ *
1522
+ * @danger You have to specify the generic argument `T`
1523
+ * @return Nothing until specifying the generic argument `T`
1524
+ * @throws compile error
1525
+ *
1526
+ * @author Jeongho Nam - https://github.com/samchon
1527
+ */
1528
+ export function createValidateEquals(): never;
1529
+
1530
+ /**
1531
+ * Creates a reusable {@link validateEquals} function.
1532
+ *
1533
+ * @template T Type of the input value
1534
+ * @returns A reusable `validateEquals` function
1535
+ *
1536
+ * @author Jeongho Nam - https://github.com/samchon
1537
+ */
1538
+ export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
1539
+
1540
+ /**
1541
+ * @internal
1542
+ */
1543
+ export function createValidateEquals(): (input: unknown) => IValidation {
1544
+ halt("createValidateEquals");
1545
+ }
1546
+ Object.assign(createValidateEquals, validateEquals);
1547
+
1548
+ /* -----------------------------------------------------------
1549
+ JSON FUNCTIONS
1550
+ ----------------------------------------------------------- */
1551
+ /**
1552
+ * Creates a reusable {@link isParse} function.
1553
+ *
1554
+ * @danger You have to specify the generic argument `T`
1555
+ * @return Nothing until specifying the generic argument `T`
1556
+ * @throws compile error
1557
+ *
1558
+ * @author Jeongho Nam - https://github.com/samchon
1559
+ */
1560
+ export function createIsParse(): never;
1561
+
1562
+ /**
1563
+ * Creates a reusable {@link isParse} function.
1564
+ *
1565
+ * @template T Expected type of parsed value
1566
+ * @returns A reusable `isParse` function
1567
+ *
1568
+ * @author Jeongho Nam - https://github.com/samchon
1569
+ */
1570
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null;
1571
+
1572
+ /**
1573
+ * @internal
1574
+ */
1575
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null {
1576
+ halt("createIsParse");
1577
+ }
1578
+ Object.assign(createIsParse, isParse);
1579
+
1580
+ /**
1581
+ * Creates a reusable {@link assertParse} function.
1582
+ *
1583
+ * @danger You have to specify the generic argument `T`
1584
+ * @return Nothing until specifying the generic argument `T`
1585
+ * @throws compile error
1586
+ *
1587
+ * @author Jeongho Nam - https://github.com/samchon
1588
+ */
1589
+ export function createAssertParse(): never;
1590
+
1591
+ /**
1592
+ * Creates a reusable {@link assertParse} function.
1593
+ *
1594
+ * @template T Expected type of parsed value
1595
+ * @returns A reusable `assertParse` function
1596
+ *
1597
+ * @author Jeongho Nam - https://github.com/samchon
1598
+ */
1599
+ export function createAssertParse<T>(): (input: string) => Primitive<T>;
1600
+
1601
+ /**
1602
+ * @internal
1603
+ */
1604
+ export function createAssertParse<T>(): (input: string) => Primitive<T> {
1605
+ halt("createAssertParse");
1606
+ }
1607
+ Object.assign(createAssertParse, assertParse);
1608
+
1609
+ /**
1610
+ * Creates a reusable {@link validateParse} function.
1611
+ *
1612
+ * @danger You have to specify the generic argument `T`
1613
+ * @return Nothing until specifying the generic argument `T`
1614
+ * @throws compile error
1615
+ *
1616
+ * @author Jeongho Nam - https://github.com/samchon
1617
+ */
1618
+ export function createValidateParse(): never;
1619
+
1620
+ /**
1621
+ * Creates a reusable {@link validateParse} function.
1622
+ *
1623
+ * @template T Expected type of parsed value
1624
+ * @returns A reusable `validateParse` function
1625
+ *
1626
+ * @author Jeongho Nam - https://github.com/samchon
1627
+ */
1628
+ export function createValidateParse<T>(): (
1629
+ input: string,
1630
+ ) => IValidation<Primitive<T>>;
1631
+
1632
+ /**
1633
+ * @internal
1634
+ */
1635
+ export function createValidateParse<T>(): (
1636
+ input: string,
1637
+ ) => IValidation<Primitive<T>> {
1638
+ halt("createValidateParse");
1639
+ }
1640
+ Object.assign(createValidateParse, validateParse);
1641
+
1642
+ /**
1643
+ * Creates a reusable {@link stringify} function.
1644
+ *
1645
+ * @danger You have to specify the generic argument `T`
1646
+ * @return Nothing until specifying the generic argument `T`
1647
+ * @throws compile error
1648
+ *
1649
+ * @author Jeongho Nam - https://github.com/samchon
1650
+ */
1651
+ export function createStringify(): never;
1652
+
1653
+ /**
1654
+ * Creates a reusable {@link stringify} function.
1655
+ *
1656
+ * @template T Type of the input value
1657
+ * @returns A reusable `stringify` function
1658
+ *
1659
+ * @author Jeongho Nam - https://github.com/samchon
1660
+ */
1661
+ export function createStringify<T>(): (input: T) => string;
1662
+
1663
+ /**
1664
+ * @internal
1665
+ */
1666
+ export function createStringify<T>(): (input: T) => string {
1667
+ halt("createStringify");
1668
+ }
1669
+ Object.assign(createStringify, stringify);
1670
+
1671
+ /**
1672
+ * Creates a reusable {@link assertStringify} function.
1673
+ *
1674
+ * @danger You have to specify the generic argument `T`
1675
+ * @return Nothing until specifying the generic argument `T`
1676
+ * @throws compile error
1677
+ *
1678
+ * @author Jeongho Nam - https://github.com/samchon
1679
+ */
1680
+ export function createAssertStringify(): never;
1681
+
1682
+ /**
1683
+ * Creates a reusable {@link assertStringify} function.
1684
+ *
1685
+ * @template T Type of the input value
1686
+ * @returns A reusable `assertStringify` function
1687
+ *
1688
+ * @author Jeongho Nam - https://github.com/samchon
1689
+ */
1690
+ export function createAssertStringify<T>(): (input: unknown) => string;
1691
+
1692
+ /**
1693
+ * @internal
1694
+ */
1695
+ export function createAssertStringify(): (input: unknown) => string {
1696
+ halt("createAssertStringify");
1697
+ }
1698
+ Object.assign(createAssertStringify, assertStringify);
1699
+
1700
+ /**
1701
+ * Creates a reusable {@link isStringify} function.
1702
+ *
1703
+ * @danger You have to specify the generic argument `T`
1704
+ * @return Nothing until specifying the generic argument `T`
1705
+ * @throws compile error
1706
+ *
1707
+ * @author Jeongho Nam - https://github.com/samchon
1708
+ */
1709
+ export function createIsStringify(): never;
1710
+
1711
+ /**
1712
+ * Creates a reusable {@link isStringify} function.
1713
+ *
1714
+ * @template T Type of the input value
1715
+ * @returns A reusable `isStringify` function
1716
+ *
1717
+ * @author Jeongho Nam - https://github.com/samchon
1718
+ */
1719
+ export function createIsStringify<T>(): (input: unknown) => string | null;
1720
+
1721
+ /**
1722
+ * @internal
1723
+ */
1724
+ export function createIsStringify(): (input: unknown) => string | null {
1725
+ halt("createIsStringify");
1726
+ }
1727
+ Object.assign(createIsStringify, isStringify);
1728
+
1729
+ /**
1730
+ * Creates a reusable {@link validateStringify} function.
1731
+ *
1732
+ * @danger You have to specify the generic argument `T`
1733
+ * @return Nothing until specifying the generic argument `T`
1734
+ * @throws compile error
1735
+ *
1736
+ * @author Jeongho Nam - https://github.com/samchon
1737
+ */
1738
+ export function createValidateStringify(): never;
1739
+
1740
+ /**
1741
+ * Creates a reusable {@link validateStringify} function.
1742
+ *
1743
+ * @template T Type of the input value
1744
+ * @returns A reusable `validateStringify` function
1745
+
1746
+ * @author Jeongho Nam - https://github.com/samchon
1747
+ */
1748
+ export function createValidateStringify<T>(): (
1749
+ input: unknown,
1750
+ ) => IValidation<string>;
1751
+
1752
+ /**
1753
+ * @internal
1754
+ */
1755
+ export function createValidateStringify(): (
1756
+ input: unknown,
1757
+ ) => IValidation<string> {
1758
+ halt("createValidateStringify");
1759
+ }
1760
+ Object.assign(createValidateStringify, validateStringify);
1761
+
1762
+ /* -----------------------------------------------------------
1763
+ MISCELLANEOUS
1764
+ ----------------------------------------------------------- */
1765
+ /**
1766
+ * Creates a reusable {@link random} function.
1767
+ *
1768
+ * @danger You have to specify the generic argument `T`
1769
+ * @param generator Random data generator
1770
+ * @return Nothing until specifying the generic argument `T`
1771
+ * @throws compile error
1772
+ *
1773
+ * @author Jeongho Nam - https://github.com/samchon
1774
+ */
1775
+ export function createRandom(generator?: Partial<IRandomGenerator>): never;
1776
+
1777
+ /**
1778
+ * Creates a resuable {@link random} function.
1779
+ *
1780
+ * @template T Type of the input value
1781
+ * @param generator Random data generator
1782
+ * @returns A reusable `random` function
1783
+ *
1784
+ * @author Jeongho Nam - https://github.com/samchon
1785
+ */
1786
+ export function createRandom<T>(
1787
+ generator?: Partial<IRandomGenerator>,
1788
+ ): () => Primitive<T>;
1789
+
1790
+ /**
1791
+ * @internal
1792
+ */
1793
+ export function createRandom(): never {
1794
+ halt("createRandom");
1795
+ }
1796
+ Object.assign(createRandom, random);
1797
+
1798
+ /**
1799
+ * Creates a reusable {@link clone} function.
1800
+ *
1801
+ * @danger You have to specify the generic argument `T`
1802
+ * @return Nothing until specifying the generic argument `T`
1803
+ * @throws compile error
1804
+ *
1805
+ * @author Jeongho Nam - https://github.com/samchon
1806
+ */
1807
+ export function createClone(): never;
1808
+
1809
+ /**
1810
+ * Creates a resuable {@link clone} function.
1811
+ *
1812
+ * @template T Type of the input value
1813
+ * @returns A reusable `clone` function
1814
+ *
1815
+ * @author Jeongho Nam - https://github.com/samchon
1816
+ */
1817
+ export function createClone<T>(): (input: T) => Primitive<T>;
1818
+
1819
+ /**
1820
+ * @internal
1821
+ */
1822
+ export function createClone(): never {
1823
+ halt("createClone");
1824
+ }
1825
+ Object.assign(createClone, clone);
1826
+
1827
+ /**
1828
+ * Creates a reusable {@link assertClone} function.
1829
+ *
1830
+ * @danger You have to specify the generic argument `T`
1831
+ * @return Nothing until specifying the generic argument `T`
1832
+ * @throws compile error
1833
+ *
1834
+ * @author Jeongho Nam - https://github.com/samchon
1835
+ */
1836
+ export function createAssertClone(): never;
1837
+
1838
+ /**
1839
+ * Creates a resuable {@link assertClone} function.
1840
+ *
1841
+ * @template T Type of the input value
1842
+ * @returns A reusable `clone` function
1843
+ *
1844
+ * @author Jeongho Nam - https://github.com/samchon
1845
+ */
1846
+ export function createAssertClone<T>(): (input: unknown) => Primitive<T>;
1847
+
1848
+ /**
1849
+ * @internal
1850
+ */
1851
+ export function createAssertClone(): never {
1852
+ halt("createAssertClone");
1853
+ }
1854
+ Object.assign(createAssertClone, assertClone);
1855
+
1856
+ /**
1857
+ * Creates a reusable {@link isClone} function.
1858
+ *
1859
+ * @danger You have to specify the generic argument `T`
1860
+ * @return Nothing until specifying the generic argument `T`
1861
+ * @throws compile error
1862
+ *
1863
+ * @author Jeongho Nam - https://github.com/samchon
1864
+ */
1865
+ export function createIsClone(): never;
1866
+
1867
+ /**
1868
+ * Creates a resuable {@link isClone} function.
1869
+ *
1870
+ * @template T Type of the input value
1871
+ * @returns A reusable `clone` function
1872
+ *
1873
+ * @author Jeongho Nam - https://github.com/samchon
1874
+ */
1875
+ export function createIsClone<T>(): (input: unknown) => Primitive<T> | null;
1876
+
1877
+ /**
1878
+ * @internal
1879
+ */
1880
+ export function createIsClone(): never {
1881
+ halt("createIsClone");
1882
+ }
1883
+ Object.assign(createIsClone, isClone);
1884
+
1885
+ /**
1886
+ * Creates a reusable {@link validateClone} function.
1887
+ *
1888
+ * @danger You have to specify the generic argument `T`
1889
+ * @return Nothing until specifying the generic argument `T`
1890
+ * @throws compile error
1891
+ *
1892
+ * @author Jeongho Nam - https://github.com/samchon
1893
+ */
1894
+ export function createValidateClone(): never;
1895
+
1896
+ /**
1897
+ * Creates a resuable {@link validateClone} function.
1898
+ *
1899
+ * @template T Type of the input value
1900
+ * @returns A reusable `clone` function
1901
+ *
1902
+ * @author Jeongho Nam - https://github.com/samchon
1903
+ */
1904
+ export function createValidateClone<T>(): (
1905
+ input: unknown,
1906
+ ) => IValidation<Primitive<T>>;
1907
+
1908
+ /**
1909
+ * @internal
1910
+ */
1911
+ export function createValidateClone(): never {
1912
+ halt("createValidateClone");
1913
+ }
1914
+ Object.assign(createValidateClone, validateClone);
1915
+
1916
+ /**
1917
+ * Creates a reusable {@link prune} function.
1918
+ *
1919
+ * @danger You have to specify the generic argument `T`
1920
+ * @return Nothing until specifying the generic argument `T`
1921
+ * @throws compile error
1922
+ *
1923
+ * @author Jeongho Nam - https://github.com/samchon
1924
+ */
1925
+ export function createPrune(): never;
1926
+
1927
+ /**
1928
+ * Creates a resuable {@link prune} function.
1929
+ *
1930
+ * @template T Type of the input value
1931
+ * @returns A reusable `prune` function
1932
+ *
1933
+ * @author Jeongho Nam - https://github.com/samchon
1934
+ */
1935
+ export function createPrune<T extends object>(): (input: T) => void;
1936
+
1937
+ /**
1938
+ * @internal
1939
+ */
1940
+ export function createPrune<T extends object>(): (input: T) => void {
1941
+ halt("createPrune");
1942
+ }
1943
+ Object.assign(createPrune, prune);
1944
+
1945
+ /**
1946
+ * Creates a reusable {@link assertPrune} function.
1947
+ *
1948
+ * @danger You have to specify the generic argument `T`
1949
+ * @return Nothing until specifying the generic argument `T`
1950
+ * @throws compile error
1951
+ *
1952
+ * @author Jeongho Nam - https://github.com/samchon
1953
+ */
1954
+ export function createAssertPrune(): never;
1955
+
1956
+ /**
1957
+ * Creates a resuable {@link assertPrune} function.
1958
+ *
1959
+ * @template T Type of the input value
1960
+ * @returns A reusable `isPrune` function
1961
+ *
1962
+ * @author Jeongho Nam - https://github.com/samchon
1963
+ */
1964
+ export function createAssertPrune<T extends object>(): (input: T) => T;
1965
+
1966
+ /**
1967
+ * @internal
1968
+ */
1969
+ export function createAssertPrune<T extends object>(): (input: T) => T {
1970
+ halt("createAssertPrune");
1971
+ }
1972
+ Object.assign(createAssertPrune, assertPrune);
1973
+
1974
+ /**
1975
+ * Creates a reusable {@link isPrune} function.
1976
+ *
1977
+ * @danger You have to specify the generic argument `T`
1978
+ * @return Nothing until specifying the generic argument `T`
1979
+ * @throws compile error
1980
+ *
1981
+ * @author Jeongho Nam - https://github.com/samchon
1982
+ */
1983
+ export function createIsPrune(): never;
1984
+
1985
+ /**
1986
+ * Creates a resuable {@link isPrune} function.
1987
+ *
1988
+ * @template T Type of the input value
1989
+ * @returns A reusable `isPrune` function
1990
+ *
1991
+ * @author Jeongho Nam - https://github.com/samchon
1992
+ */
1993
+ export function createIsPrune<T extends object>(): (input: T) => input is T;
1994
+
1995
+ /**
1996
+ * @internal
1997
+ */
1998
+ export function createIsPrune<T extends object>(): (input: T) => input is T {
1999
+ halt("createIsPrune");
2000
+ }
2001
+ Object.assign(createIsPrune, isPrune);
2002
+
2003
+ /**
2004
+ * Creates a reusable {@link validatePrune} function.
2005
+ *
2006
+ * @danger You have to specify the generic argument `T`
2007
+ * @return Nothing until specifying the generic argument `T`
2008
+ * @throws compile error
2009
+ *
2010
+ * @author Jeongho Nam - https://github.com/samchon
2011
+ */
2012
+ export function createValidatePrune(): never;
2013
+
2014
+ /**
2015
+ * Creates a resuable {@link validatePrune} function.
2016
+ *
2017
+ * @template T Type of the input value
2018
+ * @returns A reusable `validatePrune` function
2019
+ *
2020
+ * @author Jeongho Nam - https://github.com/samchon
2021
+ */
2022
+ export function createValidatePrune<T extends object>(): (
2023
+ input: T,
2024
+ ) => IValidation<T>;
2025
+
2026
+ /**
2027
+ * @internal
2028
+ */
2029
+ export function createValidatePrune<T extends object>(): (
2030
+ input: T,
2031
+ ) => IValidation<T> {
2032
+ halt("createValidatePrune");
2033
+ }
2034
+ Object.assign(createValidatePrune, validatePrune);
2035
+
2036
+ /**
2037
+ * @internal
2038
+ */
2039
+ function halt(name: string): never {
2040
+ throw new Error(
2041
+ `Error on typia.${name}(): no transform has been configured. Run "npx typia setup" command.`,
2042
+ );
2043
+ }