typia 9.7.2 → 10.0.0-dev.20251107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +153 -153
- package/lib/factories/ProtobufFactory.js +1 -1
- package/lib/factories/ProtobufFactory.mjs +1 -1
- package/lib/programmers/internal/json_schema_station.d.mts +2 -2
- package/lib/programmers/internal/json_schema_station.d.ts +2 -2
- package/lib/programmers/llm/LlmApplicationProgrammer.js +5 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.mjs +5 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -4
- package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.mjs +1 -35
- package/package.json +121 -121
- package/src/AssertionGuard.ts +41 -41
- package/src/CamelCase.ts +75 -75
- package/src/IRandomGenerator.ts +337 -337
- package/src/IReadableURLSearchParams.ts +9 -9
- package/src/PascalCase.ts +71 -71
- package/src/Primitive.ts +90 -90
- package/src/Resolved.ts +72 -72
- package/src/SnakeCase.ts +127 -127
- package/src/TypeGuardError.ts +216 -216
- package/src/factories/MetadataCollection.ts +270 -270
- package/src/factories/MetadataCommentTagFactory.ts +632 -632
- package/src/factories/MetadataFactory.ts +402 -402
- package/src/factories/ProtobufFactory.ts +873 -873
- package/src/functional.ts +705 -705
- package/src/http.ts +972 -972
- package/src/internal/_ProtobufReader.ts +188 -188
- package/src/internal/_ProtobufSizer.ts +137 -137
- package/src/internal/_ProtobufWriter.ts +135 -135
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/json.ts +643 -643
- package/src/llm.ts +615 -615
- package/src/misc.ts +594 -594
- package/src/module.ts +889 -889
- package/src/notations.ts +751 -751
- package/src/programmers/FeatureProgrammer.ts +605 -605
- package/src/programmers/ImportProgrammer.ts +179 -179
- package/src/programmers/RandomProgrammer.ts +1195 -1195
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/internal/check_array_length.ts +43 -43
- package/src/programmers/internal/check_bigint.ts +46 -46
- package/src/programmers/internal/check_dynamic_key.ts +197 -197
- package/src/programmers/internal/check_dynamic_properties.ts +231 -231
- package/src/programmers/internal/check_everything.ts +21 -21
- package/src/programmers/internal/check_native.ts +23 -23
- package/src/programmers/internal/check_number.ts +108 -108
- package/src/programmers/internal/check_object.ts +72 -72
- package/src/programmers/internal/check_string.ts +46 -46
- package/src/programmers/internal/check_template.ts +46 -46
- package/src/programmers/internal/check_union_array_like.ts +331 -331
- package/src/programmers/internal/decode_union_object.ts +110 -110
- package/src/programmers/internal/feature_object_entries.ts +59 -59
- package/src/programmers/internal/json_schema_escaped.ts +78 -78
- package/src/programmers/internal/json_schema_object.ts +150 -150
- package/src/programmers/internal/json_schema_station.ts +2 -2
- package/src/programmers/internal/metadata_to_pattern.ts +40 -40
- package/src/programmers/internal/postfix_of_tuple.ts +3 -3
- package/src/programmers/internal/prune_object_properties.ts +69 -69
- package/src/programmers/internal/stringify_dynamic_properties.ts +158 -158
- package/src/programmers/internal/stringify_native.ts +5 -5
- package/src/programmers/internal/stringify_regular_properties.ts +77 -77
- package/src/programmers/internal/template_to_pattern.ts +21 -21
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +21 -21
- package/src/programmers/json/JsonStringifyProgrammer.ts +1124 -1124
- package/src/programmers/llm/LlmApplicationProgrammer.ts +10 -1
- package/src/programmers/llm/LlmSchemaProgrammer.ts +2 -7
- package/src/protobuf.ts +820 -820
- package/src/reflect.ts +46 -46
- package/src/schemas/json/IJsonApplication.ts +77 -77
- package/src/schemas/json/IJsonSchemaCollection.ts +212 -212
- package/src/schemas/json/IJsonSchemaUnit.ts +263 -263
- package/src/schemas/metadata/IMetadataTypeTag.ts +14 -14
- package/src/schemas/metadata/Metadata.ts +669 -669
- package/src/schemas/metadata/MetadataAliasType.ts +57 -57
- package/src/schemas/metadata/MetadataApplication.ts +40 -40
- package/src/schemas/metadata/MetadataArray.ts +47 -47
- package/src/schemas/metadata/MetadataArrayType.ts +51 -51
- package/src/schemas/metadata/MetadataAtomic.ts +85 -85
- package/src/schemas/metadata/MetadataEscaped.ts +45 -45
- package/src/schemas/metadata/MetadataFunction.ts +45 -45
- package/src/schemas/metadata/MetadataObject.ts +46 -46
- package/src/schemas/metadata/MetadataObjectType.ts +137 -137
- package/src/schemas/metadata/MetadataParameter.ts +52 -52
- package/src/schemas/metadata/MetadataProperty.ts +53 -53
- package/src/schemas/metadata/MetadataTemplate.ts +78 -78
- package/src/schemas/metadata/MetadataTuple.ts +28 -28
- package/src/schemas/metadata/MetadataTupleType.ts +61 -61
- package/src/tags/Constant.ts +47 -47
- package/src/tags/ContentMediaType.ts +27 -27
- package/src/tags/Default.ts +52 -52
- package/src/tags/Example.ts +56 -56
- package/src/tags/Examples.ts +56 -56
- package/src/tags/ExclusiveMaximum.ts +44 -44
- package/src/tags/ExclusiveMinimum.ts +44 -44
- package/src/tags/Format.ts +78 -78
- package/src/tags/JsonSchemaPlugin.ts +36 -36
- package/src/tags/MaxItems.ts +31 -31
- package/src/tags/MaxLength.ts +25 -25
- package/src/tags/Maximum.ts +39 -39
- package/src/tags/MinItems.ts +31 -31
- package/src/tags/MinLength.ts +25 -25
- package/src/tags/Minimum.ts +39 -39
- package/src/tags/MultipleOf.ts +42 -42
- package/src/tags/Pattern.ts +49 -49
- package/src/tags/Sequence.ts +37 -37
- package/src/tags/TagBase.ts +102 -102
- package/src/tags/Type.ts +64 -64
- package/src/tags/UniqueItems.ts +34 -34
- package/src/tags/internal/FormatCheatSheet.ts +71 -71
- package/src/transformers/ITransformOptions.ts +70 -70
- package/src/transformers/ImportTransformer.ts +253 -253
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +224 -224
- package/src/typings/Equal.ts +18 -18
package/src/json.ts
CHANGED
|
@@ -1,643 +1,643 @@
|
|
|
1
|
-
import { IJsonSchemaCollection } from "./schemas/json/IJsonSchemaCollection";
|
|
2
|
-
import { IJsonSchemaUnit } from "./schemas/json/IJsonSchemaUnit";
|
|
3
|
-
|
|
4
|
-
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
|
|
5
|
-
|
|
6
|
-
import { IValidation } from "./IValidation";
|
|
7
|
-
import { Primitive } from "./Primitive";
|
|
8
|
-
import { TypeGuardError } from "./TypeGuardError";
|
|
9
|
-
|
|
10
|
-
/* ===========================================================
|
|
11
|
-
JSON
|
|
12
|
-
- METADATA
|
|
13
|
-
- PARSE
|
|
14
|
-
- STRINGIFY
|
|
15
|
-
- FACTORY FUNCTIONS
|
|
16
|
-
==============================================================
|
|
17
|
-
METADATA
|
|
18
|
-
----------------------------------------------------------- */
|
|
19
|
-
/**
|
|
20
|
-
* > You must configure the generic argument `Types`.
|
|
21
|
-
*
|
|
22
|
-
* JSON Schemas Generator.
|
|
23
|
-
*
|
|
24
|
-
* Creates a JSON schema list which contains both main JSON schemas and
|
|
25
|
-
* components. Note that, all of the named types are stored in the
|
|
26
|
-
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
|
|
27
|
-
*
|
|
28
|
-
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
29
|
-
* argument `Version`. For reference, the default version is `"3.1"`, and the
|
|
30
|
-
* key difference between `"3.0"` and `"3.1"` is whether supporting the tuple
|
|
31
|
-
* type or not.
|
|
32
|
-
*
|
|
33
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
-
* @template Types Tuple of target types
|
|
35
|
-
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
36
|
-
* @returns JSON schema collection
|
|
37
|
-
*/
|
|
38
|
-
export function schemas(): never;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* JSON Schemas Generator.
|
|
42
|
-
*
|
|
43
|
-
* Creates a JSON schema list which contains both main JSON schemas and
|
|
44
|
-
* components. Note that, all of the named types are stored in the
|
|
45
|
-
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
|
|
46
|
-
*
|
|
47
|
-
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
48
|
-
* argument `Version`. For reference, the default version is `"3.1"`, and the
|
|
49
|
-
* key difference between `"3.0"` and `"3.1"` is whether supporting the tuple
|
|
50
|
-
* type or not.
|
|
51
|
-
*
|
|
52
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
53
|
-
* @template Types Tuple of target types
|
|
54
|
-
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
55
|
-
* @returns JSON schema collection
|
|
56
|
-
*/
|
|
57
|
-
export function schemas<
|
|
58
|
-
Types extends unknown[],
|
|
59
|
-
Version extends "3.0" | "3.1" = "3.1",
|
|
60
|
-
>(): IJsonSchemaCollection<Version, Types>;
|
|
61
|
-
|
|
62
|
-
/** @internal */
|
|
63
|
-
export function schemas(): never {
|
|
64
|
-
NoTransformConfigurationError("json.schemas");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* > You must configure the generic argument `Type`.
|
|
69
|
-
*
|
|
70
|
-
* JSON schema generator.
|
|
71
|
-
*
|
|
72
|
-
* Creates a JSON schema unit which contains a main JSON schema and its
|
|
73
|
-
* components. Note that, all of the named types are stored in the
|
|
74
|
-
* {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
|
|
75
|
-
*
|
|
76
|
-
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
77
|
-
* argument `Version`. For reference, the default version is `"3.1"`, and key
|
|
78
|
-
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or
|
|
79
|
-
* not.
|
|
80
|
-
*
|
|
81
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
82
|
-
* @template Type Target type
|
|
83
|
-
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
84
|
-
* @returns JSON schema unit
|
|
85
|
-
*/
|
|
86
|
-
export function schema(): never;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* JSON schema generator.
|
|
90
|
-
*
|
|
91
|
-
* Creates a JSON schema unit which contains a main JSON schema and its
|
|
92
|
-
* components. Note that, all of the named types are stored in the
|
|
93
|
-
* {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
|
|
94
|
-
*
|
|
95
|
-
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
96
|
-
* argument `Version`. For reference, the default version is `"3.1"`, and key
|
|
97
|
-
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or
|
|
98
|
-
* not.
|
|
99
|
-
*
|
|
100
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
101
|
-
* @template Type Target type
|
|
102
|
-
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
103
|
-
* @returns JSON schema unit
|
|
104
|
-
*/
|
|
105
|
-
export function schema<
|
|
106
|
-
Type extends unknown,
|
|
107
|
-
Version extends "3.0" | "3.1" = "3.1",
|
|
108
|
-
>(): IJsonSchemaUnit<Version, Type>;
|
|
109
|
-
|
|
110
|
-
/** @internal */
|
|
111
|
-
export function schema(): never {
|
|
112
|
-
NoTransformConfigurationError("json.schema");
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/* -----------------------------------------------------------
|
|
116
|
-
PARSE
|
|
117
|
-
----------------------------------------------------------- */
|
|
118
|
-
/**
|
|
119
|
-
* > You must configure the generic argument `T`.
|
|
120
|
-
*
|
|
121
|
-
* Safe `JSON.parse()` function with type assertion.
|
|
122
|
-
*
|
|
123
|
-
* `typia.json.assertParse()` is a combination function of `JSON.parse()` and
|
|
124
|
-
* {@link assert}. Therefore, it converts a JSON (JavaScript Object Notation)
|
|
125
|
-
* string to a `T` typed instance with type assertion.
|
|
126
|
-
*
|
|
127
|
-
* In such reason, when parsed JSON string value is not matched with the type
|
|
128
|
-
* `T`, it throws {@link TypeGuardError} or custom error generated by
|
|
129
|
-
* _errorFactory_. Otherwise, if there's no problem with the parsed value, the
|
|
130
|
-
* parsed value will be returned.
|
|
131
|
-
*
|
|
132
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
133
|
-
* @template T Expected type of parsed value
|
|
134
|
-
* @param input JSON string
|
|
135
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
136
|
-
* @returns Parsed value
|
|
137
|
-
*/
|
|
138
|
-
export function assertParse(
|
|
139
|
-
input: string,
|
|
140
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
141
|
-
): never;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Safe `JSON.parse()` function with type assertion.
|
|
145
|
-
*
|
|
146
|
-
* `typia.json.assertParse()` is a combination function of `JSON.parse()` and
|
|
147
|
-
* {@link assert}. Therefore, it converts a JSON (JavaScript Object Notation)
|
|
148
|
-
* string to a `T` typed instance with type assertion.
|
|
149
|
-
*
|
|
150
|
-
* In such reason, when parsed JSON string value is not matched with the type
|
|
151
|
-
* `T`, it throws {@link TypeGuardError} or custom error generated by
|
|
152
|
-
* _errorFactory_. Otherwise, there's no problem on the parsed value, the parsed
|
|
153
|
-
* value would be returned.
|
|
154
|
-
*
|
|
155
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
156
|
-
* @template T Expected type of parsed value
|
|
157
|
-
* @param input JSON string
|
|
158
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
159
|
-
* @returns Parsed value
|
|
160
|
-
*/
|
|
161
|
-
export function assertParse<T>(
|
|
162
|
-
input: string,
|
|
163
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
164
|
-
): Primitive<T>;
|
|
165
|
-
|
|
166
|
-
/** @internal */
|
|
167
|
-
export function assertParse<T>(): Primitive<T> {
|
|
168
|
-
NoTransformConfigurationError("json.assertParse");
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* > You must configure the generic argument `T`.
|
|
173
|
-
*
|
|
174
|
-
* Safe `JSON.parse()` function with type checking.
|
|
175
|
-
*
|
|
176
|
-
* `typia.json.isParse()` is a combination function of `JSON.parse()` and
|
|
177
|
-
* {@link is}. Therefore, it converts a JSON (JavaScript Object Notation) string
|
|
178
|
-
* to a `T` typed instance with type checking.
|
|
179
|
-
*
|
|
180
|
-
* In such reason, when parsed JSON string value is not matched with the type
|
|
181
|
-
* `T`, it returns `null` value. Otherwise, there's no problem on the parsed
|
|
182
|
-
* value, the parsed value will be returned.
|
|
183
|
-
*
|
|
184
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
185
|
-
* @template T Expected type of parsed value
|
|
186
|
-
* @param input JSON string
|
|
187
|
-
* @returns Parsed value when exact type, otherwise `null`
|
|
188
|
-
*/
|
|
189
|
-
export function isParse(input: string): never;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Safe `JSON.parse()` function with type checking.
|
|
193
|
-
*
|
|
194
|
-
* `typia.json.isParse()` is a combination function of `JSON.parse()` and
|
|
195
|
-
* {@link is}. Therefore, it converts a JSON (JavaScript Object Notation) string
|
|
196
|
-
* to a `T` typed instance with type checking.
|
|
197
|
-
*
|
|
198
|
-
* In such reason, when parsed JSON string value is not matched with the type
|
|
199
|
-
* `T`, it returns `null` value. Otherwise, there's no problem on the parsed
|
|
200
|
-
* value, the parsed value will be returned.
|
|
201
|
-
*
|
|
202
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
203
|
-
* @template T Expected type of parsed value
|
|
204
|
-
* @param input JSON string
|
|
205
|
-
* @returns Parsed value when exact type, otherwise `null`
|
|
206
|
-
*/
|
|
207
|
-
export function isParse<T>(input: string): Primitive<T> | null;
|
|
208
|
-
|
|
209
|
-
/** @internal */
|
|
210
|
-
export function isParse<T>(): Primitive<T> | null {
|
|
211
|
-
NoTransformConfigurationError("json.isParse");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* > You must configure the generic argument `T`.
|
|
216
|
-
*
|
|
217
|
-
* Safe `JSON.parse()` function with detailed type validation.
|
|
218
|
-
*
|
|
219
|
-
* `typia.json.validateParse()` is a combination function of `JSON.parse()` and
|
|
220
|
-
* {@link validate}. Therefore, it converts a JSON (JavaScript Object Notation)
|
|
221
|
-
* string to a `T` typed instance with detailed type validation.
|
|
222
|
-
*
|
|
223
|
-
* In such reason, when parsed JSON string value is not matched with the type
|
|
224
|
-
* `T`, it returns {@link IValidation.IFailure} value with detailed error
|
|
225
|
-
* reasons. Otherwise, there's no problem on the parsed value, the parsed value
|
|
226
|
-
* will be stored in `data` property of the output {@link IValidation.ISuccess}
|
|
227
|
-
* instance.
|
|
228
|
-
*
|
|
229
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
230
|
-
* @template T Expected type of parsed value
|
|
231
|
-
* @param input JSON string
|
|
232
|
-
* @returns Validation result with JSON parsed value
|
|
233
|
-
*/
|
|
234
|
-
export function validateParse(input: string): never;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Safe `JSON.parse()` function with detailed type validation.
|
|
238
|
-
*
|
|
239
|
-
* `typia.json.validateParse()` is a combination function of `JSON.parse()` and
|
|
240
|
-
* {@link validate}. Therefore, it converts a JSON (JavaScript Object Notation)
|
|
241
|
-
* string to a `T` typed instance with detailed type validation.
|
|
242
|
-
*
|
|
243
|
-
* In such reason, when parsed JSON string value is not matched with the type
|
|
244
|
-
* `T`, it returns {@link IValidation.IFailure} value with detailed error
|
|
245
|
-
* reasons. Otherwise, there's no problem on the parsed value, the parsed value
|
|
246
|
-
* will be stored in `data` property of the output {@link IValidation.ISuccess}
|
|
247
|
-
* instance.
|
|
248
|
-
*
|
|
249
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
250
|
-
* @template T Expected type of parsed value
|
|
251
|
-
* @param input JSON string
|
|
252
|
-
* @returns Validation result with JSON parsed value
|
|
253
|
-
*/
|
|
254
|
-
export function validateParse<T>(input: string): IValidation<Primitive<T>>;
|
|
255
|
-
|
|
256
|
-
/** @internal */
|
|
257
|
-
export function validateParse<T>(): IValidation<Primitive<T>> {
|
|
258
|
-
NoTransformConfigurationError("json.validateParse");
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/* -----------------------------------------------------------
|
|
262
|
-
STRINGIFY
|
|
263
|
-
----------------------------------------------------------- */
|
|
264
|
-
/**
|
|
265
|
-
* 8x faster `JSON.stringify()` function.
|
|
266
|
-
*
|
|
267
|
-
* Converts an input value to a JSON (JavaScript Object Notation) string, about
|
|
268
|
-
* 8x faster than the native `JSON.stringify()` function. The 5x faster
|
|
269
|
-
* principle is because it writes an optimized JSON conversion plan, only for
|
|
270
|
-
* the type `T`.
|
|
271
|
-
*
|
|
272
|
-
* For reference, this `typia.json.stringify()` does not validate the input
|
|
273
|
-
* value type. It just believes that the input value is following the type `T`.
|
|
274
|
-
* Therefore, if you can't ensure the input value type, it will be better to
|
|
275
|
-
* call one of below functions instead.
|
|
276
|
-
*
|
|
277
|
-
* - {@link assertStringify}
|
|
278
|
-
* - {@link isStringify}
|
|
279
|
-
* - {@link validateStringify}
|
|
280
|
-
*
|
|
281
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
282
|
-
* @template T Type of the input value
|
|
283
|
-
* @param input A value to be converted
|
|
284
|
-
* @returns JSON string value
|
|
285
|
-
*/
|
|
286
|
-
export function stringify<T>(input: T): string;
|
|
287
|
-
|
|
288
|
-
/** @internal */
|
|
289
|
-
export function stringify(): never {
|
|
290
|
-
NoTransformConfigurationError("json.stringify");
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* 5x faster `JSON.stringify()` function with type assertion.
|
|
295
|
-
*
|
|
296
|
-
* `typia.json.assertStringify()` is a combination function of {@link assert} and
|
|
297
|
-
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript
|
|
298
|
-
* Object Notation) string, with type assertion.
|
|
299
|
-
*
|
|
300
|
-
* In such reason, when `input` value is not matched with the type `T`, it
|
|
301
|
-
* throws an {@link TypeGuardError} or custom error generated by _errorFactory_.
|
|
302
|
-
* Otherwise, there's no problem on the `input` value, JSON string will be
|
|
303
|
-
* returned.
|
|
304
|
-
*
|
|
305
|
-
* For reference, with type assertion, it is even 5x times faster than the
|
|
306
|
-
* native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
|
|
307
|
-
* conversion with confidence.
|
|
308
|
-
*
|
|
309
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
310
|
-
* @template T Type of the input value
|
|
311
|
-
* @param input A value to be asserted and converted
|
|
312
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
313
|
-
* @returns JSON string value
|
|
314
|
-
*/
|
|
315
|
-
export function assertStringify<T>(
|
|
316
|
-
input: T,
|
|
317
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
318
|
-
): string;
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* 5x faster `JSON.stringify()` function with type assertion.
|
|
322
|
-
*
|
|
323
|
-
* `typia.json.assertStringify()` is a combination function of {@link assert} and
|
|
324
|
-
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript
|
|
325
|
-
* Object Notation) string, with type assertion.
|
|
326
|
-
*
|
|
327
|
-
* In such reason, when `input` value is not matched with the type `T`, it
|
|
328
|
-
* throws an {@link TypeGuardError} or custom error generated by _errorFactory_.
|
|
329
|
-
* Otherwise, there's no problem on the `input` value, JSON string will be
|
|
330
|
-
* returned.
|
|
331
|
-
*
|
|
332
|
-
* For reference, with type assertion, it is even 5x times faster than the
|
|
333
|
-
* native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
|
|
334
|
-
* conversion with confidence.
|
|
335
|
-
*
|
|
336
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
337
|
-
* @template T Type of the input value
|
|
338
|
-
* @param input A value to be asserted and converted
|
|
339
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
340
|
-
* @returns JSON string value
|
|
341
|
-
*/
|
|
342
|
-
export function assertStringify<T>(
|
|
343
|
-
input: T,
|
|
344
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
345
|
-
): unknown;
|
|
346
|
-
|
|
347
|
-
/** @internal */
|
|
348
|
-
export function assertStringify(): string {
|
|
349
|
-
NoTransformConfigurationError("json.assertStringify");
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* 7x faster `JSON.stringify()` function with type checking.
|
|
354
|
-
*
|
|
355
|
-
* `typia.json.stringify()` is a combination function of {@link is} and
|
|
356
|
-
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript
|
|
357
|
-
* Object Notation) string, with type checking.
|
|
358
|
-
*
|
|
359
|
-
* In such reason, when `input` value is not matched with the type `T`, it
|
|
360
|
-
* returns `null` value. Otherwise, there's no problem on the `input` value,
|
|
361
|
-
* JSON string will be returned.
|
|
362
|
-
*
|
|
363
|
-
* For reference, with type checking, it is even 7x times faster than the native
|
|
364
|
-
* `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
|
|
365
|
-
* with confidence.
|
|
366
|
-
*
|
|
367
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
368
|
-
* @template T Type of the input value
|
|
369
|
-
* @param input A value to be checked and converted
|
|
370
|
-
* @returns JSON string value when exact type, otherwise null
|
|
371
|
-
*/
|
|
372
|
-
export function isStringify<T>(input: T): string | null;
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* 7x faster `JSON.stringify()` function with type checking.
|
|
376
|
-
*
|
|
377
|
-
* `typia.json.isStringify()` is a combination function of {@link is} and
|
|
378
|
-
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript
|
|
379
|
-
* Object Notation) string, with type checking.
|
|
380
|
-
*
|
|
381
|
-
* In such reason, when `input` value is not matched with the type `T`, it
|
|
382
|
-
* returns `null` value. Otherwise, there's no problem on the `input` value,
|
|
383
|
-
* JSON string will be returned.
|
|
384
|
-
*
|
|
385
|
-
* For reference, with type checking, it is even 7x times faster than the native
|
|
386
|
-
* `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
|
|
387
|
-
* with confidence.
|
|
388
|
-
*
|
|
389
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
390
|
-
* @template T Type of the input value
|
|
391
|
-
* @param input A value to be checked and converted
|
|
392
|
-
* @returns JSON string value when exact type, otherwise null
|
|
393
|
-
*/
|
|
394
|
-
export function isStringify<T>(input: unknown): string | null;
|
|
395
|
-
|
|
396
|
-
/** @internal */
|
|
397
|
-
export function isStringify(): string | null {
|
|
398
|
-
NoTransformConfigurationError("json.isStringify");
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* 5x faster `JSON.stringify()` function with detailed type validation.
|
|
403
|
-
*
|
|
404
|
-
* `typia.json.validateStringify()` is a combination function of {@link validate}
|
|
405
|
-
* and {@link stringify}. Therefore, it converts an input value to JSON
|
|
406
|
-
* (JavaScript Object Notation) string, with detailed type validation.
|
|
407
|
-
*
|
|
408
|
-
* In such reason, when `input` value is not matched with the type `T`, it
|
|
409
|
-
* returns {@link IValidation.IFailure} value with detailed error reasons.
|
|
410
|
-
* Otherwise, there's no problem on the `input` value, JSON string will be
|
|
411
|
-
* stored in `data` property of the output {@link IValidation.ISuccess}
|
|
412
|
-
* instance.
|
|
413
|
-
*
|
|
414
|
-
* For reference, with detailed type validation, it is even 5x times faster than
|
|
415
|
-
* the native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
|
|
416
|
-
* conversion with confidence.
|
|
417
|
-
*
|
|
418
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
419
|
-
* @template T Type of the input value
|
|
420
|
-
* @param input A value to be checked and converted
|
|
421
|
-
* @returns Validation result with JSON string value
|
|
422
|
-
*/
|
|
423
|
-
export function validateStringify<T>(input: T): IValidation<string>;
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* 5x faster `JSON.stringify()` function with detailed type validation.
|
|
427
|
-
*
|
|
428
|
-
* `typia.json.validateStringify()` is a combination function of {@link validate}
|
|
429
|
-
* and {@link stringify}. Therefore, it converts an input value to JSON
|
|
430
|
-
* (JavaScript Object Notation) string, with detailed type validation.
|
|
431
|
-
*
|
|
432
|
-
* In such reason, when `input` value is not matched with the type `T`, it
|
|
433
|
-
* returns {@link IValidation.IFailure} value with detailed error reasons.
|
|
434
|
-
* Otherwise, there's no problem on the `input` value, JSON string will be
|
|
435
|
-
* stored in `data` property of the output {@link IValidation.ISuccess}
|
|
436
|
-
* instance.
|
|
437
|
-
*
|
|
438
|
-
* For reference, with detailed type validation, it is even 5x times faster than
|
|
439
|
-
* the native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
|
|
440
|
-
* conversion with confidence.
|
|
441
|
-
*
|
|
442
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
443
|
-
* @template T Type of the input value
|
|
444
|
-
* @param input A value to be checked and converted
|
|
445
|
-
* @returns Validation result with JSON string value
|
|
446
|
-
*/
|
|
447
|
-
export function validateStringify<T>(input: unknown): IValidation<string>;
|
|
448
|
-
|
|
449
|
-
/** @internal */
|
|
450
|
-
export function validateStringify(): IValidation<string> {
|
|
451
|
-
NoTransformConfigurationError("json.validateStringify");
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/* -----------------------------------------------------------
|
|
455
|
-
FACTORY FUNCTIONS
|
|
456
|
-
----------------------------------------------------------- */
|
|
457
|
-
/**
|
|
458
|
-
* Creates a reusable {@link isParse} function.
|
|
459
|
-
*
|
|
460
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
461
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
462
|
-
* @throws Compile error
|
|
463
|
-
* @danger You must configure the generic argument `T`
|
|
464
|
-
*/
|
|
465
|
-
export function createIsParse(): never;
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Creates a reusable {@link isParse} function.
|
|
469
|
-
*
|
|
470
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
471
|
-
* @template T Expected type of parsed value
|
|
472
|
-
* @returns A reusable `isParse` function
|
|
473
|
-
*/
|
|
474
|
-
export function createIsParse<T>(): (input: string) => Primitive<T> | null;
|
|
475
|
-
|
|
476
|
-
/** @internal */
|
|
477
|
-
export function createIsParse<T>(): (input: string) => Primitive<T> | null {
|
|
478
|
-
NoTransformConfigurationError("json.createIsParse");
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Creates a reusable {@link assertParse} function.
|
|
483
|
-
*
|
|
484
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
485
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
486
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
487
|
-
* @throws Compile error
|
|
488
|
-
* @danger You must configure the generic argument `T`
|
|
489
|
-
*/
|
|
490
|
-
export function createAssertParse(
|
|
491
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
492
|
-
): never;
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Creates a reusable {@link assertParse} function.
|
|
496
|
-
*
|
|
497
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
498
|
-
* @template T Expected type of parsed value
|
|
499
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
500
|
-
* @returns A reusable `assertParse` function
|
|
501
|
-
*/
|
|
502
|
-
export function createAssertParse<T>(
|
|
503
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
504
|
-
): (input: string) => Primitive<T>;
|
|
505
|
-
|
|
506
|
-
/** @internal */
|
|
507
|
-
export function createAssertParse<T>(): (input: string) => Primitive<T> {
|
|
508
|
-
NoTransformConfigurationError("json.createAssertParse");
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Creates a reusable {@link validateParse} function.
|
|
513
|
-
*
|
|
514
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
515
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
516
|
-
* @throws Compile error
|
|
517
|
-
* @danger You must configure the generic argument `T`
|
|
518
|
-
*/
|
|
519
|
-
export function createValidateParse(): never;
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Creates a reusable {@link validateParse} function.
|
|
523
|
-
*
|
|
524
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
525
|
-
* @template T Expected type of parsed value
|
|
526
|
-
* @returns A reusable `validateParse` function
|
|
527
|
-
*/
|
|
528
|
-
export function createValidateParse<T>(): (
|
|
529
|
-
input: string,
|
|
530
|
-
) => IValidation<Primitive<T>>;
|
|
531
|
-
|
|
532
|
-
/** @internal */
|
|
533
|
-
export function createValidateParse<T>(): (
|
|
534
|
-
input: string,
|
|
535
|
-
) => IValidation<Primitive<T>> {
|
|
536
|
-
NoTransformConfigurationError("json.createValidateParse");
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Creates a reusable {@link stringify} function.
|
|
541
|
-
*
|
|
542
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
543
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
544
|
-
* @throws Compile error
|
|
545
|
-
* @danger You must configure the generic argument `T`
|
|
546
|
-
*/
|
|
547
|
-
export function createStringify(): never;
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Creates a reusable {@link stringify} function.
|
|
551
|
-
*
|
|
552
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
553
|
-
* @template T Type of the input value
|
|
554
|
-
* @returns A reusable `stringify` function
|
|
555
|
-
*/
|
|
556
|
-
export function createStringify<T>(): (input: T) => string;
|
|
557
|
-
|
|
558
|
-
/** @internal */
|
|
559
|
-
export function createStringify<T>(): (input: T) => string {
|
|
560
|
-
NoTransformConfigurationError("json.createStringify");
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* Creates a reusable {@link assertStringify} function.
|
|
565
|
-
*
|
|
566
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
567
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
568
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
569
|
-
* @throws Compile error
|
|
570
|
-
* @danger You must configure the generic argument `T`
|
|
571
|
-
*/
|
|
572
|
-
export function createAssertStringify(
|
|
573
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
574
|
-
): never;
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Creates a reusable {@link assertStringify} function.
|
|
578
|
-
*
|
|
579
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
580
|
-
* @template T Type of the input value
|
|
581
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
582
|
-
* @returns A reusable `assertStringify` function
|
|
583
|
-
*/
|
|
584
|
-
export function createAssertStringify<T>(
|
|
585
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
586
|
-
): (input: unknown) => string;
|
|
587
|
-
|
|
588
|
-
/** @internal */
|
|
589
|
-
export function createAssertStringify(): (input: unknown) => string {
|
|
590
|
-
NoTransformConfigurationError("json.createAssertStringify");
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Creates a reusable {@link isStringify} function.
|
|
595
|
-
*
|
|
596
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
597
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
598
|
-
* @throws Compile error
|
|
599
|
-
* @danger You must configure the generic argument `T`
|
|
600
|
-
*/
|
|
601
|
-
export function createIsStringify(): never;
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* Creates a reusable {@link isStringify} function.
|
|
605
|
-
*
|
|
606
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
607
|
-
* @template T Type of the input value
|
|
608
|
-
* @returns A reusable `isStringify` function
|
|
609
|
-
*/
|
|
610
|
-
export function createIsStringify<T>(): (input: unknown) => string | null;
|
|
611
|
-
|
|
612
|
-
/** @internal */
|
|
613
|
-
export function createIsStringify(): (input: unknown) => string | null {
|
|
614
|
-
NoTransformConfigurationError("json.createIsStringify");
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* Creates a reusable {@link validateStringify} function.
|
|
619
|
-
*
|
|
620
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
621
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
622
|
-
* @throws Compile error
|
|
623
|
-
* @danger You must configure the generic argument `T`
|
|
624
|
-
*/
|
|
625
|
-
export function createValidateStringify(): never;
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Creates a reusable {@link validateStringify} function.
|
|
629
|
-
*
|
|
630
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
631
|
-
* @template T Type of the input value
|
|
632
|
-
* @returns A reusable `validateStringify` function
|
|
633
|
-
*/
|
|
634
|
-
export function createValidateStringify<T>(): (
|
|
635
|
-
input: unknown,
|
|
636
|
-
) => IValidation<string>;
|
|
637
|
-
|
|
638
|
-
/** @internal */
|
|
639
|
-
export function createValidateStringify(): (
|
|
640
|
-
input: unknown,
|
|
641
|
-
) => IValidation<string> {
|
|
642
|
-
NoTransformConfigurationError("json.createValidateStringify");
|
|
643
|
-
}
|
|
1
|
+
import { IJsonSchemaCollection } from "./schemas/json/IJsonSchemaCollection";
|
|
2
|
+
import { IJsonSchemaUnit } from "./schemas/json/IJsonSchemaUnit";
|
|
3
|
+
|
|
4
|
+
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
|
|
5
|
+
|
|
6
|
+
import { IValidation } from "./IValidation";
|
|
7
|
+
import { Primitive } from "./Primitive";
|
|
8
|
+
import { TypeGuardError } from "./TypeGuardError";
|
|
9
|
+
|
|
10
|
+
/* ===========================================================
|
|
11
|
+
JSON
|
|
12
|
+
- METADATA
|
|
13
|
+
- PARSE
|
|
14
|
+
- STRINGIFY
|
|
15
|
+
- FACTORY FUNCTIONS
|
|
16
|
+
==============================================================
|
|
17
|
+
METADATA
|
|
18
|
+
----------------------------------------------------------- */
|
|
19
|
+
/**
|
|
20
|
+
* > You must configure the generic argument `Types`.
|
|
21
|
+
*
|
|
22
|
+
* JSON Schemas Generator.
|
|
23
|
+
*
|
|
24
|
+
* Creates a JSON schema list which contains both main JSON schemas and
|
|
25
|
+
* components. Note that, all of the named types are stored in the
|
|
26
|
+
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
|
|
27
|
+
*
|
|
28
|
+
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
29
|
+
* argument `Version`. For reference, the default version is `"3.1"`, and the
|
|
30
|
+
* key difference between `"3.0"` and `"3.1"` is whether supporting the tuple
|
|
31
|
+
* type or not.
|
|
32
|
+
*
|
|
33
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
+
* @template Types Tuple of target types
|
|
35
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
36
|
+
* @returns JSON schema collection
|
|
37
|
+
*/
|
|
38
|
+
export function schemas(): never;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* JSON Schemas Generator.
|
|
42
|
+
*
|
|
43
|
+
* Creates a JSON schema list which contains both main JSON schemas and
|
|
44
|
+
* components. Note that, all of the named types are stored in the
|
|
45
|
+
* {@link IJsonSchemaCollection.components} property for the `$ref` referencing.
|
|
46
|
+
*
|
|
47
|
+
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
48
|
+
* argument `Version`. For reference, the default version is `"3.1"`, and the
|
|
49
|
+
* key difference between `"3.0"` and `"3.1"` is whether supporting the tuple
|
|
50
|
+
* type or not.
|
|
51
|
+
*
|
|
52
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
53
|
+
* @template Types Tuple of target types
|
|
54
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
55
|
+
* @returns JSON schema collection
|
|
56
|
+
*/
|
|
57
|
+
export function schemas<
|
|
58
|
+
Types extends unknown[],
|
|
59
|
+
Version extends "3.0" | "3.1" = "3.1",
|
|
60
|
+
>(): IJsonSchemaCollection<Version, Types>;
|
|
61
|
+
|
|
62
|
+
/** @internal */
|
|
63
|
+
export function schemas(): never {
|
|
64
|
+
NoTransformConfigurationError("json.schemas");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* > You must configure the generic argument `Type`.
|
|
69
|
+
*
|
|
70
|
+
* JSON schema generator.
|
|
71
|
+
*
|
|
72
|
+
* Creates a JSON schema unit which contains a main JSON schema and its
|
|
73
|
+
* components. Note that, all of the named types are stored in the
|
|
74
|
+
* {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
|
|
75
|
+
*
|
|
76
|
+
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
77
|
+
* argument `Version`. For reference, the default version is `"3.1"`, and key
|
|
78
|
+
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or
|
|
79
|
+
* not.
|
|
80
|
+
*
|
|
81
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
82
|
+
* @template Type Target type
|
|
83
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
84
|
+
* @returns JSON schema unit
|
|
85
|
+
*/
|
|
86
|
+
export function schema(): never;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* JSON schema generator.
|
|
90
|
+
*
|
|
91
|
+
* Creates a JSON schema unit which contains a main JSON schema and its
|
|
92
|
+
* components. Note that, all of the named types are stored in the
|
|
93
|
+
* {@link IJsonSchemaUnit.components} property for the `$ref` referencing.
|
|
94
|
+
*
|
|
95
|
+
* Also, you can specify the OpenAPI version by configuring the second generic
|
|
96
|
+
* argument `Version`. For reference, the default version is `"3.1"`, and key
|
|
97
|
+
* different of `"3.0"` and `"3.1"` is whether supporting the tuple type or
|
|
98
|
+
* not.
|
|
99
|
+
*
|
|
100
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
101
|
+
* @template Type Target type
|
|
102
|
+
* @template Version Version of OpenAPI specification. Default is 3.1
|
|
103
|
+
* @returns JSON schema unit
|
|
104
|
+
*/
|
|
105
|
+
export function schema<
|
|
106
|
+
Type extends unknown,
|
|
107
|
+
Version extends "3.0" | "3.1" = "3.1",
|
|
108
|
+
>(): IJsonSchemaUnit<Version, Type>;
|
|
109
|
+
|
|
110
|
+
/** @internal */
|
|
111
|
+
export function schema(): never {
|
|
112
|
+
NoTransformConfigurationError("json.schema");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* -----------------------------------------------------------
|
|
116
|
+
PARSE
|
|
117
|
+
----------------------------------------------------------- */
|
|
118
|
+
/**
|
|
119
|
+
* > You must configure the generic argument `T`.
|
|
120
|
+
*
|
|
121
|
+
* Safe `JSON.parse()` function with type assertion.
|
|
122
|
+
*
|
|
123
|
+
* `typia.json.assertParse()` is a combination function of `JSON.parse()` and
|
|
124
|
+
* {@link assert}. Therefore, it converts a JSON (JavaScript Object Notation)
|
|
125
|
+
* string to a `T` typed instance with type assertion.
|
|
126
|
+
*
|
|
127
|
+
* In such reason, when parsed JSON string value is not matched with the type
|
|
128
|
+
* `T`, it throws {@link TypeGuardError} or custom error generated by
|
|
129
|
+
* _errorFactory_. Otherwise, if there's no problem with the parsed value, the
|
|
130
|
+
* parsed value will be returned.
|
|
131
|
+
*
|
|
132
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
133
|
+
* @template T Expected type of parsed value
|
|
134
|
+
* @param input JSON string
|
|
135
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
136
|
+
* @returns Parsed value
|
|
137
|
+
*/
|
|
138
|
+
export function assertParse(
|
|
139
|
+
input: string,
|
|
140
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
141
|
+
): never;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Safe `JSON.parse()` function with type assertion.
|
|
145
|
+
*
|
|
146
|
+
* `typia.json.assertParse()` is a combination function of `JSON.parse()` and
|
|
147
|
+
* {@link assert}. Therefore, it converts a JSON (JavaScript Object Notation)
|
|
148
|
+
* string to a `T` typed instance with type assertion.
|
|
149
|
+
*
|
|
150
|
+
* In such reason, when parsed JSON string value is not matched with the type
|
|
151
|
+
* `T`, it throws {@link TypeGuardError} or custom error generated by
|
|
152
|
+
* _errorFactory_. Otherwise, there's no problem on the parsed value, the parsed
|
|
153
|
+
* value would be returned.
|
|
154
|
+
*
|
|
155
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
156
|
+
* @template T Expected type of parsed value
|
|
157
|
+
* @param input JSON string
|
|
158
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
159
|
+
* @returns Parsed value
|
|
160
|
+
*/
|
|
161
|
+
export function assertParse<T>(
|
|
162
|
+
input: string,
|
|
163
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
164
|
+
): Primitive<T>;
|
|
165
|
+
|
|
166
|
+
/** @internal */
|
|
167
|
+
export function assertParse<T>(): Primitive<T> {
|
|
168
|
+
NoTransformConfigurationError("json.assertParse");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* > You must configure the generic argument `T`.
|
|
173
|
+
*
|
|
174
|
+
* Safe `JSON.parse()` function with type checking.
|
|
175
|
+
*
|
|
176
|
+
* `typia.json.isParse()` is a combination function of `JSON.parse()` and
|
|
177
|
+
* {@link is}. Therefore, it converts a JSON (JavaScript Object Notation) string
|
|
178
|
+
* to a `T` typed instance with type checking.
|
|
179
|
+
*
|
|
180
|
+
* In such reason, when parsed JSON string value is not matched with the type
|
|
181
|
+
* `T`, it returns `null` value. Otherwise, there's no problem on the parsed
|
|
182
|
+
* value, the parsed value will be returned.
|
|
183
|
+
*
|
|
184
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
185
|
+
* @template T Expected type of parsed value
|
|
186
|
+
* @param input JSON string
|
|
187
|
+
* @returns Parsed value when exact type, otherwise `null`
|
|
188
|
+
*/
|
|
189
|
+
export function isParse(input: string): never;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Safe `JSON.parse()` function with type checking.
|
|
193
|
+
*
|
|
194
|
+
* `typia.json.isParse()` is a combination function of `JSON.parse()` and
|
|
195
|
+
* {@link is}. Therefore, it converts a JSON (JavaScript Object Notation) string
|
|
196
|
+
* to a `T` typed instance with type checking.
|
|
197
|
+
*
|
|
198
|
+
* In such reason, when parsed JSON string value is not matched with the type
|
|
199
|
+
* `T`, it returns `null` value. Otherwise, there's no problem on the parsed
|
|
200
|
+
* value, the parsed value will be returned.
|
|
201
|
+
*
|
|
202
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
203
|
+
* @template T Expected type of parsed value
|
|
204
|
+
* @param input JSON string
|
|
205
|
+
* @returns Parsed value when exact type, otherwise `null`
|
|
206
|
+
*/
|
|
207
|
+
export function isParse<T>(input: string): Primitive<T> | null;
|
|
208
|
+
|
|
209
|
+
/** @internal */
|
|
210
|
+
export function isParse<T>(): Primitive<T> | null {
|
|
211
|
+
NoTransformConfigurationError("json.isParse");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* > You must configure the generic argument `T`.
|
|
216
|
+
*
|
|
217
|
+
* Safe `JSON.parse()` function with detailed type validation.
|
|
218
|
+
*
|
|
219
|
+
* `typia.json.validateParse()` is a combination function of `JSON.parse()` and
|
|
220
|
+
* {@link validate}. Therefore, it converts a JSON (JavaScript Object Notation)
|
|
221
|
+
* string to a `T` typed instance with detailed type validation.
|
|
222
|
+
*
|
|
223
|
+
* In such reason, when parsed JSON string value is not matched with the type
|
|
224
|
+
* `T`, it returns {@link IValidation.IFailure} value with detailed error
|
|
225
|
+
* reasons. Otherwise, there's no problem on the parsed value, the parsed value
|
|
226
|
+
* will be stored in `data` property of the output {@link IValidation.ISuccess}
|
|
227
|
+
* instance.
|
|
228
|
+
*
|
|
229
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
230
|
+
* @template T Expected type of parsed value
|
|
231
|
+
* @param input JSON string
|
|
232
|
+
* @returns Validation result with JSON parsed value
|
|
233
|
+
*/
|
|
234
|
+
export function validateParse(input: string): never;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Safe `JSON.parse()` function with detailed type validation.
|
|
238
|
+
*
|
|
239
|
+
* `typia.json.validateParse()` is a combination function of `JSON.parse()` and
|
|
240
|
+
* {@link validate}. Therefore, it converts a JSON (JavaScript Object Notation)
|
|
241
|
+
* string to a `T` typed instance with detailed type validation.
|
|
242
|
+
*
|
|
243
|
+
* In such reason, when parsed JSON string value is not matched with the type
|
|
244
|
+
* `T`, it returns {@link IValidation.IFailure} value with detailed error
|
|
245
|
+
* reasons. Otherwise, there's no problem on the parsed value, the parsed value
|
|
246
|
+
* will be stored in `data` property of the output {@link IValidation.ISuccess}
|
|
247
|
+
* instance.
|
|
248
|
+
*
|
|
249
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
250
|
+
* @template T Expected type of parsed value
|
|
251
|
+
* @param input JSON string
|
|
252
|
+
* @returns Validation result with JSON parsed value
|
|
253
|
+
*/
|
|
254
|
+
export function validateParse<T>(input: string): IValidation<Primitive<T>>;
|
|
255
|
+
|
|
256
|
+
/** @internal */
|
|
257
|
+
export function validateParse<T>(): IValidation<Primitive<T>> {
|
|
258
|
+
NoTransformConfigurationError("json.validateParse");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* -----------------------------------------------------------
|
|
262
|
+
STRINGIFY
|
|
263
|
+
----------------------------------------------------------- */
|
|
264
|
+
/**
|
|
265
|
+
* 8x faster `JSON.stringify()` function.
|
|
266
|
+
*
|
|
267
|
+
* Converts an input value to a JSON (JavaScript Object Notation) string, about
|
|
268
|
+
* 8x faster than the native `JSON.stringify()` function. The 5x faster
|
|
269
|
+
* principle is because it writes an optimized JSON conversion plan, only for
|
|
270
|
+
* the type `T`.
|
|
271
|
+
*
|
|
272
|
+
* For reference, this `typia.json.stringify()` does not validate the input
|
|
273
|
+
* value type. It just believes that the input value is following the type `T`.
|
|
274
|
+
* Therefore, if you can't ensure the input value type, it will be better to
|
|
275
|
+
* call one of below functions instead.
|
|
276
|
+
*
|
|
277
|
+
* - {@link assertStringify}
|
|
278
|
+
* - {@link isStringify}
|
|
279
|
+
* - {@link validateStringify}
|
|
280
|
+
*
|
|
281
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
282
|
+
* @template T Type of the input value
|
|
283
|
+
* @param input A value to be converted
|
|
284
|
+
* @returns JSON string value
|
|
285
|
+
*/
|
|
286
|
+
export function stringify<T>(input: T): string;
|
|
287
|
+
|
|
288
|
+
/** @internal */
|
|
289
|
+
export function stringify(): never {
|
|
290
|
+
NoTransformConfigurationError("json.stringify");
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 5x faster `JSON.stringify()` function with type assertion.
|
|
295
|
+
*
|
|
296
|
+
* `typia.json.assertStringify()` is a combination function of {@link assert} and
|
|
297
|
+
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript
|
|
298
|
+
* Object Notation) string, with type assertion.
|
|
299
|
+
*
|
|
300
|
+
* In such reason, when `input` value is not matched with the type `T`, it
|
|
301
|
+
* throws an {@link TypeGuardError} or custom error generated by _errorFactory_.
|
|
302
|
+
* Otherwise, there's no problem on the `input` value, JSON string will be
|
|
303
|
+
* returned.
|
|
304
|
+
*
|
|
305
|
+
* For reference, with type assertion, it is even 5x times faster than the
|
|
306
|
+
* native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
|
|
307
|
+
* conversion with confidence.
|
|
308
|
+
*
|
|
309
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
310
|
+
* @template T Type of the input value
|
|
311
|
+
* @param input A value to be asserted and converted
|
|
312
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
313
|
+
* @returns JSON string value
|
|
314
|
+
*/
|
|
315
|
+
export function assertStringify<T>(
|
|
316
|
+
input: T,
|
|
317
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
318
|
+
): string;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* 5x faster `JSON.stringify()` function with type assertion.
|
|
322
|
+
*
|
|
323
|
+
* `typia.json.assertStringify()` is a combination function of {@link assert} and
|
|
324
|
+
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript
|
|
325
|
+
* Object Notation) string, with type assertion.
|
|
326
|
+
*
|
|
327
|
+
* In such reason, when `input` value is not matched with the type `T`, it
|
|
328
|
+
* throws an {@link TypeGuardError} or custom error generated by _errorFactory_.
|
|
329
|
+
* Otherwise, there's no problem on the `input` value, JSON string will be
|
|
330
|
+
* returned.
|
|
331
|
+
*
|
|
332
|
+
* For reference, with type assertion, it is even 5x times faster than the
|
|
333
|
+
* native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
|
|
334
|
+
* conversion with confidence.
|
|
335
|
+
*
|
|
336
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
337
|
+
* @template T Type of the input value
|
|
338
|
+
* @param input A value to be asserted and converted
|
|
339
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
340
|
+
* @returns JSON string value
|
|
341
|
+
*/
|
|
342
|
+
export function assertStringify<T>(
|
|
343
|
+
input: T,
|
|
344
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
345
|
+
): unknown;
|
|
346
|
+
|
|
347
|
+
/** @internal */
|
|
348
|
+
export function assertStringify(): string {
|
|
349
|
+
NoTransformConfigurationError("json.assertStringify");
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* 7x faster `JSON.stringify()` function with type checking.
|
|
354
|
+
*
|
|
355
|
+
* `typia.json.stringify()` is a combination function of {@link is} and
|
|
356
|
+
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript
|
|
357
|
+
* Object Notation) string, with type checking.
|
|
358
|
+
*
|
|
359
|
+
* In such reason, when `input` value is not matched with the type `T`, it
|
|
360
|
+
* returns `null` value. Otherwise, there's no problem on the `input` value,
|
|
361
|
+
* JSON string will be returned.
|
|
362
|
+
*
|
|
363
|
+
* For reference, with type checking, it is even 7x times faster than the native
|
|
364
|
+
* `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
|
|
365
|
+
* with confidence.
|
|
366
|
+
*
|
|
367
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
368
|
+
* @template T Type of the input value
|
|
369
|
+
* @param input A value to be checked and converted
|
|
370
|
+
* @returns JSON string value when exact type, otherwise null
|
|
371
|
+
*/
|
|
372
|
+
export function isStringify<T>(input: T): string | null;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 7x faster `JSON.stringify()` function with type checking.
|
|
376
|
+
*
|
|
377
|
+
* `typia.json.isStringify()` is a combination function of {@link is} and
|
|
378
|
+
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript
|
|
379
|
+
* Object Notation) string, with type checking.
|
|
380
|
+
*
|
|
381
|
+
* In such reason, when `input` value is not matched with the type `T`, it
|
|
382
|
+
* returns `null` value. Otherwise, there's no problem on the `input` value,
|
|
383
|
+
* JSON string will be returned.
|
|
384
|
+
*
|
|
385
|
+
* For reference, with type checking, it is even 7x times faster than the native
|
|
386
|
+
* `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
|
|
387
|
+
* with confidence.
|
|
388
|
+
*
|
|
389
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
390
|
+
* @template T Type of the input value
|
|
391
|
+
* @param input A value to be checked and converted
|
|
392
|
+
* @returns JSON string value when exact type, otherwise null
|
|
393
|
+
*/
|
|
394
|
+
export function isStringify<T>(input: unknown): string | null;
|
|
395
|
+
|
|
396
|
+
/** @internal */
|
|
397
|
+
export function isStringify(): string | null {
|
|
398
|
+
NoTransformConfigurationError("json.isStringify");
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* 5x faster `JSON.stringify()` function with detailed type validation.
|
|
403
|
+
*
|
|
404
|
+
* `typia.json.validateStringify()` is a combination function of {@link validate}
|
|
405
|
+
* and {@link stringify}. Therefore, it converts an input value to JSON
|
|
406
|
+
* (JavaScript Object Notation) string, with detailed type validation.
|
|
407
|
+
*
|
|
408
|
+
* In such reason, when `input` value is not matched with the type `T`, it
|
|
409
|
+
* returns {@link IValidation.IFailure} value with detailed error reasons.
|
|
410
|
+
* Otherwise, there's no problem on the `input` value, JSON string will be
|
|
411
|
+
* stored in `data` property of the output {@link IValidation.ISuccess}
|
|
412
|
+
* instance.
|
|
413
|
+
*
|
|
414
|
+
* For reference, with detailed type validation, it is even 5x times faster than
|
|
415
|
+
* the native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
|
|
416
|
+
* conversion with confidence.
|
|
417
|
+
*
|
|
418
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
419
|
+
* @template T Type of the input value
|
|
420
|
+
* @param input A value to be checked and converted
|
|
421
|
+
* @returns Validation result with JSON string value
|
|
422
|
+
*/
|
|
423
|
+
export function validateStringify<T>(input: T): IValidation<string>;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* 5x faster `JSON.stringify()` function with detailed type validation.
|
|
427
|
+
*
|
|
428
|
+
* `typia.json.validateStringify()` is a combination function of {@link validate}
|
|
429
|
+
* and {@link stringify}. Therefore, it converts an input value to JSON
|
|
430
|
+
* (JavaScript Object Notation) string, with detailed type validation.
|
|
431
|
+
*
|
|
432
|
+
* In such reason, when `input` value is not matched with the type `T`, it
|
|
433
|
+
* returns {@link IValidation.IFailure} value with detailed error reasons.
|
|
434
|
+
* Otherwise, there's no problem on the `input` value, JSON string will be
|
|
435
|
+
* stored in `data` property of the output {@link IValidation.ISuccess}
|
|
436
|
+
* instance.
|
|
437
|
+
*
|
|
438
|
+
* For reference, with detailed type validation, it is even 5x times faster than
|
|
439
|
+
* the native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
|
|
440
|
+
* conversion with confidence.
|
|
441
|
+
*
|
|
442
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
443
|
+
* @template T Type of the input value
|
|
444
|
+
* @param input A value to be checked and converted
|
|
445
|
+
* @returns Validation result with JSON string value
|
|
446
|
+
*/
|
|
447
|
+
export function validateStringify<T>(input: unknown): IValidation<string>;
|
|
448
|
+
|
|
449
|
+
/** @internal */
|
|
450
|
+
export function validateStringify(): IValidation<string> {
|
|
451
|
+
NoTransformConfigurationError("json.validateStringify");
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/* -----------------------------------------------------------
|
|
455
|
+
FACTORY FUNCTIONS
|
|
456
|
+
----------------------------------------------------------- */
|
|
457
|
+
/**
|
|
458
|
+
* Creates a reusable {@link isParse} function.
|
|
459
|
+
*
|
|
460
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
461
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
462
|
+
* @throws Compile error
|
|
463
|
+
* @danger You must configure the generic argument `T`
|
|
464
|
+
*/
|
|
465
|
+
export function createIsParse(): never;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Creates a reusable {@link isParse} function.
|
|
469
|
+
*
|
|
470
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
471
|
+
* @template T Expected type of parsed value
|
|
472
|
+
* @returns A reusable `isParse` function
|
|
473
|
+
*/
|
|
474
|
+
export function createIsParse<T>(): (input: string) => Primitive<T> | null;
|
|
475
|
+
|
|
476
|
+
/** @internal */
|
|
477
|
+
export function createIsParse<T>(): (input: string) => Primitive<T> | null {
|
|
478
|
+
NoTransformConfigurationError("json.createIsParse");
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Creates a reusable {@link assertParse} function.
|
|
483
|
+
*
|
|
484
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
485
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
486
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
487
|
+
* @throws Compile error
|
|
488
|
+
* @danger You must configure the generic argument `T`
|
|
489
|
+
*/
|
|
490
|
+
export function createAssertParse(
|
|
491
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
492
|
+
): never;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Creates a reusable {@link assertParse} function.
|
|
496
|
+
*
|
|
497
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
498
|
+
* @template T Expected type of parsed value
|
|
499
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
500
|
+
* @returns A reusable `assertParse` function
|
|
501
|
+
*/
|
|
502
|
+
export function createAssertParse<T>(
|
|
503
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
504
|
+
): (input: string) => Primitive<T>;
|
|
505
|
+
|
|
506
|
+
/** @internal */
|
|
507
|
+
export function createAssertParse<T>(): (input: string) => Primitive<T> {
|
|
508
|
+
NoTransformConfigurationError("json.createAssertParse");
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Creates a reusable {@link validateParse} function.
|
|
513
|
+
*
|
|
514
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
515
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
516
|
+
* @throws Compile error
|
|
517
|
+
* @danger You must configure the generic argument `T`
|
|
518
|
+
*/
|
|
519
|
+
export function createValidateParse(): never;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Creates a reusable {@link validateParse} function.
|
|
523
|
+
*
|
|
524
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
525
|
+
* @template T Expected type of parsed value
|
|
526
|
+
* @returns A reusable `validateParse` function
|
|
527
|
+
*/
|
|
528
|
+
export function createValidateParse<T>(): (
|
|
529
|
+
input: string,
|
|
530
|
+
) => IValidation<Primitive<T>>;
|
|
531
|
+
|
|
532
|
+
/** @internal */
|
|
533
|
+
export function createValidateParse<T>(): (
|
|
534
|
+
input: string,
|
|
535
|
+
) => IValidation<Primitive<T>> {
|
|
536
|
+
NoTransformConfigurationError("json.createValidateParse");
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Creates a reusable {@link stringify} function.
|
|
541
|
+
*
|
|
542
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
543
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
544
|
+
* @throws Compile error
|
|
545
|
+
* @danger You must configure the generic argument `T`
|
|
546
|
+
*/
|
|
547
|
+
export function createStringify(): never;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Creates a reusable {@link stringify} function.
|
|
551
|
+
*
|
|
552
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
553
|
+
* @template T Type of the input value
|
|
554
|
+
* @returns A reusable `stringify` function
|
|
555
|
+
*/
|
|
556
|
+
export function createStringify<T>(): (input: T) => string;
|
|
557
|
+
|
|
558
|
+
/** @internal */
|
|
559
|
+
export function createStringify<T>(): (input: T) => string {
|
|
560
|
+
NoTransformConfigurationError("json.createStringify");
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Creates a reusable {@link assertStringify} function.
|
|
565
|
+
*
|
|
566
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
567
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
568
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
569
|
+
* @throws Compile error
|
|
570
|
+
* @danger You must configure the generic argument `T`
|
|
571
|
+
*/
|
|
572
|
+
export function createAssertStringify(
|
|
573
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
574
|
+
): never;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Creates a reusable {@link assertStringify} function.
|
|
578
|
+
*
|
|
579
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
580
|
+
* @template T Type of the input value
|
|
581
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
582
|
+
* @returns A reusable `assertStringify` function
|
|
583
|
+
*/
|
|
584
|
+
export function createAssertStringify<T>(
|
|
585
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
586
|
+
): (input: unknown) => string;
|
|
587
|
+
|
|
588
|
+
/** @internal */
|
|
589
|
+
export function createAssertStringify(): (input: unknown) => string {
|
|
590
|
+
NoTransformConfigurationError("json.createAssertStringify");
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Creates a reusable {@link isStringify} function.
|
|
595
|
+
*
|
|
596
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
597
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
598
|
+
* @throws Compile error
|
|
599
|
+
* @danger You must configure the generic argument `T`
|
|
600
|
+
*/
|
|
601
|
+
export function createIsStringify(): never;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Creates a reusable {@link isStringify} function.
|
|
605
|
+
*
|
|
606
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
607
|
+
* @template T Type of the input value
|
|
608
|
+
* @returns A reusable `isStringify` function
|
|
609
|
+
*/
|
|
610
|
+
export function createIsStringify<T>(): (input: unknown) => string | null;
|
|
611
|
+
|
|
612
|
+
/** @internal */
|
|
613
|
+
export function createIsStringify(): (input: unknown) => string | null {
|
|
614
|
+
NoTransformConfigurationError("json.createIsStringify");
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Creates a reusable {@link validateStringify} function.
|
|
619
|
+
*
|
|
620
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
621
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
622
|
+
* @throws Compile error
|
|
623
|
+
* @danger You must configure the generic argument `T`
|
|
624
|
+
*/
|
|
625
|
+
export function createValidateStringify(): never;
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Creates a reusable {@link validateStringify} function.
|
|
629
|
+
*
|
|
630
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
631
|
+
* @template T Type of the input value
|
|
632
|
+
* @returns A reusable `validateStringify` function
|
|
633
|
+
*/
|
|
634
|
+
export function createValidateStringify<T>(): (
|
|
635
|
+
input: unknown,
|
|
636
|
+
) => IValidation<string>;
|
|
637
|
+
|
|
638
|
+
/** @internal */
|
|
639
|
+
export function createValidateStringify(): (
|
|
640
|
+
input: unknown,
|
|
641
|
+
) => IValidation<string> {
|
|
642
|
+
NoTransformConfigurationError("json.createValidateStringify");
|
|
643
|
+
}
|