typia 5.2.4 → 5.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/factories/internal/metadata/emplace_metadata_object.js +24 -0
- package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
- package/lib/functional/$stoll.d.ts +1 -0
- package/lib/functional/$stoll.js +14 -0
- package/lib/functional/$stoll.js.map +1 -0
- package/lib/functional/Namespace.js +4 -10
- package/lib/functional/Namespace.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +71 -63
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +2 -2
- package/lib/programmers/IsProgrammer.js +66 -64
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +50 -46
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_key.d.ts +5 -0
- package/lib/programmers/internal/check_dynamic_key.js +158 -0
- package/lib/programmers/internal/check_dynamic_key.js.map +1 -0
- package/lib/programmers/internal/check_dynamic_properties.js +69 -61
- package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/check_object.js +11 -9
- package/lib/programmers/internal/check_object.js.map +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/package.json +2 -2
- package/src/CamelCase.ts +116 -116
- package/src/PascalCase.ts +116 -116
- package/src/Primitive.ts +135 -135
- package/src/Resolved.ts +116 -116
- package/src/SnakeCase.ts +156 -156
- package/src/executable/TypiaSetupWizard.ts +142 -142
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/factories/JsonMetadataFactory.ts +50 -50
- package/src/factories/MetadataCollection.ts +282 -282
- package/src/factories/internal/metadata/emplace_metadata_object.ts +28 -0
- package/src/functional/$convention.ts +40 -40
- package/src/functional/$stoll.ts +8 -0
- package/src/functional/Namespace.ts +168 -164
- package/src/module.ts +662 -662
- package/src/notations.ts +855 -855
- package/src/programmers/AssertProgrammer.ts +36 -31
- package/src/programmers/IsProgrammer.ts +13 -7
- package/src/programmers/ValidateProgrammer.ts +34 -31
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/NotationJoiner.ts +146 -146
- package/src/programmers/internal/check_dynamic_key.ts +178 -0
- package/src/programmers/internal/check_dynamic_properties.ts +19 -12
- package/src/programmers/internal/check_object.ts +8 -1
- package/src/programmers/json/JsonStringifyProgrammer.ts +1 -1
- package/src/programmers/misc/MiscCloneProgrammer.ts +790 -790
- package/src/programmers/misc/MiscPruneProgrammer.ts +552 -552
- package/src/programmers/notations/NotationAssertGeneralProgrammer.ts +72 -72
- package/src/programmers/notations/NotationGeneralProgrammer.ts +720 -720
- package/src/programmers/notations/NotationIsGeneralProgrammer.ts +79 -79
- package/src/programmers/notations/NotationValidateGeneralProgrammer.ts +88 -88
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +1 -1
- package/src/transformers/CallExpressionTransformer.ts +380 -380
- package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +12 -12
- package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
- package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +12 -12
- package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +12 -12
- package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
- package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +12 -12
- package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +12 -12
- package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +12 -12
- package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +12 -12
- package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
- package/src/transformers/features/notations/NotationAssertGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationCreateAssertGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationCreateGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationCreateIsGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationCreateValidateGeneralTransformer.ts +17 -17
- package/src/transformers/features/notations/NotationGeneralTransformer.ts +11 -11
- package/src/transformers/features/notations/NotationIsGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationValidateGeneralTransformer.ts +17 -17
- package/src/transformers/features/protobuf/ProtobufCreateAssertDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufCreateAssertEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufCreateDecodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufCreateEncodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufCreateIsDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufCreateIsEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufCreateValidateDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufCreateValidateEncodeTransformer.ts +12 -12
- package/src/utils/NamingConvention.ts +91 -91
- package/src/utils/StringUtil.ts +4 -4
package/src/module.ts
CHANGED
|
@@ -1,662 +1,662 @@
|
|
|
1
|
-
import { Namespace } from "./functional/Namespace";
|
|
2
|
-
|
|
3
|
-
import { IMetadataApplication } from "./schemas/metadata/IMetadataApplication";
|
|
4
|
-
|
|
5
|
-
import { IRandomGenerator } from "./IRandomGenerator";
|
|
6
|
-
import { IValidation } from "./IValidation";
|
|
7
|
-
import { Resolved } from "./Resolved";
|
|
8
|
-
|
|
9
|
-
export * as http from "./http";
|
|
10
|
-
export * as json from "./json";
|
|
11
|
-
export * as misc from "./misc";
|
|
12
|
-
export * as notations from "./notations";
|
|
13
|
-
export * as protobuf from "./protobuf";
|
|
14
|
-
export * as tags from "./tags";
|
|
15
|
-
|
|
16
|
-
export * from "./schemas/json/IJsonApplication";
|
|
17
|
-
export * from "./schemas/json/IJsonComponents";
|
|
18
|
-
export * from "./schemas/json/IJsonSchema";
|
|
19
|
-
export * from "./IRandomGenerator";
|
|
20
|
-
export * from "./IValidation";
|
|
21
|
-
export * from "./TypeGuardError";
|
|
22
|
-
|
|
23
|
-
export * from "./Primitive";
|
|
24
|
-
export * from "./Resolved";
|
|
25
|
-
export * from "./CamelCase";
|
|
26
|
-
export * from "./PascalCase";
|
|
27
|
-
export * from "./SnakeCase";
|
|
28
|
-
|
|
29
|
-
/* -----------------------------------------------------------
|
|
30
|
-
BASIC VALIDATORS
|
|
31
|
-
----------------------------------------------------------- */
|
|
32
|
-
/**
|
|
33
|
-
* Asserts a value type.
|
|
34
|
-
*
|
|
35
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
|
|
36
|
-
* reason, if the parametric value is not following the type `T`. Otherwise, the
|
|
37
|
-
* value is following the type `T`, just input parameter would be returned.
|
|
38
|
-
*
|
|
39
|
-
* If what you want is not asserting but just knowing whether the parametric value is
|
|
40
|
-
* following the type `T` or not, you can choose the {@link is} function instead.
|
|
41
|
-
* Otherwise you want to know all the errors, {@link validate} is the way to go.
|
|
42
|
-
*
|
|
43
|
-
* On the other and, if you don't want to allow any superfluous property that is not
|
|
44
|
-
* enrolled to the type `T`, you can use {@link assertEquals} function instead.
|
|
45
|
-
*
|
|
46
|
-
* @template T Type of the input value
|
|
47
|
-
* @param input A value to be asserted
|
|
48
|
-
* @returns Parametric input value
|
|
49
|
-
* @throws A {@link TypeGuardError} instance with detailed reason
|
|
50
|
-
*
|
|
51
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
52
|
-
*/
|
|
53
|
-
export function assert<T>(input: T): T;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Asserts a value type.
|
|
57
|
-
*
|
|
58
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
|
|
59
|
-
* reason, if the parametric value is not following the type `T`. Otherwise, the
|
|
60
|
-
* value is following the type `T`, just input parameter would be returned.
|
|
61
|
-
*
|
|
62
|
-
* If what you want is not asserting but just knowing whether the parametric value is
|
|
63
|
-
* following the type `T` or not, you can choose the {@link is} function instead.
|
|
64
|
-
* Otherwise, you want to know all the errors, {@link validate} is the way to go.
|
|
65
|
-
*
|
|
66
|
-
* On the other and, if you don't want to allow any superfluous property that is not
|
|
67
|
-
* enrolled to the type `T`, you can use {@link assertEquals} function instead.
|
|
68
|
-
*
|
|
69
|
-
* @template T Type of the input value
|
|
70
|
-
* @param input A value to be asserted
|
|
71
|
-
* @returns Parametric input value casted as `T`
|
|
72
|
-
* @throws A {@link TypeGuardError} instance with detailed reason
|
|
73
|
-
*
|
|
74
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
75
|
-
*/
|
|
76
|
-
export function assert<T>(input: unknown): T;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @internal
|
|
80
|
-
*/
|
|
81
|
-
export function assert(): never {
|
|
82
|
-
halt("assert");
|
|
83
|
-
}
|
|
84
|
-
Object.assign(assert, Namespace.assert("assert"));
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Tests a value type.
|
|
88
|
-
*
|
|
89
|
-
* Tests a parametric value type and returns whether it's following the type `T` or not.
|
|
90
|
-
* If the parametric value is matched with the type `T`, `true` value would be returned.
|
|
91
|
-
* Otherwise, the parametric value is not following the type `T`, `false` value would be
|
|
92
|
-
* returned.
|
|
93
|
-
*
|
|
94
|
-
* If what you want is not just knowing whether the parametric value is following the
|
|
95
|
-
* type `T` or not, but throwing an exception with detailed reason, you can choose
|
|
96
|
-
* {@link assert} function instead. Also, if you want to know all the errors with
|
|
97
|
-
* detailed reasons, {@link validate} function would be useful.
|
|
98
|
-
*
|
|
99
|
-
* On the other and, if you don't want to allow any superfluous property that is not
|
|
100
|
-
* enrolled to the type `T`, you can use {@link equals} function instead.
|
|
101
|
-
*
|
|
102
|
-
* @template T Type of the input value
|
|
103
|
-
* @param input A value to be tested
|
|
104
|
-
* @returns Whether the parametric value is following the type `T` or not
|
|
105
|
-
*
|
|
106
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
107
|
-
*/
|
|
108
|
-
export function is<T>(input: T): input is T;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Tests a value type.
|
|
112
|
-
*
|
|
113
|
-
* Tests a parametric value type and returns whether it's following the type `T` or not.
|
|
114
|
-
* If the parametric value is matched with the type `T`, `true` value would be returned.
|
|
115
|
-
* Otherwise, the parametric value is not following the type `T`, `false` value would be
|
|
116
|
-
* returned.
|
|
117
|
-
*
|
|
118
|
-
* If what you want is not just knowing whether the parametric value is following the
|
|
119
|
-
* type `T` or not, but throwing an exception with detailed reason, you can choose
|
|
120
|
-
* {@link assert} function instead. Also, if you want to know all the errors with
|
|
121
|
-
* detailed reasons, {@link validate} function would be useful.
|
|
122
|
-
*
|
|
123
|
-
* On the other and, if you don't want to allow any superfluous property that is not
|
|
124
|
-
* enrolled to the type `T`, you can use {@link equals} function instead.
|
|
125
|
-
*
|
|
126
|
-
* @template T Type of the input value
|
|
127
|
-
* @param input A value to be tested
|
|
128
|
-
* @returns Whether the parametric value is following the type `T` or not
|
|
129
|
-
*
|
|
130
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
131
|
-
*/
|
|
132
|
-
export function is<T>(input: unknown): input is T;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @internal
|
|
136
|
-
*/
|
|
137
|
-
export function is(): never {
|
|
138
|
-
halt("is");
|
|
139
|
-
}
|
|
140
|
-
Object.assign(is, Namespace.assert("is"));
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Validates a value type.
|
|
144
|
-
*
|
|
145
|
-
* Validates a parametric value type and archives all the type errors into an
|
|
146
|
-
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
147
|
-
* type `T`. Of course, if the parametric value is following the type `T`, the
|
|
148
|
-
* {@link IValidation.errors} array would be empty and {@link IValidation.success}
|
|
149
|
-
* would have the `true` value.
|
|
150
|
-
*
|
|
151
|
-
* If what you want is not finding all the error, but asserting the parametric value
|
|
152
|
-
* type with exception throwing, you can choose {@link assert} function instead.
|
|
153
|
-
* Otherwise, you just want to know whether the parametric value is matched with the
|
|
154
|
-
* type `T`, {@link is} function is the way to go.
|
|
155
|
-
*
|
|
156
|
-
* On the other and, if you don't want to allow any superfluous property that is not
|
|
157
|
-
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
|
|
158
|
-
*
|
|
159
|
-
* @template Type of the input value
|
|
160
|
-
* @param input A value to be validated
|
|
161
|
-
* @returns Validation result
|
|
162
|
-
*
|
|
163
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
164
|
-
*/
|
|
165
|
-
export function validate<T>(input: T): IValidation<T>;
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Validates a value type.
|
|
169
|
-
*
|
|
170
|
-
* Validates a parametric value type and archives all the type errors into an
|
|
171
|
-
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
172
|
-
* type `T`. Of course, if the parametric value is following the type `T`, the
|
|
173
|
-
* {@link IValidation.errors} array would be empty and {@link IValidation.success}
|
|
174
|
-
* would have the `true` value.
|
|
175
|
-
*
|
|
176
|
-
* If what you want is not finding all the error, but asserting the parametric value
|
|
177
|
-
* type with exception throwing, you can choose {@link assert} function instead.
|
|
178
|
-
* Otherwise, you just want to know whether the parametric value is matched with the
|
|
179
|
-
* type `T`, {@link is} function is the way to go.
|
|
180
|
-
*
|
|
181
|
-
* On the other and, if you don't want to allow any superfluous property that is not
|
|
182
|
-
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
|
|
183
|
-
*
|
|
184
|
-
* @template Type of the input value
|
|
185
|
-
* @param input A value to be validated
|
|
186
|
-
* @returns Validation result
|
|
187
|
-
*
|
|
188
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
189
|
-
*/
|
|
190
|
-
export function validate<T>(input: unknown): IValidation<T>;
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @internal
|
|
194
|
-
*/
|
|
195
|
-
export function validate(): never {
|
|
196
|
-
halt("validate");
|
|
197
|
-
}
|
|
198
|
-
Object.assign(validate, Namespace.validate());
|
|
199
|
-
|
|
200
|
-
/* -----------------------------------------------------------
|
|
201
|
-
STRICT VALIDATORS
|
|
202
|
-
----------------------------------------------------------- */
|
|
203
|
-
/**
|
|
204
|
-
* Asserts equality between a value and its type.
|
|
205
|
-
*
|
|
206
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
|
|
207
|
-
* reason, if the parametric value is not following the type `T` or some superfluous
|
|
208
|
-
* property that is not listed on the type `T` has been found. Otherwise, the value is
|
|
209
|
-
* following the type `T` without any superfluous property, just input parameter would
|
|
210
|
-
* be returned.
|
|
211
|
-
*
|
|
212
|
-
* If what you want is not asserting but just knowing whether the parametric value is
|
|
213
|
-
* following the type `T` or not, you can choose the {@link equals} function instead.
|
|
214
|
-
* Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
|
|
215
|
-
*
|
|
216
|
-
* On the other hand, if you want to allow superfluous property that is not enrolled
|
|
217
|
-
* to the type `T`, you can use {@link assert} function instead.
|
|
218
|
-
*
|
|
219
|
-
* @template T Type of the input value
|
|
220
|
-
* @param input A value to be asserted
|
|
221
|
-
* @returns Parametric input value
|
|
222
|
-
* @throws A {@link TypeGuardError} instance with detailed reason
|
|
223
|
-
*
|
|
224
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
225
|
-
*/
|
|
226
|
-
export function assertEquals<T>(input: T): T;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Asserts equality between a value and its type.
|
|
230
|
-
*
|
|
231
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
|
|
232
|
-
* reason, if the parametric value is not following the type `T` or some superfluous
|
|
233
|
-
* property that is not listed on the type `T` has been found. Otherwise, the value is
|
|
234
|
-
* following the type `T` without any superfluous property, just input parameter would
|
|
235
|
-
* be returned.
|
|
236
|
-
*
|
|
237
|
-
* If what you want is not asserting but just knowing whether the parametric value is
|
|
238
|
-
* following the type `T` or not, you can choose the {@link equals} function instead.
|
|
239
|
-
* Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
|
|
240
|
-
*
|
|
241
|
-
* On the other hand, if you want to allow superfluous property that is not enrolled
|
|
242
|
-
* to the type `T`, you can use {@link assert} function instead.
|
|
243
|
-
*
|
|
244
|
-
* @template T Type of the input value
|
|
245
|
-
* @param input A value to be asserted
|
|
246
|
-
* @returns Parametric input value casted as `T`
|
|
247
|
-
* @throws A {@link TypeGuardError} instance with detailed reason
|
|
248
|
-
*
|
|
249
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
250
|
-
*/
|
|
251
|
-
export function assertEquals<T>(input: unknown): T;
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* @internal
|
|
255
|
-
*/
|
|
256
|
-
export function assertEquals(): never {
|
|
257
|
-
halt("assertEquals");
|
|
258
|
-
}
|
|
259
|
-
Object.assign(assertEquals, Namespace.assert("assertEquals"));
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Tests equality between a value and its type.
|
|
263
|
-
*
|
|
264
|
-
* Tests a parametric value type and returns whether it's equivalent to the type `T`
|
|
265
|
-
* or not. If the parametric value is matched with the type `T` and there's not any
|
|
266
|
-
* superfluous property that is not listed on the type `T`, `true` value would be
|
|
267
|
-
* returned. Otherwise, the parametric value is not following the type `T` or some
|
|
268
|
-
* superfluous property exists, `false` value would be returned.
|
|
269
|
-
*
|
|
270
|
-
* If what you want is not just knowing whether the parametric value is following the
|
|
271
|
-
* type `T` or not, but throwing an exception with detailed reason, you can choose
|
|
272
|
-
* {@link assertEquals} function instead. Also, if you want to know all the errors with
|
|
273
|
-
* detailed reasons, {@link validateEquals} function would be useful.
|
|
274
|
-
*
|
|
275
|
-
* On the other hand, if you want to allow superfluous property that is not enrolled
|
|
276
|
-
* to the type `T`, you can use {@link is} function instead.
|
|
277
|
-
*
|
|
278
|
-
* @template T Type of the input value
|
|
279
|
-
* @param input A value to be tested
|
|
280
|
-
* @returns Whether the parametric value is equivalent to the type `T` or not
|
|
281
|
-
*
|
|
282
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
283
|
-
*/
|
|
284
|
-
export function equals<T>(input: T): input is T;
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Tests equality between a value and its type.
|
|
288
|
-
*
|
|
289
|
-
* Tests a parametric value type and returns whether it's equivalent to the type `T`
|
|
290
|
-
* or not. If the parametric value is matched with the type `T` and there's not any
|
|
291
|
-
* superfluous property that is not listed on the type `T`, `true` value would be
|
|
292
|
-
* returned. Otherwise, the parametric value is not following the type `T` or some
|
|
293
|
-
* superfluous property exists, `false` value would be returned.
|
|
294
|
-
*
|
|
295
|
-
* If what you want is not just knowing whether the parametric value is following the
|
|
296
|
-
* type `T` or not, but throwing an exception with detailed reason, you can choose
|
|
297
|
-
* {@link assertEquals} function instead. Also, if you want to know all the errors with
|
|
298
|
-
* detailed reasons, {@link validateEquals} function would be useful.
|
|
299
|
-
*
|
|
300
|
-
* On the other hand, if you want to allow superfluous property that is not enrolled
|
|
301
|
-
* to the type `T`, you can use {@link is} function instead.
|
|
302
|
-
*
|
|
303
|
-
* @template T Type of the input value
|
|
304
|
-
* @param input A value to be tested
|
|
305
|
-
* @returns Whether the parametric value is equivalent to the type `T` or not
|
|
306
|
-
*
|
|
307
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
308
|
-
*/
|
|
309
|
-
export function equals<T>(input: unknown): input is T;
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* @internal
|
|
313
|
-
*/
|
|
314
|
-
export function equals(): never {
|
|
315
|
-
halt("equals");
|
|
316
|
-
}
|
|
317
|
-
Object.assign(equals, Namespace.is());
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Validates equality between a value and its type.
|
|
321
|
-
*
|
|
322
|
-
* Validates a parametric value type and archives all the type errors into an
|
|
323
|
-
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
324
|
-
* type `T` or some superfluous property that is not listed on the type `T` has been
|
|
325
|
-
* found. Of course, if the parametric value is following the type `T` and no
|
|
326
|
-
* superfluous property exists, the {@link IValidation.errors} array would be empty
|
|
327
|
-
* and {@link IValidation.success} would have the `true` value.
|
|
328
|
-
*
|
|
329
|
-
* If what you want is not finding all the error, but asserting the parametric value
|
|
330
|
-
* type with exception throwing, you can choose {@link assert} function instead.
|
|
331
|
-
* Otherwise, you just want to know whether the parametric value is matched with the
|
|
332
|
-
* type `T`, {@link is} function is the way to go.
|
|
333
|
-
*
|
|
334
|
-
* On the other and, if you don't want to allow any superfluous property that is not
|
|
335
|
-
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
|
|
336
|
-
*
|
|
337
|
-
* @template Type of the input value
|
|
338
|
-
* @param input A value to be validated
|
|
339
|
-
* @returns Validation result
|
|
340
|
-
*
|
|
341
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
342
|
-
*/
|
|
343
|
-
export function validateEquals<T>(input: T): IValidation<T>;
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Validates equality between a value and its type.
|
|
347
|
-
*
|
|
348
|
-
* Validates a parametric value type and archives all the type errors into an
|
|
349
|
-
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
350
|
-
* type `T` or some superfluous property that is not listed on the type `T` has been
|
|
351
|
-
* found. Of course, if the parametric value is following the type `T` and no
|
|
352
|
-
* superfluous property exists, the {@link IValidation.errors} array would be empty
|
|
353
|
-
* and {@link IValidation.success} would have the `true` value.
|
|
354
|
-
*
|
|
355
|
-
* If what you want is not finding all the error, but asserting the parametric value
|
|
356
|
-
* type with exception throwing, you can choose {@link assert} function instead.
|
|
357
|
-
* Otherwise, you just want to know whether the parametric value is matched with the
|
|
358
|
-
* type `T`, {@link is} function is the way to go.
|
|
359
|
-
*
|
|
360
|
-
* On the other and, if you don't want to allow any superfluous property that is not
|
|
361
|
-
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
|
|
362
|
-
*
|
|
363
|
-
* @template Type of the input value
|
|
364
|
-
* @param input A value to be validated
|
|
365
|
-
* @returns Validation result
|
|
366
|
-
*
|
|
367
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
368
|
-
*/
|
|
369
|
-
export function validateEquals<T>(input: unknown): IValidation<T>;
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* @internal
|
|
373
|
-
*/
|
|
374
|
-
export function validateEquals(): never {
|
|
375
|
-
halt("validateEquals");
|
|
376
|
-
}
|
|
377
|
-
Object.assign(validateEquals, Namespace.validate());
|
|
378
|
-
|
|
379
|
-
/* -----------------------------------------------------------
|
|
380
|
-
RANDOM
|
|
381
|
-
----------------------------------------------------------- */
|
|
382
|
-
/**
|
|
383
|
-
* > You must configure the generic argument `T`.
|
|
384
|
-
*
|
|
385
|
-
* Generate random data.
|
|
386
|
-
*
|
|
387
|
-
* Generates a random data following type the `T`.
|
|
388
|
-
*
|
|
389
|
-
* For reference, this `typia.random()` function generates only primitive type.
|
|
390
|
-
* If there're some methods in the type `T` or its nested instances, those would
|
|
391
|
-
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
392
|
-
* would be generated instead.
|
|
393
|
-
*
|
|
394
|
-
* @template T Type of data to generate
|
|
395
|
-
* @param generator Random data generator
|
|
396
|
-
* @return Randomly generated data
|
|
397
|
-
*
|
|
398
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
399
|
-
*/
|
|
400
|
-
export function random(generator?: Partial<IRandomGenerator>): never;
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Generate random data.
|
|
404
|
-
*
|
|
405
|
-
* Generates a random data following type the `T`.
|
|
406
|
-
*
|
|
407
|
-
* For reference, this `typia.random()` function generates only primitive type.
|
|
408
|
-
* If there're some methods in the type `T` or its nested instances, those would
|
|
409
|
-
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
410
|
-
* would be generated instead.
|
|
411
|
-
*
|
|
412
|
-
* @template T Type of data to generate
|
|
413
|
-
* @param generator Random data generator
|
|
414
|
-
* @return Randomly generated data
|
|
415
|
-
*
|
|
416
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
417
|
-
*/
|
|
418
|
-
export function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* @internal
|
|
422
|
-
*/
|
|
423
|
-
export function random(): never {
|
|
424
|
-
halt("random");
|
|
425
|
-
}
|
|
426
|
-
Object.assign(random, Namespace.random());
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* @internal
|
|
430
|
-
*/
|
|
431
|
-
export function metadata(): never;
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* @internal
|
|
435
|
-
*/
|
|
436
|
-
export function metadata<Types extends unknown[]>(): IMetadataApplication;
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* @internal
|
|
440
|
-
*/
|
|
441
|
-
export function metadata(): never {
|
|
442
|
-
halt("metadata");
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/* -----------------------------------------------------------
|
|
446
|
-
FACTORY FUNCTIONS
|
|
447
|
-
----------------------------------------------------------- */
|
|
448
|
-
/**
|
|
449
|
-
* Creates a reusable {@link assert} function.
|
|
450
|
-
*
|
|
451
|
-
* @danger You must configure the generic argument `T`
|
|
452
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
453
|
-
* @throws compile error
|
|
454
|
-
*
|
|
455
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
456
|
-
*/
|
|
457
|
-
export function createAssert(): never;
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Creates a reusable {@link assert} function.
|
|
461
|
-
*
|
|
462
|
-
* @template T Type of the input value
|
|
463
|
-
* @returns A reusable `assert` function
|
|
464
|
-
*
|
|
465
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
466
|
-
*/
|
|
467
|
-
export function createAssert<T>(): (input: unknown) => T;
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* @internal
|
|
471
|
-
*/
|
|
472
|
-
export function createAssert<T>(): (input: unknown) => T {
|
|
473
|
-
halt("createAssert");
|
|
474
|
-
}
|
|
475
|
-
Object.assign(createAssert, assert);
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* Creates a reusable {@link is} function.
|
|
479
|
-
*
|
|
480
|
-
* @danger You must configure the generic argument `T`
|
|
481
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
482
|
-
* @throws compile error
|
|
483
|
-
*
|
|
484
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
485
|
-
*/
|
|
486
|
-
export function createIs(): never;
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Creates a reusable {@link is} function.
|
|
490
|
-
*
|
|
491
|
-
* @template T Type of the input value
|
|
492
|
-
* @returns A reusable `is` function
|
|
493
|
-
*
|
|
494
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
495
|
-
*/
|
|
496
|
-
export function createIs<T>(): (input: unknown) => input is T;
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* @internal
|
|
500
|
-
*/
|
|
501
|
-
export function createIs<T>(): (input: unknown) => input is T {
|
|
502
|
-
halt("createIs");
|
|
503
|
-
}
|
|
504
|
-
Object.assign(createIs, is);
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Creates a reusable {@link validate} function.
|
|
508
|
-
*
|
|
509
|
-
* @danger You must configure the generic argument `T`
|
|
510
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
511
|
-
* @throws compile error
|
|
512
|
-
*
|
|
513
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
514
|
-
*/
|
|
515
|
-
export function createValidate(): never;
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Creates a reusable {@link validate} function.
|
|
519
|
-
*
|
|
520
|
-
* @template T Type of the input value
|
|
521
|
-
* @returns A reusable `validate` function
|
|
522
|
-
*
|
|
523
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
524
|
-
*/
|
|
525
|
-
export function createValidate<T>(): (input: unknown) => IValidation<T>;
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* @internal
|
|
529
|
-
*/
|
|
530
|
-
export function createValidate(): (input: unknown) => IValidation {
|
|
531
|
-
halt("createValidate");
|
|
532
|
-
}
|
|
533
|
-
Object.assign(createValidate, validate);
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Creates a reusable {@link assertEquals} function.
|
|
537
|
-
*
|
|
538
|
-
* @danger You must configure the generic argument `T`
|
|
539
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
540
|
-
* @throws compile error
|
|
541
|
-
*
|
|
542
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
543
|
-
*/
|
|
544
|
-
export function createAssertEquals(): never;
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Creates a reusable {@link assertEquals} function.
|
|
548
|
-
*
|
|
549
|
-
* @template T Type of the input value
|
|
550
|
-
* @returns A reusable `assertEquals` function
|
|
551
|
-
*
|
|
552
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
553
|
-
*/
|
|
554
|
-
export function createAssertEquals<T>(): (input: unknown) => T;
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* @internal
|
|
558
|
-
*/
|
|
559
|
-
export function createAssertEquals<T>(): (input: unknown) => T {
|
|
560
|
-
halt("createAssertEquals");
|
|
561
|
-
}
|
|
562
|
-
Object.assign(createAssertEquals, assertEquals);
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Creates a reusable {@link equals} function.
|
|
566
|
-
*
|
|
567
|
-
* @danger You must configure the generic argument `T`
|
|
568
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
569
|
-
* @throws compile error
|
|
570
|
-
*
|
|
571
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
572
|
-
*/
|
|
573
|
-
export function createEquals(): never;
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* Creates a reusable {@link equals} function.
|
|
577
|
-
*
|
|
578
|
-
* @template T Type of the input value
|
|
579
|
-
* @returns A reusable `equals` function
|
|
580
|
-
*
|
|
581
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
582
|
-
*/
|
|
583
|
-
export function createEquals<T>(): (input: unknown) => input is T;
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* @internal
|
|
587
|
-
*/
|
|
588
|
-
export function createEquals<T>(): (input: unknown) => input is T {
|
|
589
|
-
halt("createEquals");
|
|
590
|
-
}
|
|
591
|
-
Object.assign(createEquals, equals);
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Creates a reusable {@link validateEquals} function.
|
|
595
|
-
*
|
|
596
|
-
* @danger You must configure the generic argument `T`
|
|
597
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
598
|
-
* @throws compile error
|
|
599
|
-
*
|
|
600
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
601
|
-
*/
|
|
602
|
-
export function createValidateEquals(): never;
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Creates a reusable {@link validateEquals} function.
|
|
606
|
-
*
|
|
607
|
-
* @template T Type of the input value
|
|
608
|
-
* @returns A reusable `validateEquals` function
|
|
609
|
-
*
|
|
610
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
611
|
-
*/
|
|
612
|
-
export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* @internal
|
|
616
|
-
*/
|
|
617
|
-
export function createValidateEquals(): (input: unknown) => IValidation {
|
|
618
|
-
halt("createValidateEquals");
|
|
619
|
-
}
|
|
620
|
-
Object.assign(createValidateEquals, validateEquals);
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* Creates a reusable {@link random} function.
|
|
624
|
-
*
|
|
625
|
-
* @danger You must configure the generic argument `T`
|
|
626
|
-
* @param generator Random data generator
|
|
627
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
628
|
-
* @throws compile error
|
|
629
|
-
*
|
|
630
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
631
|
-
*/
|
|
632
|
-
export function createRandom(generator?: Partial<IRandomGenerator>): never;
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Creates a resuable {@link random} function.
|
|
636
|
-
*
|
|
637
|
-
* @template T Type of the input value
|
|
638
|
-
* @param generator Random data generator
|
|
639
|
-
* @returns A reusable `random` function
|
|
640
|
-
*
|
|
641
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
642
|
-
*/
|
|
643
|
-
export function createRandom<T>(
|
|
644
|
-
generator?: Partial<IRandomGenerator>,
|
|
645
|
-
): () => Resolved<T>;
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* @internal
|
|
649
|
-
*/
|
|
650
|
-
export function createRandom(): never {
|
|
651
|
-
halt("createRandom");
|
|
652
|
-
}
|
|
653
|
-
Object.assign(createRandom, random);
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* @internal
|
|
657
|
-
*/
|
|
658
|
-
function halt(name: string): never {
|
|
659
|
-
throw new Error(
|
|
660
|
-
`Error on typia.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
|
|
661
|
-
);
|
|
662
|
-
}
|
|
1
|
+
import { Namespace } from "./functional/Namespace";
|
|
2
|
+
|
|
3
|
+
import { IMetadataApplication } from "./schemas/metadata/IMetadataApplication";
|
|
4
|
+
|
|
5
|
+
import { IRandomGenerator } from "./IRandomGenerator";
|
|
6
|
+
import { IValidation } from "./IValidation";
|
|
7
|
+
import { Resolved } from "./Resolved";
|
|
8
|
+
|
|
9
|
+
export * as http from "./http";
|
|
10
|
+
export * as json from "./json";
|
|
11
|
+
export * as misc from "./misc";
|
|
12
|
+
export * as notations from "./notations";
|
|
13
|
+
export * as protobuf from "./protobuf";
|
|
14
|
+
export * as tags from "./tags";
|
|
15
|
+
|
|
16
|
+
export * from "./schemas/json/IJsonApplication";
|
|
17
|
+
export * from "./schemas/json/IJsonComponents";
|
|
18
|
+
export * from "./schemas/json/IJsonSchema";
|
|
19
|
+
export * from "./IRandomGenerator";
|
|
20
|
+
export * from "./IValidation";
|
|
21
|
+
export * from "./TypeGuardError";
|
|
22
|
+
|
|
23
|
+
export * from "./Primitive";
|
|
24
|
+
export * from "./Resolved";
|
|
25
|
+
export * from "./CamelCase";
|
|
26
|
+
export * from "./PascalCase";
|
|
27
|
+
export * from "./SnakeCase";
|
|
28
|
+
|
|
29
|
+
/* -----------------------------------------------------------
|
|
30
|
+
BASIC VALIDATORS
|
|
31
|
+
----------------------------------------------------------- */
|
|
32
|
+
/**
|
|
33
|
+
* Asserts a value type.
|
|
34
|
+
*
|
|
35
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
|
|
36
|
+
* reason, if the parametric value is not following the type `T`. Otherwise, the
|
|
37
|
+
* value is following the type `T`, just input parameter would be returned.
|
|
38
|
+
*
|
|
39
|
+
* If what you want is not asserting but just knowing whether the parametric value is
|
|
40
|
+
* following the type `T` or not, you can choose the {@link is} function instead.
|
|
41
|
+
* Otherwise you want to know all the errors, {@link validate} is the way to go.
|
|
42
|
+
*
|
|
43
|
+
* On the other and, if you don't want to allow any superfluous property that is not
|
|
44
|
+
* enrolled to the type `T`, you can use {@link assertEquals} function instead.
|
|
45
|
+
*
|
|
46
|
+
* @template T Type of the input value
|
|
47
|
+
* @param input A value to be asserted
|
|
48
|
+
* @returns Parametric input value
|
|
49
|
+
* @throws A {@link TypeGuardError} instance with detailed reason
|
|
50
|
+
*
|
|
51
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
52
|
+
*/
|
|
53
|
+
export function assert<T>(input: T): T;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Asserts a value type.
|
|
57
|
+
*
|
|
58
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
|
|
59
|
+
* reason, if the parametric value is not following the type `T`. Otherwise, the
|
|
60
|
+
* value is following the type `T`, just input parameter would be returned.
|
|
61
|
+
*
|
|
62
|
+
* If what you want is not asserting but just knowing whether the parametric value is
|
|
63
|
+
* following the type `T` or not, you can choose the {@link is} function instead.
|
|
64
|
+
* Otherwise, you want to know all the errors, {@link validate} is the way to go.
|
|
65
|
+
*
|
|
66
|
+
* On the other and, if you don't want to allow any superfluous property that is not
|
|
67
|
+
* enrolled to the type `T`, you can use {@link assertEquals} function instead.
|
|
68
|
+
*
|
|
69
|
+
* @template T Type of the input value
|
|
70
|
+
* @param input A value to be asserted
|
|
71
|
+
* @returns Parametric input value casted as `T`
|
|
72
|
+
* @throws A {@link TypeGuardError} instance with detailed reason
|
|
73
|
+
*
|
|
74
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
75
|
+
*/
|
|
76
|
+
export function assert<T>(input: unknown): T;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export function assert(): never {
|
|
82
|
+
halt("assert");
|
|
83
|
+
}
|
|
84
|
+
Object.assign(assert, Namespace.assert("assert"));
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Tests a value type.
|
|
88
|
+
*
|
|
89
|
+
* Tests a parametric value type and returns whether it's following the type `T` or not.
|
|
90
|
+
* If the parametric value is matched with the type `T`, `true` value would be returned.
|
|
91
|
+
* Otherwise, the parametric value is not following the type `T`, `false` value would be
|
|
92
|
+
* returned.
|
|
93
|
+
*
|
|
94
|
+
* If what you want is not just knowing whether the parametric value is following the
|
|
95
|
+
* type `T` or not, but throwing an exception with detailed reason, you can choose
|
|
96
|
+
* {@link assert} function instead. Also, if you want to know all the errors with
|
|
97
|
+
* detailed reasons, {@link validate} function would be useful.
|
|
98
|
+
*
|
|
99
|
+
* On the other and, if you don't want to allow any superfluous property that is not
|
|
100
|
+
* enrolled to the type `T`, you can use {@link equals} function instead.
|
|
101
|
+
*
|
|
102
|
+
* @template T Type of the input value
|
|
103
|
+
* @param input A value to be tested
|
|
104
|
+
* @returns Whether the parametric value is following the type `T` or not
|
|
105
|
+
*
|
|
106
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
107
|
+
*/
|
|
108
|
+
export function is<T>(input: T): input is T;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Tests a value type.
|
|
112
|
+
*
|
|
113
|
+
* Tests a parametric value type and returns whether it's following the type `T` or not.
|
|
114
|
+
* If the parametric value is matched with the type `T`, `true` value would be returned.
|
|
115
|
+
* Otherwise, the parametric value is not following the type `T`, `false` value would be
|
|
116
|
+
* returned.
|
|
117
|
+
*
|
|
118
|
+
* If what you want is not just knowing whether the parametric value is following the
|
|
119
|
+
* type `T` or not, but throwing an exception with detailed reason, you can choose
|
|
120
|
+
* {@link assert} function instead. Also, if you want to know all the errors with
|
|
121
|
+
* detailed reasons, {@link validate} function would be useful.
|
|
122
|
+
*
|
|
123
|
+
* On the other and, if you don't want to allow any superfluous property that is not
|
|
124
|
+
* enrolled to the type `T`, you can use {@link equals} function instead.
|
|
125
|
+
*
|
|
126
|
+
* @template T Type of the input value
|
|
127
|
+
* @param input A value to be tested
|
|
128
|
+
* @returns Whether the parametric value is following the type `T` or not
|
|
129
|
+
*
|
|
130
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
131
|
+
*/
|
|
132
|
+
export function is<T>(input: unknown): input is T;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
export function is(): never {
|
|
138
|
+
halt("is");
|
|
139
|
+
}
|
|
140
|
+
Object.assign(is, Namespace.assert("is"));
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Validates a value type.
|
|
144
|
+
*
|
|
145
|
+
* Validates a parametric value type and archives all the type errors into an
|
|
146
|
+
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
147
|
+
* type `T`. Of course, if the parametric value is following the type `T`, the
|
|
148
|
+
* {@link IValidation.errors} array would be empty and {@link IValidation.success}
|
|
149
|
+
* would have the `true` value.
|
|
150
|
+
*
|
|
151
|
+
* If what you want is not finding all the error, but asserting the parametric value
|
|
152
|
+
* type with exception throwing, you can choose {@link assert} function instead.
|
|
153
|
+
* Otherwise, you just want to know whether the parametric value is matched with the
|
|
154
|
+
* type `T`, {@link is} function is the way to go.
|
|
155
|
+
*
|
|
156
|
+
* On the other and, if you don't want to allow any superfluous property that is not
|
|
157
|
+
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
|
|
158
|
+
*
|
|
159
|
+
* @template Type of the input value
|
|
160
|
+
* @param input A value to be validated
|
|
161
|
+
* @returns Validation result
|
|
162
|
+
*
|
|
163
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
164
|
+
*/
|
|
165
|
+
export function validate<T>(input: T): IValidation<T>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Validates a value type.
|
|
169
|
+
*
|
|
170
|
+
* Validates a parametric value type and archives all the type errors into an
|
|
171
|
+
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
172
|
+
* type `T`. Of course, if the parametric value is following the type `T`, the
|
|
173
|
+
* {@link IValidation.errors} array would be empty and {@link IValidation.success}
|
|
174
|
+
* would have the `true` value.
|
|
175
|
+
*
|
|
176
|
+
* If what you want is not finding all the error, but asserting the parametric value
|
|
177
|
+
* type with exception throwing, you can choose {@link assert} function instead.
|
|
178
|
+
* Otherwise, you just want to know whether the parametric value is matched with the
|
|
179
|
+
* type `T`, {@link is} function is the way to go.
|
|
180
|
+
*
|
|
181
|
+
* On the other and, if you don't want to allow any superfluous property that is not
|
|
182
|
+
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
|
|
183
|
+
*
|
|
184
|
+
* @template Type of the input value
|
|
185
|
+
* @param input A value to be validated
|
|
186
|
+
* @returns Validation result
|
|
187
|
+
*
|
|
188
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
189
|
+
*/
|
|
190
|
+
export function validate<T>(input: unknown): IValidation<T>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
export function validate(): never {
|
|
196
|
+
halt("validate");
|
|
197
|
+
}
|
|
198
|
+
Object.assign(validate, Namespace.validate());
|
|
199
|
+
|
|
200
|
+
/* -----------------------------------------------------------
|
|
201
|
+
STRICT VALIDATORS
|
|
202
|
+
----------------------------------------------------------- */
|
|
203
|
+
/**
|
|
204
|
+
* Asserts equality between a value and its type.
|
|
205
|
+
*
|
|
206
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
|
|
207
|
+
* reason, if the parametric value is not following the type `T` or some superfluous
|
|
208
|
+
* property that is not listed on the type `T` has been found. Otherwise, the value is
|
|
209
|
+
* following the type `T` without any superfluous property, just input parameter would
|
|
210
|
+
* be returned.
|
|
211
|
+
*
|
|
212
|
+
* If what you want is not asserting but just knowing whether the parametric value is
|
|
213
|
+
* following the type `T` or not, you can choose the {@link equals} function instead.
|
|
214
|
+
* Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
|
|
215
|
+
*
|
|
216
|
+
* On the other hand, if you want to allow superfluous property that is not enrolled
|
|
217
|
+
* to the type `T`, you can use {@link assert} function instead.
|
|
218
|
+
*
|
|
219
|
+
* @template T Type of the input value
|
|
220
|
+
* @param input A value to be asserted
|
|
221
|
+
* @returns Parametric input value
|
|
222
|
+
* @throws A {@link TypeGuardError} instance with detailed reason
|
|
223
|
+
*
|
|
224
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
225
|
+
*/
|
|
226
|
+
export function assertEquals<T>(input: T): T;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Asserts equality between a value and its type.
|
|
230
|
+
*
|
|
231
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
|
|
232
|
+
* reason, if the parametric value is not following the type `T` or some superfluous
|
|
233
|
+
* property that is not listed on the type `T` has been found. Otherwise, the value is
|
|
234
|
+
* following the type `T` without any superfluous property, just input parameter would
|
|
235
|
+
* be returned.
|
|
236
|
+
*
|
|
237
|
+
* If what you want is not asserting but just knowing whether the parametric value is
|
|
238
|
+
* following the type `T` or not, you can choose the {@link equals} function instead.
|
|
239
|
+
* Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
|
|
240
|
+
*
|
|
241
|
+
* On the other hand, if you want to allow superfluous property that is not enrolled
|
|
242
|
+
* to the type `T`, you can use {@link assert} function instead.
|
|
243
|
+
*
|
|
244
|
+
* @template T Type of the input value
|
|
245
|
+
* @param input A value to be asserted
|
|
246
|
+
* @returns Parametric input value casted as `T`
|
|
247
|
+
* @throws A {@link TypeGuardError} instance with detailed reason
|
|
248
|
+
*
|
|
249
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
250
|
+
*/
|
|
251
|
+
export function assertEquals<T>(input: unknown): T;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @internal
|
|
255
|
+
*/
|
|
256
|
+
export function assertEquals(): never {
|
|
257
|
+
halt("assertEquals");
|
|
258
|
+
}
|
|
259
|
+
Object.assign(assertEquals, Namespace.assert("assertEquals"));
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Tests equality between a value and its type.
|
|
263
|
+
*
|
|
264
|
+
* Tests a parametric value type and returns whether it's equivalent to the type `T`
|
|
265
|
+
* or not. If the parametric value is matched with the type `T` and there's not any
|
|
266
|
+
* superfluous property that is not listed on the type `T`, `true` value would be
|
|
267
|
+
* returned. Otherwise, the parametric value is not following the type `T` or some
|
|
268
|
+
* superfluous property exists, `false` value would be returned.
|
|
269
|
+
*
|
|
270
|
+
* If what you want is not just knowing whether the parametric value is following the
|
|
271
|
+
* type `T` or not, but throwing an exception with detailed reason, you can choose
|
|
272
|
+
* {@link assertEquals} function instead. Also, if you want to know all the errors with
|
|
273
|
+
* detailed reasons, {@link validateEquals} function would be useful.
|
|
274
|
+
*
|
|
275
|
+
* On the other hand, if you want to allow superfluous property that is not enrolled
|
|
276
|
+
* to the type `T`, you can use {@link is} function instead.
|
|
277
|
+
*
|
|
278
|
+
* @template T Type of the input value
|
|
279
|
+
* @param input A value to be tested
|
|
280
|
+
* @returns Whether the parametric value is equivalent to the type `T` or not
|
|
281
|
+
*
|
|
282
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
283
|
+
*/
|
|
284
|
+
export function equals<T>(input: T): input is T;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Tests equality between a value and its type.
|
|
288
|
+
*
|
|
289
|
+
* Tests a parametric value type and returns whether it's equivalent to the type `T`
|
|
290
|
+
* or not. If the parametric value is matched with the type `T` and there's not any
|
|
291
|
+
* superfluous property that is not listed on the type `T`, `true` value would be
|
|
292
|
+
* returned. Otherwise, the parametric value is not following the type `T` or some
|
|
293
|
+
* superfluous property exists, `false` value would be returned.
|
|
294
|
+
*
|
|
295
|
+
* If what you want is not just knowing whether the parametric value is following the
|
|
296
|
+
* type `T` or not, but throwing an exception with detailed reason, you can choose
|
|
297
|
+
* {@link assertEquals} function instead. Also, if you want to know all the errors with
|
|
298
|
+
* detailed reasons, {@link validateEquals} function would be useful.
|
|
299
|
+
*
|
|
300
|
+
* On the other hand, if you want to allow superfluous property that is not enrolled
|
|
301
|
+
* to the type `T`, you can use {@link is} function instead.
|
|
302
|
+
*
|
|
303
|
+
* @template T Type of the input value
|
|
304
|
+
* @param input A value to be tested
|
|
305
|
+
* @returns Whether the parametric value is equivalent to the type `T` or not
|
|
306
|
+
*
|
|
307
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
308
|
+
*/
|
|
309
|
+
export function equals<T>(input: unknown): input is T;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @internal
|
|
313
|
+
*/
|
|
314
|
+
export function equals(): never {
|
|
315
|
+
halt("equals");
|
|
316
|
+
}
|
|
317
|
+
Object.assign(equals, Namespace.is());
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Validates equality between a value and its type.
|
|
321
|
+
*
|
|
322
|
+
* Validates a parametric value type and archives all the type errors into an
|
|
323
|
+
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
324
|
+
* type `T` or some superfluous property that is not listed on the type `T` has been
|
|
325
|
+
* found. Of course, if the parametric value is following the type `T` and no
|
|
326
|
+
* superfluous property exists, the {@link IValidation.errors} array would be empty
|
|
327
|
+
* and {@link IValidation.success} would have the `true` value.
|
|
328
|
+
*
|
|
329
|
+
* If what you want is not finding all the error, but asserting the parametric value
|
|
330
|
+
* type with exception throwing, you can choose {@link assert} function instead.
|
|
331
|
+
* Otherwise, you just want to know whether the parametric value is matched with the
|
|
332
|
+
* type `T`, {@link is} function is the way to go.
|
|
333
|
+
*
|
|
334
|
+
* On the other and, if you don't want to allow any superfluous property that is not
|
|
335
|
+
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
|
|
336
|
+
*
|
|
337
|
+
* @template Type of the input value
|
|
338
|
+
* @param input A value to be validated
|
|
339
|
+
* @returns Validation result
|
|
340
|
+
*
|
|
341
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
342
|
+
*/
|
|
343
|
+
export function validateEquals<T>(input: T): IValidation<T>;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Validates equality between a value and its type.
|
|
347
|
+
*
|
|
348
|
+
* Validates a parametric value type and archives all the type errors into an
|
|
349
|
+
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
350
|
+
* type `T` or some superfluous property that is not listed on the type `T` has been
|
|
351
|
+
* found. Of course, if the parametric value is following the type `T` and no
|
|
352
|
+
* superfluous property exists, the {@link IValidation.errors} array would be empty
|
|
353
|
+
* and {@link IValidation.success} would have the `true` value.
|
|
354
|
+
*
|
|
355
|
+
* If what you want is not finding all the error, but asserting the parametric value
|
|
356
|
+
* type with exception throwing, you can choose {@link assert} function instead.
|
|
357
|
+
* Otherwise, you just want to know whether the parametric value is matched with the
|
|
358
|
+
* type `T`, {@link is} function is the way to go.
|
|
359
|
+
*
|
|
360
|
+
* On the other and, if you don't want to allow any superfluous property that is not
|
|
361
|
+
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
|
|
362
|
+
*
|
|
363
|
+
* @template Type of the input value
|
|
364
|
+
* @param input A value to be validated
|
|
365
|
+
* @returns Validation result
|
|
366
|
+
*
|
|
367
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
368
|
+
*/
|
|
369
|
+
export function validateEquals<T>(input: unknown): IValidation<T>;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @internal
|
|
373
|
+
*/
|
|
374
|
+
export function validateEquals(): never {
|
|
375
|
+
halt("validateEquals");
|
|
376
|
+
}
|
|
377
|
+
Object.assign(validateEquals, Namespace.validate());
|
|
378
|
+
|
|
379
|
+
/* -----------------------------------------------------------
|
|
380
|
+
RANDOM
|
|
381
|
+
----------------------------------------------------------- */
|
|
382
|
+
/**
|
|
383
|
+
* > You must configure the generic argument `T`.
|
|
384
|
+
*
|
|
385
|
+
* Generate random data.
|
|
386
|
+
*
|
|
387
|
+
* Generates a random data following type the `T`.
|
|
388
|
+
*
|
|
389
|
+
* For reference, this `typia.random()` function generates only primitive type.
|
|
390
|
+
* If there're some methods in the type `T` or its nested instances, those would
|
|
391
|
+
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
392
|
+
* would be generated instead.
|
|
393
|
+
*
|
|
394
|
+
* @template T Type of data to generate
|
|
395
|
+
* @param generator Random data generator
|
|
396
|
+
* @return Randomly generated data
|
|
397
|
+
*
|
|
398
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
399
|
+
*/
|
|
400
|
+
export function random(generator?: Partial<IRandomGenerator>): never;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Generate random data.
|
|
404
|
+
*
|
|
405
|
+
* Generates a random data following type the `T`.
|
|
406
|
+
*
|
|
407
|
+
* For reference, this `typia.random()` function generates only primitive type.
|
|
408
|
+
* If there're some methods in the type `T` or its nested instances, those would
|
|
409
|
+
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
410
|
+
* would be generated instead.
|
|
411
|
+
*
|
|
412
|
+
* @template T Type of data to generate
|
|
413
|
+
* @param generator Random data generator
|
|
414
|
+
* @return Randomly generated data
|
|
415
|
+
*
|
|
416
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
417
|
+
*/
|
|
418
|
+
export function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @internal
|
|
422
|
+
*/
|
|
423
|
+
export function random(): never {
|
|
424
|
+
halt("random");
|
|
425
|
+
}
|
|
426
|
+
Object.assign(random, Namespace.random());
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* @internal
|
|
430
|
+
*/
|
|
431
|
+
export function metadata(): never;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* @internal
|
|
435
|
+
*/
|
|
436
|
+
export function metadata<Types extends unknown[]>(): IMetadataApplication;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* @internal
|
|
440
|
+
*/
|
|
441
|
+
export function metadata(): never {
|
|
442
|
+
halt("metadata");
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/* -----------------------------------------------------------
|
|
446
|
+
FACTORY FUNCTIONS
|
|
447
|
+
----------------------------------------------------------- */
|
|
448
|
+
/**
|
|
449
|
+
* Creates a reusable {@link assert} function.
|
|
450
|
+
*
|
|
451
|
+
* @danger You must configure the generic argument `T`
|
|
452
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
453
|
+
* @throws compile error
|
|
454
|
+
*
|
|
455
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
456
|
+
*/
|
|
457
|
+
export function createAssert(): never;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Creates a reusable {@link assert} function.
|
|
461
|
+
*
|
|
462
|
+
* @template T Type of the input value
|
|
463
|
+
* @returns A reusable `assert` function
|
|
464
|
+
*
|
|
465
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
466
|
+
*/
|
|
467
|
+
export function createAssert<T>(): (input: unknown) => T;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @internal
|
|
471
|
+
*/
|
|
472
|
+
export function createAssert<T>(): (input: unknown) => T {
|
|
473
|
+
halt("createAssert");
|
|
474
|
+
}
|
|
475
|
+
Object.assign(createAssert, assert);
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Creates a reusable {@link is} function.
|
|
479
|
+
*
|
|
480
|
+
* @danger You must configure the generic argument `T`
|
|
481
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
482
|
+
* @throws compile error
|
|
483
|
+
*
|
|
484
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
485
|
+
*/
|
|
486
|
+
export function createIs(): never;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Creates a reusable {@link is} function.
|
|
490
|
+
*
|
|
491
|
+
* @template T Type of the input value
|
|
492
|
+
* @returns A reusable `is` function
|
|
493
|
+
*
|
|
494
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
495
|
+
*/
|
|
496
|
+
export function createIs<T>(): (input: unknown) => input is T;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @internal
|
|
500
|
+
*/
|
|
501
|
+
export function createIs<T>(): (input: unknown) => input is T {
|
|
502
|
+
halt("createIs");
|
|
503
|
+
}
|
|
504
|
+
Object.assign(createIs, is);
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Creates a reusable {@link validate} function.
|
|
508
|
+
*
|
|
509
|
+
* @danger You must configure the generic argument `T`
|
|
510
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
511
|
+
* @throws compile error
|
|
512
|
+
*
|
|
513
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
514
|
+
*/
|
|
515
|
+
export function createValidate(): never;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Creates a reusable {@link validate} function.
|
|
519
|
+
*
|
|
520
|
+
* @template T Type of the input value
|
|
521
|
+
* @returns A reusable `validate` function
|
|
522
|
+
*
|
|
523
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
524
|
+
*/
|
|
525
|
+
export function createValidate<T>(): (input: unknown) => IValidation<T>;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* @internal
|
|
529
|
+
*/
|
|
530
|
+
export function createValidate(): (input: unknown) => IValidation {
|
|
531
|
+
halt("createValidate");
|
|
532
|
+
}
|
|
533
|
+
Object.assign(createValidate, validate);
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Creates a reusable {@link assertEquals} function.
|
|
537
|
+
*
|
|
538
|
+
* @danger You must configure the generic argument `T`
|
|
539
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
540
|
+
* @throws compile error
|
|
541
|
+
*
|
|
542
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
543
|
+
*/
|
|
544
|
+
export function createAssertEquals(): never;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Creates a reusable {@link assertEquals} function.
|
|
548
|
+
*
|
|
549
|
+
* @template T Type of the input value
|
|
550
|
+
* @returns A reusable `assertEquals` function
|
|
551
|
+
*
|
|
552
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
553
|
+
*/
|
|
554
|
+
export function createAssertEquals<T>(): (input: unknown) => T;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* @internal
|
|
558
|
+
*/
|
|
559
|
+
export function createAssertEquals<T>(): (input: unknown) => T {
|
|
560
|
+
halt("createAssertEquals");
|
|
561
|
+
}
|
|
562
|
+
Object.assign(createAssertEquals, assertEquals);
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Creates a reusable {@link equals} function.
|
|
566
|
+
*
|
|
567
|
+
* @danger You must configure the generic argument `T`
|
|
568
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
569
|
+
* @throws compile error
|
|
570
|
+
*
|
|
571
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
572
|
+
*/
|
|
573
|
+
export function createEquals(): never;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Creates a reusable {@link equals} function.
|
|
577
|
+
*
|
|
578
|
+
* @template T Type of the input value
|
|
579
|
+
* @returns A reusable `equals` function
|
|
580
|
+
*
|
|
581
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
582
|
+
*/
|
|
583
|
+
export function createEquals<T>(): (input: unknown) => input is T;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* @internal
|
|
587
|
+
*/
|
|
588
|
+
export function createEquals<T>(): (input: unknown) => input is T {
|
|
589
|
+
halt("createEquals");
|
|
590
|
+
}
|
|
591
|
+
Object.assign(createEquals, equals);
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Creates a reusable {@link validateEquals} function.
|
|
595
|
+
*
|
|
596
|
+
* @danger You must configure the generic argument `T`
|
|
597
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
598
|
+
* @throws compile error
|
|
599
|
+
*
|
|
600
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
601
|
+
*/
|
|
602
|
+
export function createValidateEquals(): never;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Creates a reusable {@link validateEquals} function.
|
|
606
|
+
*
|
|
607
|
+
* @template T Type of the input value
|
|
608
|
+
* @returns A reusable `validateEquals` function
|
|
609
|
+
*
|
|
610
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
611
|
+
*/
|
|
612
|
+
export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* @internal
|
|
616
|
+
*/
|
|
617
|
+
export function createValidateEquals(): (input: unknown) => IValidation {
|
|
618
|
+
halt("createValidateEquals");
|
|
619
|
+
}
|
|
620
|
+
Object.assign(createValidateEquals, validateEquals);
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Creates a reusable {@link random} function.
|
|
624
|
+
*
|
|
625
|
+
* @danger You must configure the generic argument `T`
|
|
626
|
+
* @param generator Random data generator
|
|
627
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
628
|
+
* @throws compile error
|
|
629
|
+
*
|
|
630
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
631
|
+
*/
|
|
632
|
+
export function createRandom(generator?: Partial<IRandomGenerator>): never;
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Creates a resuable {@link random} function.
|
|
636
|
+
*
|
|
637
|
+
* @template T Type of the input value
|
|
638
|
+
* @param generator Random data generator
|
|
639
|
+
* @returns A reusable `random` function
|
|
640
|
+
*
|
|
641
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
642
|
+
*/
|
|
643
|
+
export function createRandom<T>(
|
|
644
|
+
generator?: Partial<IRandomGenerator>,
|
|
645
|
+
): () => Resolved<T>;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* @internal
|
|
649
|
+
*/
|
|
650
|
+
export function createRandom(): never {
|
|
651
|
+
halt("createRandom");
|
|
652
|
+
}
|
|
653
|
+
Object.assign(createRandom, random);
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* @internal
|
|
657
|
+
*/
|
|
658
|
+
function halt(name: string): never {
|
|
659
|
+
throw new Error(
|
|
660
|
+
`Error on typia.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
|
|
661
|
+
);
|
|
662
|
+
}
|