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