typia 5.0.4 → 5.0.5-dev.20230921
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/README.md +1 -1
- package/package.json +1 -1
- package/src/IRandomGenerator.ts +35 -35
- package/src/IValidation.ts +21 -21
- package/src/Primitive.ts +135 -135
- package/src/Resolved.ts +116 -116
- 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 +159 -159
- package/src/factories/IdentifierFactory.ts +74 -74
- package/src/factories/JsonMetadataFactory.ts +43 -43
- package/src/factories/LiteralFactory.ts +47 -47
- package/src/factories/MetadataCollection.ts +269 -269
- package/src/factories/MetadataCommentTagFactory.ts +629 -629
- package/src/factories/MetadataFactory.ts +214 -214
- package/src/factories/MetadataTypeTagFactory.ts +313 -313
- package/src/factories/NumericRangeFactory.ts +33 -33
- package/src/factories/ProtobufFactory.ts +272 -272
- package/src/factories/StatementFactory.ts +72 -72
- package/src/factories/TemplateFactory.ts +58 -58
- package/src/factories/TypeFactory.ts +119 -119
- 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 +40 -40
- package/src/factories/internal/metadata/emplace_metadata_alias.ts +41 -41
- package/src/factories/internal/metadata/emplace_metadata_array_type.ts +41 -41
- package/src/factories/internal/metadata/emplace_metadata_object.ts +150 -150
- package/src/factories/internal/metadata/emplace_metadata_tuple.ts +60 -60
- package/src/factories/internal/metadata/explore_metadata.ts +32 -32
- package/src/factories/internal/metadata/iterate_metadata.ts +101 -101
- package/src/factories/internal/metadata/iterate_metadata_alias.ts +35 -35
- package/src/factories/internal/metadata/iterate_metadata_array.ts +37 -37
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +141 -141
- package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +26 -26
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +197 -197
- package/src/factories/internal/metadata/iterate_metadata_map.ts +57 -57
- package/src/factories/internal/metadata/iterate_metadata_native.ts +210 -210
- package/src/factories/internal/metadata/iterate_metadata_object.ts +44 -44
- package/src/factories/internal/metadata/iterate_metadata_resolve.ts +52 -52
- package/src/factories/internal/metadata/iterate_metadata_set.ts +42 -42
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
- package/src/factories/internal/metadata/iterate_metadata_template.ts +47 -47
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +37 -37
- package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
- package/src/functional/$ProtobufReader.ts +201 -201
- package/src/functional/$ProtobufSizer.ts +147 -147
- package/src/functional/$ProtobufWriter.ts +151 -151
- package/src/functional/$any.ts +4 -4
- package/src/functional/$clone.ts +4 -4
- 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/$join.ts +46 -46
- package/src/functional/$number.ts +13 -13
- package/src/functional/$report.ts +15 -15
- package/src/functional/$rest.ts +3 -3
- package/src/functional/$string.ts +50 -50
- package/src/functional/$strlen.ts +7 -7
- package/src/functional/$tail.ts +5 -5
- package/src/functional/$varint.ts +130 -130
- package/src/functional/$zigzag.ts +39 -39
- package/src/functional/IProtobufWriter.ts +18 -18
- package/src/functional/Namespace.ts +133 -133
- package/src/index.ts +4 -4
- package/src/json.ts +648 -648
- package/src/misc.ts +651 -651
- package/src/module.ts +656 -656
- package/src/programmers/AssertProgrammer.ts +317 -317
- package/src/programmers/CheckerProgrammer.ts +1137 -1137
- package/src/programmers/FeatureProgrammer.ts +478 -478
- package/src/programmers/IsProgrammer.ts +252 -252
- package/src/programmers/RandomProgrammer.ts +878 -878
- package/src/programmers/TypiaProgrammer.ts +163 -163
- package/src/programmers/ValidateProgrammer.ts +346 -346
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/CloneJoiner.ts +144 -144
- package/src/programmers/helpers/FunctionImporeter.ts +91 -91
- package/src/programmers/helpers/ICheckEntry.ts +13 -13
- package/src/programmers/helpers/IExpressionEntry.ts +12 -12
- package/src/programmers/helpers/OptionPredicator.ts +15 -15
- package/src/programmers/helpers/ProtobufUtil.ts +125 -125
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/helpers/PruneJoiner.ts +143 -143
- package/src/programmers/helpers/RandomJoiner.ts +151 -151
- package/src/programmers/helpers/RandomRanger.ts +173 -173
- package/src/programmers/helpers/StringifyJoinder.ts +113 -113
- package/src/programmers/helpers/StringifyPredicator.ts +12 -12
- 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 +32 -32
- package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
- package/src/programmers/internal/application_alias.ts +65 -65
- package/src/programmers/internal/application_array.ts +53 -53
- 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 +37 -37
- package/src/programmers/internal/application_escaped.ts +55 -55
- package/src/programmers/internal/application_native.ts +39 -39
- package/src/programmers/internal/application_number.ts +88 -88
- package/src/programmers/internal/application_object.ts +162 -162
- package/src/programmers/internal/application_schema.ts +175 -175
- package/src/programmers/internal/application_string.ts +51 -51
- package/src/programmers/internal/application_templates.ts +25 -25
- package/src/programmers/internal/application_tuple.ts +58 -58
- package/src/programmers/internal/check_array_length.ts +41 -41
- package/src/programmers/internal/check_bigint.ts +45 -45
- package/src/programmers/internal/check_dynamic_properties.ts +194 -194
- package/src/programmers/internal/check_everything.ts +28 -28
- package/src/programmers/internal/check_native.ts +21 -21
- package/src/programmers/internal/check_number.ts +105 -105
- package/src/programmers/internal/check_object.ts +55 -55
- package/src/programmers/internal/check_string.ts +45 -45
- package/src/programmers/internal/check_template.ts +61 -61
- package/src/programmers/internal/check_union_array_like.ts +323 -323
- package/src/programmers/internal/decode_union_object.ts +84 -84
- package/src/programmers/internal/feature_object_entries.ts +58 -58
- 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 +37 -37
- 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 +20 -20
- package/src/programmers/json/JsonApplicationProgrammer.ts +50 -50
- package/src/programmers/json/JsonAssertParseProgrammer.ts +71 -71
- package/src/programmers/json/JsonAssertStringifyProgrammer.ts +66 -66
- package/src/programmers/json/JsonIsParseProgrammer.ts +77 -77
- package/src/programmers/json/JsonIsStringifyProgrammer.ts +76 -76
- package/src/programmers/json/JsonStringifyProgrammer.ts +964 -964
- package/src/programmers/json/JsonValidateParseProgrammer.ts +68 -68
- package/src/programmers/json/JsonValidateStringifyProgrammer.ts +84 -84
- package/src/programmers/misc/MiscAssertCloneProgrammer.ts +71 -71
- package/src/programmers/misc/MiscAssertPruneProgrammer.ts +68 -68
- package/src/programmers/misc/MiscCloneProgrammer.ts +774 -774
- package/src/programmers/misc/MiscIsCloneProgrammer.ts +78 -78
- package/src/programmers/misc/MiscIsPruneProgrammer.ts +73 -73
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +69 -69
- package/src/programmers/misc/MiscPruneProgrammer.ts +550 -550
- package/src/programmers/misc/MiscValidateCloneProgrammer.ts +85 -85
- package/src/programmers/misc/MiscValidatePruneProgrammer.ts +78 -78
- package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +66 -66
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +655 -655
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +883 -883
- package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +85 -85
- package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +76 -76
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +165 -165
- package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +86 -86
- package/src/protobuf.ts +881 -881
- package/src/schemas/json/IJsonApplication.ts +8 -8
- package/src/schemas/json/IJsonComponents.ts +33 -33
- package/src/schemas/json/IJsonSchema.ts +110 -110
- package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
- package/src/schemas/metadata/IMetadata.ts +34 -34
- package/src/schemas/metadata/IMetadataAlias.ts +12 -12
- package/src/schemas/metadata/IMetadataApplication.ts +7 -7
- package/src/schemas/metadata/IMetadataArray.ts +7 -7
- package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
- package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
- package/src/schemas/metadata/IMetadataCollection.ts +11 -11
- package/src/schemas/metadata/IMetadataConstant.ts +16 -16
- package/src/schemas/metadata/IMetadataDictionary.ts +14 -14
- package/src/schemas/metadata/IMetadataEntry.ts +6 -6
- package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
- package/src/schemas/metadata/IMetadataObject.ts +18 -18
- package/src/schemas/metadata/IMetadataProperty.ts +9 -9
- package/src/schemas/metadata/IMetadataTuple.ts +7 -7
- package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
- package/src/schemas/metadata/IMetadataTypeTag.ts +8 -8
- package/src/schemas/metadata/Metadata.ts +685 -685
- package/src/schemas/metadata/MetadataAlias.ts +61 -61
- package/src/schemas/metadata/MetadataArray.ts +49 -49
- package/src/schemas/metadata/MetadataArrayType.ts +57 -57
- package/src/schemas/metadata/MetadataAtomic.ts +42 -42
- package/src/schemas/metadata/MetadataConstant.ts +3 -3
- package/src/schemas/metadata/MetadataEscaped.ts +51 -51
- package/src/schemas/metadata/MetadataObject.ts +139 -139
- package/src/schemas/metadata/MetadataProperty.ts +59 -59
- package/src/schemas/metadata/MetadataTuple.ts +32 -32
- package/src/schemas/metadata/MetadataTupleType.ts +67 -67
- package/src/tags/ExclusiveMaximum.ts +13 -13
- package/src/tags/ExclusiveMinimum.ts +13 -13
- package/src/tags/Format.ts +30 -30
- package/src/tags/MaxItems.ts +9 -9
- package/src/tags/MaxLength.ts +9 -9
- package/src/tags/Maximum.ts +13 -13
- package/src/tags/MinItems.ts +9 -9
- package/src/tags/MinLength.ts +9 -9
- package/src/tags/Minimum.ts +13 -13
- package/src/tags/MultipleOf.ts +15 -15
- package/src/tags/Pattern.ts +8 -8
- package/src/tags/TagBase.ts +68 -68
- package/src/tags/Type.ts +27 -27
- package/src/tags/index.ts +13 -13
- package/src/transform.ts +35 -35
- package/src/transformers/CallExpressionTransformer.ts +243 -243
- package/src/transformers/FileTransformer.ts +57 -57
- package/src/transformers/IProject.ts +15 -15
- package/src/transformers/ITransformOptions.ts +62 -62
- package/src/transformers/ImportTransformer.ts +66 -66
- package/src/transformers/NodeTransformer.ts +13 -13
- package/src/transformers/TransformerError.ts +55 -55
- package/src/transformers/features/AssertTransformer.ts +11 -11
- package/src/transformers/features/CreateAssertTransformer.ts +13 -13
- package/src/transformers/features/CreateIsTransformer.ts +11 -11
- package/src/transformers/features/CreateRandomTransformer.ts +43 -43
- package/src/transformers/features/CreateValidateTransformer.ts +13 -13
- package/src/transformers/features/IsTransformer.ts +11 -11
- package/src/transformers/features/RandomTransformer.ts +46 -46
- package/src/transformers/features/ValidateTransformer.ts +11 -11
- package/src/transformers/features/json/JsonApplicationTransformer.ts +118 -118
- package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
- package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
- package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
- package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
- package/src/transformers/features/misc/MetadataTransformer.ts +61 -61
- package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
- package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
- package/src/transformers/features/protobuf/CreateProtobufAssertDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufAssertEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufDecodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/CreateProtobufEncodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/CreateProtobufIsDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufIsEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufValidateDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/CreateProtobufValidateEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufAssertDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufAssertEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufIsDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufIsEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
- package/src/transformers/features/protobuf/ProtobufValidateDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufValidateEncodeTransformer.ts +12 -12
- package/src/transformers/internal/GenericTransformer.ts +104 -104
- package/src/typings/Atomic.ts +18 -18
- package/src/typings/ClassProperties.ts +5 -5
- package/src/typings/Customizable.ts +5 -5
- package/src/typings/OmitNever.ts +3 -3
- package/src/typings/ProtobufAtomic.ts +19 -19
- package/src/typings/SpecialFields.ts +3 -3
- package/src/typings/ValidationPipe.ts +9 -9
- 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/NameEncoder.ts +32 -32
- package/src/utils/PatternUtil.ts +33 -33
- package/src/utils/RandomGenerator.ts +83 -83
- package/src/utils/Singleton.ts +17 -17
package/src/misc.ts
CHANGED
|
@@ -1,651 +1,651 @@
|
|
|
1
|
-
/* ===========================================================
|
|
2
|
-
MISCELLAENOUS
|
|
3
|
-
- LITERALS
|
|
4
|
-
- CLONE
|
|
5
|
-
- PRUNE
|
|
6
|
-
- FACTORY FUNCTIONS
|
|
7
|
-
==============================================================
|
|
8
|
-
LITERALS
|
|
9
|
-
----------------------------------------------------------- */
|
|
10
|
-
import { Namespace } from "./functional/Namespace";
|
|
11
|
-
|
|
12
|
-
import { Atomic } from "./typings/Atomic";
|
|
13
|
-
|
|
14
|
-
import { IValidation } from "./IValidation";
|
|
15
|
-
import { Resolved } from "./Resolved";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* > You must configure the generic argument `T`.
|
|
19
|
-
*
|
|
20
|
-
* Union literal type to array.
|
|
21
|
-
*
|
|
22
|
-
* Converts a union literal type to an array of its members.
|
|
23
|
-
*
|
|
24
|
-
* ```typescript
|
|
25
|
-
* literals<"A" | "B" | 1>; // ["A", "B", 1]
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @template T Union literal type
|
|
29
|
-
* @return Array of union literal type's members
|
|
30
|
-
*
|
|
31
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
32
|
-
*/
|
|
33
|
-
export function literals(): never;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Union literal type to array.
|
|
37
|
-
*
|
|
38
|
-
* Converts a union literal type to an array of its members.
|
|
39
|
-
*
|
|
40
|
-
* ```typescript
|
|
41
|
-
* literals<"A" | "B" | 1>; // ["A", "B", 1]
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @template T Union literal type
|
|
45
|
-
* @return Array of union literal type's members
|
|
46
|
-
*
|
|
47
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
48
|
-
*/
|
|
49
|
-
export function literals<T extends Atomic.Type | null>(): T[];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
export function literals(): never {
|
|
55
|
-
halt("literals");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* -----------------------------------------------------------
|
|
59
|
-
CLONE
|
|
60
|
-
----------------------------------------------------------- */
|
|
61
|
-
/**
|
|
62
|
-
* Clone a data.
|
|
63
|
-
*
|
|
64
|
-
* Clones an instance following type `T`. If the target *input* value or its member
|
|
65
|
-
* variable contains a class instance having methods, those methods would not be
|
|
66
|
-
* cloned.
|
|
67
|
-
*
|
|
68
|
-
* For reference, this `typia.misc.clone()` function does not validate the input value
|
|
69
|
-
* type. It just believes that the input value is following the type `T`. Therefore,
|
|
70
|
-
* if you can't ensure the input value type, it would be better to call
|
|
71
|
-
* {@link assertClone} function instead.
|
|
72
|
-
*
|
|
73
|
-
* @template T Type of the input value
|
|
74
|
-
* @param input A value to be cloned
|
|
75
|
-
* @return Cloned data
|
|
76
|
-
*
|
|
77
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
78
|
-
*/
|
|
79
|
-
export function clone<T>(input: T): Resolved<T>;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @internal
|
|
83
|
-
*/
|
|
84
|
-
export function clone(): never {
|
|
85
|
-
halt("clone");
|
|
86
|
-
}
|
|
87
|
-
Object.assign(clone, Namespace.misc.clone("clone"));
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Clone a data with type assertion.
|
|
91
|
-
*
|
|
92
|
-
* Clones an instance following type `T`, with type assertion. If the target `input`
|
|
93
|
-
* value or its member variable contains a class instance having methods, those
|
|
94
|
-
* methods would not be cloned.
|
|
95
|
-
*
|
|
96
|
-
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
97
|
-
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
|
|
98
|
-
* data would be returned.
|
|
99
|
-
*
|
|
100
|
-
* @template T Type of the input value
|
|
101
|
-
* @param input A value to be cloned
|
|
102
|
-
* @return Cloned data
|
|
103
|
-
*
|
|
104
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
105
|
-
*/
|
|
106
|
-
export function assertClone<T>(input: T): Resolved<T>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Clone a data with type assertion.
|
|
110
|
-
*
|
|
111
|
-
* Clones an instance following type `T`, with type assertion. If the target `input`
|
|
112
|
-
* value or its member variable contains a class instance having methods, those
|
|
113
|
-
* methods would not be cloned.
|
|
114
|
-
*
|
|
115
|
-
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
116
|
-
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
|
|
117
|
-
* data would be returned.
|
|
118
|
-
*
|
|
119
|
-
* @template T Type of the input value
|
|
120
|
-
* @param input A value to be cloned
|
|
121
|
-
* @return Cloned data
|
|
122
|
-
*
|
|
123
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
124
|
-
*/
|
|
125
|
-
export function assertClone<T>(input: unknown): Resolved<T>;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @internal
|
|
129
|
-
*/
|
|
130
|
-
export function assertClone(): never {
|
|
131
|
-
halt("assertClone");
|
|
132
|
-
}
|
|
133
|
-
Object.assign(assertClone, Namespace.assert("assertClone"));
|
|
134
|
-
Object.assign(assertClone, Namespace.misc.clone("assertClone"));
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Clone a data with type checking.
|
|
138
|
-
*
|
|
139
|
-
* Clones an instance following type `T`, with type checking. If the target `input`
|
|
140
|
-
* value or its member variable contains a class instance having methods, those
|
|
141
|
-
* methods would not be cloned.
|
|
142
|
-
*
|
|
143
|
-
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
144
|
-
* `null` value instead. Otherwise, there's no problem on the `input` value, cloned
|
|
145
|
-
* data would be returned.
|
|
146
|
-
*
|
|
147
|
-
* @template T Type of the input value
|
|
148
|
-
* @param input A value to be cloned
|
|
149
|
-
* @return Cloned data when exact type, otherwise null
|
|
150
|
-
*
|
|
151
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
152
|
-
*/
|
|
153
|
-
export function isClone<T>(input: T): Resolved<T> | null;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Clone a data with type checking.
|
|
157
|
-
*
|
|
158
|
-
* Clones an instance following type `T`, with type checking. If the target `input`
|
|
159
|
-
* value or its member variable contains a class instance having methods, those
|
|
160
|
-
* methods would not be cloned.
|
|
161
|
-
*
|
|
162
|
-
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
163
|
-
* `null` value instead. Otherwise, there's no problem on the `input` value, cloned
|
|
164
|
-
* data would be returned.
|
|
165
|
-
*
|
|
166
|
-
* @template T Type of the input value
|
|
167
|
-
* @param input A value to be cloned
|
|
168
|
-
* @return Cloned data when exact type, otherwise null
|
|
169
|
-
*
|
|
170
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
171
|
-
*/
|
|
172
|
-
export function isClone<T>(input: unknown): Resolved<T> | null;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @internal
|
|
176
|
-
*/
|
|
177
|
-
export function isClone(): never {
|
|
178
|
-
halt("isClone");
|
|
179
|
-
}
|
|
180
|
-
Object.assign(isClone, Namespace.is());
|
|
181
|
-
Object.assign(isClone, Namespace.misc.clone("isClone"));
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Clone a data with detailed type validation.
|
|
185
|
-
*
|
|
186
|
-
* Clones an instance following type `T`, with detailed type validation. If the target
|
|
187
|
-
* `input` value or its member variable contains a class instance having methods,
|
|
188
|
-
* those methods would not be cloned.
|
|
189
|
-
*
|
|
190
|
-
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
191
|
-
* {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
|
|
192
|
-
* value, cloned data would be stored in `data` property of the output
|
|
193
|
-
* {@link IValidation.Success} instance.
|
|
194
|
-
*
|
|
195
|
-
* @template T Type of the input value
|
|
196
|
-
* @param input A value to be cloned
|
|
197
|
-
* @returns Validation result with cloned value
|
|
198
|
-
*/
|
|
199
|
-
export function validateClone<T>(input: T): IValidation<Resolved<T>>;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Clone a data with detailed type validation.
|
|
203
|
-
*
|
|
204
|
-
* Clones an instance following type `T`, with detailed type validation. If the target
|
|
205
|
-
* `input` value or its member variable contains a class instance having methods,
|
|
206
|
-
* those methods would not be cloned.
|
|
207
|
-
*
|
|
208
|
-
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
209
|
-
* {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
|
|
210
|
-
* value, cloned data would be stored in `data` property of the output
|
|
211
|
-
* {@link IValidation.Success} instance.
|
|
212
|
-
*
|
|
213
|
-
* @template T Type of the input value
|
|
214
|
-
* @param input A value to be cloned
|
|
215
|
-
* @returns Validation result with cloned value
|
|
216
|
-
*/
|
|
217
|
-
export function validateClone<T>(input: unknown): IValidation<Resolved<T>>;
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* @internal
|
|
221
|
-
*/
|
|
222
|
-
export function validateClone(): never {
|
|
223
|
-
halt("validateClone");
|
|
224
|
-
}
|
|
225
|
-
Object.assign(validateClone, Namespace.validate());
|
|
226
|
-
Object.assign(validateClone, Namespace.misc.clone("validateClone"));
|
|
227
|
-
|
|
228
|
-
/* -----------------------------------------------------------
|
|
229
|
-
PRUNE
|
|
230
|
-
----------------------------------------------------------- */
|
|
231
|
-
/**
|
|
232
|
-
* Prune, erase superfluous properties.
|
|
233
|
-
*
|
|
234
|
-
* Remove every superfluous properties from the `input` object, even including nested
|
|
235
|
-
* objects. Note that, as every superfluous properties would be deleted, you never can
|
|
236
|
-
* read those superfluous properties after calling this `prune()` function.
|
|
237
|
-
*
|
|
238
|
-
* For reference, this `typia.misc.prune()` function does not validate the input value
|
|
239
|
-
* type. It just believes that the input value is following the type `T`. Therefore,
|
|
240
|
-
* if you can't ensure the input value type, it would better to call one of below
|
|
241
|
-
* functions instead.
|
|
242
|
-
*
|
|
243
|
-
* - {@link assertPrune}
|
|
244
|
-
* - {@link isPrune}
|
|
245
|
-
* - {@link validatePrune}
|
|
246
|
-
*
|
|
247
|
-
* @template T Type of the input value
|
|
248
|
-
* @param input Target instance to prune
|
|
249
|
-
*
|
|
250
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
251
|
-
*/
|
|
252
|
-
export function prune<T extends object>(input: T): void;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* @internal
|
|
256
|
-
*/
|
|
257
|
-
export function prune(): never {
|
|
258
|
-
halt("prune");
|
|
259
|
-
}
|
|
260
|
-
Object.assign(prune, Namespace.misc.prune("prune"));
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Prune, erase superfluous properties, with type assertion.
|
|
264
|
-
*
|
|
265
|
-
* `typia.misc.assertPrune()` is a combination function of {@link assert} and
|
|
266
|
-
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
267
|
-
* object including nested objects, with type assertion.
|
|
268
|
-
*
|
|
269
|
-
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
270
|
-
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
|
|
271
|
-
* every superfluous properties would be removed, including nested objects.
|
|
272
|
-
*
|
|
273
|
-
* @template T Type of the input value
|
|
274
|
-
* @param input Target instance to assert and prune
|
|
275
|
-
*
|
|
276
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
277
|
-
*/
|
|
278
|
-
export function assertPrune<T>(input: T): T;
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Prune, erase superfluous properties, with type assertion.
|
|
282
|
-
*
|
|
283
|
-
* `typia.misc.assertPrune()` is a combination function of {@link assert} and
|
|
284
|
-
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
285
|
-
* object including nested objects, with type assertion.
|
|
286
|
-
*
|
|
287
|
-
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
288
|
-
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
|
|
289
|
-
* every superfluous properties would be removed, including nested objects.
|
|
290
|
-
*
|
|
291
|
-
* @template T Type of the input value
|
|
292
|
-
* @param input Target instance to assert and prune
|
|
293
|
-
*
|
|
294
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
295
|
-
*/
|
|
296
|
-
export function assertPrune<T>(input: unknown): T;
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* @internal
|
|
300
|
-
*/
|
|
301
|
-
export function assertPrune(): unknown {
|
|
302
|
-
halt("assertPrune");
|
|
303
|
-
}
|
|
304
|
-
Object.assign(assertPrune, Namespace.assert("assertPrune"));
|
|
305
|
-
Object.assign(assertPrune, Namespace.misc.prune("assertPrune"));
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Prune, erase superfluous properties, with type checking.
|
|
309
|
-
*
|
|
310
|
-
* `typia.misc.assertPrune()` is a combination function of {@link is} and
|
|
311
|
-
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
312
|
-
* object including nested objects, with type checking.
|
|
313
|
-
*
|
|
314
|
-
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
315
|
-
* `false` value. Otherwise, there's no problem on the `input` value, it returns
|
|
316
|
-
* `true` after removing every superfluous properties, including nested objects.
|
|
317
|
-
*
|
|
318
|
-
* @template T Type of the input value
|
|
319
|
-
* @param input Target instance to check and prune
|
|
320
|
-
* @returns Whether the parametric value is following the type `T` or not
|
|
321
|
-
*
|
|
322
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
323
|
-
*/
|
|
324
|
-
export function isPrune<T>(input: T): input is T;
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Prune, erase superfluous properties, with type checking.
|
|
328
|
-
*
|
|
329
|
-
* `typia.misc.assertPrune()` is a combination function of {@link is} and
|
|
330
|
-
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
331
|
-
* object including nested objects, with type checking.
|
|
332
|
-
*
|
|
333
|
-
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
334
|
-
* `false` value. Otherwise, there's no problem on the `input` value, it returns
|
|
335
|
-
* `true` after removing every superfluous properties, including nested objects.
|
|
336
|
-
*
|
|
337
|
-
* @template T Type of the input value
|
|
338
|
-
* @param input Target instance to check and prune
|
|
339
|
-
* @returns Whether the parametric value is following the type `T` or not
|
|
340
|
-
*
|
|
341
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
342
|
-
*/
|
|
343
|
-
export function isPrune<T>(input: unknown): input is T;
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* @internal
|
|
347
|
-
*/
|
|
348
|
-
export function isPrune(): never {
|
|
349
|
-
halt("isPrune");
|
|
350
|
-
}
|
|
351
|
-
Object.assign(isPrune, Namespace.is());
|
|
352
|
-
Object.assign(isPrune, Namespace.misc.prune("isPrune"));
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Prune, erase superfluous properties, with type validation.
|
|
356
|
-
*
|
|
357
|
-
* `typia.misc.validatePrune()` is a combination function of {@link validate} and
|
|
358
|
-
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
359
|
-
* object including nested objects, with type validation.
|
|
360
|
-
*
|
|
361
|
-
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
362
|
-
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
|
|
363
|
-
* no problem on the `input` value, it returns {@link IValidation.ISucess} value after
|
|
364
|
-
* removing every superfluous properties, including nested objects.
|
|
365
|
-
*
|
|
366
|
-
* @template T Type of the input value
|
|
367
|
-
* @param input Target instance to validate and prune
|
|
368
|
-
* @returns Validation result
|
|
369
|
-
*
|
|
370
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
371
|
-
*/
|
|
372
|
-
export function validatePrune<T>(input: T): IValidation<T>;
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Prune, erase superfluous properties, with type validation.
|
|
376
|
-
*
|
|
377
|
-
* `typia.misc.validatePrune()` is a combination function of {@link validate} and
|
|
378
|
-
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
379
|
-
* object including nested objects, with type validation.
|
|
380
|
-
*
|
|
381
|
-
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
382
|
-
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
|
|
383
|
-
* no problem on the `input` value, it returns {@link IValidation.ISucess} value after
|
|
384
|
-
* removing every superfluous properties, including nested objects.
|
|
385
|
-
*
|
|
386
|
-
* @template T Type of the input value
|
|
387
|
-
* @param input Target instance to validate and prune
|
|
388
|
-
* @returns Validation result
|
|
389
|
-
*
|
|
390
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
391
|
-
*/
|
|
392
|
-
export function validatePrune<T>(input: unknown): IValidation<T>;
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* @internal
|
|
396
|
-
*/
|
|
397
|
-
export function validatePrune<T>(): IValidation<T> {
|
|
398
|
-
halt("validatePrune");
|
|
399
|
-
}
|
|
400
|
-
Object.assign(validatePrune, Namespace.misc.prune("validatePrune"));
|
|
401
|
-
Object.assign(validatePrune, Namespace.validate());
|
|
402
|
-
|
|
403
|
-
/* -----------------------------------------------------------
|
|
404
|
-
FACTORY FUNCTIONS
|
|
405
|
-
----------------------------------------------------------- */
|
|
406
|
-
/**
|
|
407
|
-
* Creates a reusable {@link clone} function.
|
|
408
|
-
*
|
|
409
|
-
* @danger You must configure the generic argument `T`
|
|
410
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
411
|
-
* @throws compile error
|
|
412
|
-
*
|
|
413
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
414
|
-
*/
|
|
415
|
-
export function createClone(): never;
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* Creates a resuable {@link clone} function.
|
|
419
|
-
*
|
|
420
|
-
* @template T Type of the input value
|
|
421
|
-
* @returns A reusable `clone` function
|
|
422
|
-
*
|
|
423
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
424
|
-
*/
|
|
425
|
-
export function createClone<T>(): (input: T) => Resolved<T>;
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* @internal
|
|
429
|
-
*/
|
|
430
|
-
export function createClone(): never {
|
|
431
|
-
halt("createClone");
|
|
432
|
-
}
|
|
433
|
-
Object.assign(createClone, clone);
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Creates a reusable {@link assertClone} function.
|
|
437
|
-
*
|
|
438
|
-
* @danger You must configure the generic argument `T`
|
|
439
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
440
|
-
* @throws compile error
|
|
441
|
-
*
|
|
442
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
443
|
-
*/
|
|
444
|
-
export function createAssertClone(): never;
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Creates a resuable {@link assertClone} function.
|
|
448
|
-
*
|
|
449
|
-
* @template T Type of the input value
|
|
450
|
-
* @returns A reusable `clone` function
|
|
451
|
-
*
|
|
452
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
453
|
-
*/
|
|
454
|
-
export function createAssertClone<T>(): (input: unknown) => Resolved<T>;
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* @internal
|
|
458
|
-
*/
|
|
459
|
-
export function createAssertClone(): never {
|
|
460
|
-
halt("createAssertClone");
|
|
461
|
-
}
|
|
462
|
-
Object.assign(createAssertClone, assertClone);
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Creates a reusable {@link isClone} function.
|
|
466
|
-
*
|
|
467
|
-
* @danger You must configure the generic argument `T`
|
|
468
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
469
|
-
* @throws compile error
|
|
470
|
-
*
|
|
471
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
472
|
-
*/
|
|
473
|
-
export function createIsClone(): never;
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Creates a resuable {@link isClone} function.
|
|
477
|
-
*
|
|
478
|
-
* @template T Type of the input value
|
|
479
|
-
* @returns A reusable `clone` function
|
|
480
|
-
*
|
|
481
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
482
|
-
*/
|
|
483
|
-
export function createIsClone<T>(): (input: unknown) => Resolved<T> | null;
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* @internal
|
|
487
|
-
*/
|
|
488
|
-
export function createIsClone(): never {
|
|
489
|
-
halt("createIsClone");
|
|
490
|
-
}
|
|
491
|
-
Object.assign(createIsClone, isClone);
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Creates a reusable {@link validateClone} function.
|
|
495
|
-
*
|
|
496
|
-
* @danger You must configure the generic argument `T`
|
|
497
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
498
|
-
* @throws compile error
|
|
499
|
-
*
|
|
500
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
501
|
-
*/
|
|
502
|
-
export function createValidateClone(): never;
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Creates a resuable {@link validateClone} function.
|
|
506
|
-
*
|
|
507
|
-
* @template T Type of the input value
|
|
508
|
-
* @returns A reusable `clone` function
|
|
509
|
-
*
|
|
510
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
511
|
-
*/
|
|
512
|
-
export function createValidateClone<T>(): (
|
|
513
|
-
input: unknown,
|
|
514
|
-
) => IValidation<Resolved<T>>;
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* @internal
|
|
518
|
-
*/
|
|
519
|
-
export function createValidateClone(): never {
|
|
520
|
-
halt("createValidateClone");
|
|
521
|
-
}
|
|
522
|
-
Object.assign(createValidateClone, validateClone);
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Creates a reusable {@link prune} function.
|
|
526
|
-
*
|
|
527
|
-
* @danger You must configure the generic argument `T`
|
|
528
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
529
|
-
* @throws compile error
|
|
530
|
-
*
|
|
531
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
532
|
-
*/
|
|
533
|
-
export function createPrune(): never;
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Creates a resuable {@link prune} function.
|
|
537
|
-
*
|
|
538
|
-
* @template T Type of the input value
|
|
539
|
-
* @returns A reusable `prune` function
|
|
540
|
-
*
|
|
541
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
542
|
-
*/
|
|
543
|
-
export function createPrune<T extends object>(): (input: T) => void;
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* @internal
|
|
547
|
-
*/
|
|
548
|
-
export function createPrune<T extends object>(): (input: T) => void {
|
|
549
|
-
halt("createPrune");
|
|
550
|
-
}
|
|
551
|
-
Object.assign(createPrune, prune);
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* Creates a reusable {@link assertPrune} function.
|
|
555
|
-
*
|
|
556
|
-
* @danger You must configure the generic argument `T`
|
|
557
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
558
|
-
* @throws compile error
|
|
559
|
-
*
|
|
560
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
561
|
-
*/
|
|
562
|
-
export function createAssertPrune(): never;
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Creates a resuable {@link assertPrune} function.
|
|
566
|
-
*
|
|
567
|
-
* @template T Type of the input value
|
|
568
|
-
* @returns A reusable `isPrune` function
|
|
569
|
-
*
|
|
570
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
571
|
-
*/
|
|
572
|
-
export function createAssertPrune<T extends object>(): (input: T) => T;
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* @internal
|
|
576
|
-
*/
|
|
577
|
-
export function createAssertPrune<T extends object>(): (input: T) => T {
|
|
578
|
-
halt("createAssertPrune");
|
|
579
|
-
}
|
|
580
|
-
Object.assign(createAssertPrune, assertPrune);
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Creates a reusable {@link isPrune} function.
|
|
584
|
-
*
|
|
585
|
-
* @danger You must configure the generic argument `T`
|
|
586
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
587
|
-
* @throws compile error
|
|
588
|
-
*
|
|
589
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
590
|
-
*/
|
|
591
|
-
export function createIsPrune(): never;
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Creates a resuable {@link isPrune} function.
|
|
595
|
-
*
|
|
596
|
-
* @template T Type of the input value
|
|
597
|
-
* @returns A reusable `isPrune` function
|
|
598
|
-
*
|
|
599
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
600
|
-
*/
|
|
601
|
-
export function createIsPrune<T extends object>(): (input: T) => input is T;
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* @internal
|
|
605
|
-
*/
|
|
606
|
-
export function createIsPrune<T extends object>(): (input: T) => input is T {
|
|
607
|
-
halt("createIsPrune");
|
|
608
|
-
}
|
|
609
|
-
Object.assign(createIsPrune, isPrune);
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Creates a reusable {@link validatePrune} function.
|
|
613
|
-
*
|
|
614
|
-
* @danger You must configure the generic argument `T`
|
|
615
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
616
|
-
* @throws compile error
|
|
617
|
-
*
|
|
618
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
619
|
-
*/
|
|
620
|
-
export function createValidatePrune(): never;
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* Creates a resuable {@link validatePrune} function.
|
|
624
|
-
*
|
|
625
|
-
* @template T Type of the input value
|
|
626
|
-
* @returns A reusable `validatePrune` function
|
|
627
|
-
*
|
|
628
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
629
|
-
*/
|
|
630
|
-
export function createValidatePrune<T extends object>(): (
|
|
631
|
-
input: T,
|
|
632
|
-
) => IValidation<T>;
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* @internal
|
|
636
|
-
*/
|
|
637
|
-
export function createValidatePrune<T extends object>(): (
|
|
638
|
-
input: T,
|
|
639
|
-
) => IValidation<T> {
|
|
640
|
-
halt("createValidatePrune");
|
|
641
|
-
}
|
|
642
|
-
Object.assign(createValidatePrune, validatePrune);
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* @internal
|
|
646
|
-
*/
|
|
647
|
-
function halt(name: string): never {
|
|
648
|
-
throw new Error(
|
|
649
|
-
`Error on typia.misc.${name}(): no transform has been configured. Read and follow https://typia.misc.io/docs/setup please.`,
|
|
650
|
-
);
|
|
651
|
-
}
|
|
1
|
+
/* ===========================================================
|
|
2
|
+
MISCELLAENOUS
|
|
3
|
+
- LITERALS
|
|
4
|
+
- CLONE
|
|
5
|
+
- PRUNE
|
|
6
|
+
- FACTORY FUNCTIONS
|
|
7
|
+
==============================================================
|
|
8
|
+
LITERALS
|
|
9
|
+
----------------------------------------------------------- */
|
|
10
|
+
import { Namespace } from "./functional/Namespace";
|
|
11
|
+
|
|
12
|
+
import { Atomic } from "./typings/Atomic";
|
|
13
|
+
|
|
14
|
+
import { IValidation } from "./IValidation";
|
|
15
|
+
import { Resolved } from "./Resolved";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* > You must configure the generic argument `T`.
|
|
19
|
+
*
|
|
20
|
+
* Union literal type to array.
|
|
21
|
+
*
|
|
22
|
+
* Converts a union literal type to an array of its members.
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* literals<"A" | "B" | 1>; // ["A", "B", 1]
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @template T Union literal type
|
|
29
|
+
* @return Array of union literal type's members
|
|
30
|
+
*
|
|
31
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
32
|
+
*/
|
|
33
|
+
export function literals(): never;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Union literal type to array.
|
|
37
|
+
*
|
|
38
|
+
* Converts a union literal type to an array of its members.
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* literals<"A" | "B" | 1>; // ["A", "B", 1]
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @template T Union literal type
|
|
45
|
+
* @return Array of union literal type's members
|
|
46
|
+
*
|
|
47
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
48
|
+
*/
|
|
49
|
+
export function literals<T extends Atomic.Type | null>(): T[];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export function literals(): never {
|
|
55
|
+
halt("literals");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* -----------------------------------------------------------
|
|
59
|
+
CLONE
|
|
60
|
+
----------------------------------------------------------- */
|
|
61
|
+
/**
|
|
62
|
+
* Clone a data.
|
|
63
|
+
*
|
|
64
|
+
* Clones an instance following type `T`. If the target *input* value or its member
|
|
65
|
+
* variable contains a class instance having methods, those methods would not be
|
|
66
|
+
* cloned.
|
|
67
|
+
*
|
|
68
|
+
* For reference, this `typia.misc.clone()` function does not validate the input value
|
|
69
|
+
* type. It just believes that the input value is following the type `T`. Therefore,
|
|
70
|
+
* if you can't ensure the input value type, it would be better to call
|
|
71
|
+
* {@link assertClone} function instead.
|
|
72
|
+
*
|
|
73
|
+
* @template T Type of the input value
|
|
74
|
+
* @param input A value to be cloned
|
|
75
|
+
* @return Cloned data
|
|
76
|
+
*
|
|
77
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
78
|
+
*/
|
|
79
|
+
export function clone<T>(input: T): Resolved<T>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export function clone(): never {
|
|
85
|
+
halt("clone");
|
|
86
|
+
}
|
|
87
|
+
Object.assign(clone, Namespace.misc.clone("clone"));
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Clone a data with type assertion.
|
|
91
|
+
*
|
|
92
|
+
* Clones an instance following type `T`, with type assertion. If the target `input`
|
|
93
|
+
* value or its member variable contains a class instance having methods, those
|
|
94
|
+
* methods would not be cloned.
|
|
95
|
+
*
|
|
96
|
+
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
97
|
+
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
|
|
98
|
+
* data would be returned.
|
|
99
|
+
*
|
|
100
|
+
* @template T Type of the input value
|
|
101
|
+
* @param input A value to be cloned
|
|
102
|
+
* @return Cloned data
|
|
103
|
+
*
|
|
104
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
105
|
+
*/
|
|
106
|
+
export function assertClone<T>(input: T): Resolved<T>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Clone a data with type assertion.
|
|
110
|
+
*
|
|
111
|
+
* Clones an instance following type `T`, with type assertion. If the target `input`
|
|
112
|
+
* value or its member variable contains a class instance having methods, those
|
|
113
|
+
* methods would not be cloned.
|
|
114
|
+
*
|
|
115
|
+
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
116
|
+
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
|
|
117
|
+
* data would be returned.
|
|
118
|
+
*
|
|
119
|
+
* @template T Type of the input value
|
|
120
|
+
* @param input A value to be cloned
|
|
121
|
+
* @return Cloned data
|
|
122
|
+
*
|
|
123
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
124
|
+
*/
|
|
125
|
+
export function assertClone<T>(input: unknown): Resolved<T>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
export function assertClone(): never {
|
|
131
|
+
halt("assertClone");
|
|
132
|
+
}
|
|
133
|
+
Object.assign(assertClone, Namespace.assert("assertClone"));
|
|
134
|
+
Object.assign(assertClone, Namespace.misc.clone("assertClone"));
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Clone a data with type checking.
|
|
138
|
+
*
|
|
139
|
+
* Clones an instance following type `T`, with type checking. If the target `input`
|
|
140
|
+
* value or its member variable contains a class instance having methods, those
|
|
141
|
+
* methods would not be cloned.
|
|
142
|
+
*
|
|
143
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
144
|
+
* `null` value instead. Otherwise, there's no problem on the `input` value, cloned
|
|
145
|
+
* data would be returned.
|
|
146
|
+
*
|
|
147
|
+
* @template T Type of the input value
|
|
148
|
+
* @param input A value to be cloned
|
|
149
|
+
* @return Cloned data when exact type, otherwise null
|
|
150
|
+
*
|
|
151
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
152
|
+
*/
|
|
153
|
+
export function isClone<T>(input: T): Resolved<T> | null;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Clone a data with type checking.
|
|
157
|
+
*
|
|
158
|
+
* Clones an instance following type `T`, with type checking. If the target `input`
|
|
159
|
+
* value or its member variable contains a class instance having methods, those
|
|
160
|
+
* methods would not be cloned.
|
|
161
|
+
*
|
|
162
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
163
|
+
* `null` value instead. Otherwise, there's no problem on the `input` value, cloned
|
|
164
|
+
* data would be returned.
|
|
165
|
+
*
|
|
166
|
+
* @template T Type of the input value
|
|
167
|
+
* @param input A value to be cloned
|
|
168
|
+
* @return Cloned data when exact type, otherwise null
|
|
169
|
+
*
|
|
170
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
171
|
+
*/
|
|
172
|
+
export function isClone<T>(input: unknown): Resolved<T> | null;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @internal
|
|
176
|
+
*/
|
|
177
|
+
export function isClone(): never {
|
|
178
|
+
halt("isClone");
|
|
179
|
+
}
|
|
180
|
+
Object.assign(isClone, Namespace.is());
|
|
181
|
+
Object.assign(isClone, Namespace.misc.clone("isClone"));
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Clone a data with detailed type validation.
|
|
185
|
+
*
|
|
186
|
+
* Clones an instance following type `T`, with detailed type validation. If the target
|
|
187
|
+
* `input` value or its member variable contains a class instance having methods,
|
|
188
|
+
* those methods would not be cloned.
|
|
189
|
+
*
|
|
190
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
191
|
+
* {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
|
|
192
|
+
* value, cloned data would be stored in `data` property of the output
|
|
193
|
+
* {@link IValidation.Success} instance.
|
|
194
|
+
*
|
|
195
|
+
* @template T Type of the input value
|
|
196
|
+
* @param input A value to be cloned
|
|
197
|
+
* @returns Validation result with cloned value
|
|
198
|
+
*/
|
|
199
|
+
export function validateClone<T>(input: T): IValidation<Resolved<T>>;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Clone a data with detailed type validation.
|
|
203
|
+
*
|
|
204
|
+
* Clones an instance following type `T`, with detailed type validation. If the target
|
|
205
|
+
* `input` value or its member variable contains a class instance having methods,
|
|
206
|
+
* those methods would not be cloned.
|
|
207
|
+
*
|
|
208
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
209
|
+
* {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
|
|
210
|
+
* value, cloned data would be stored in `data` property of the output
|
|
211
|
+
* {@link IValidation.Success} instance.
|
|
212
|
+
*
|
|
213
|
+
* @template T Type of the input value
|
|
214
|
+
* @param input A value to be cloned
|
|
215
|
+
* @returns Validation result with cloned value
|
|
216
|
+
*/
|
|
217
|
+
export function validateClone<T>(input: unknown): IValidation<Resolved<T>>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
222
|
+
export function validateClone(): never {
|
|
223
|
+
halt("validateClone");
|
|
224
|
+
}
|
|
225
|
+
Object.assign(validateClone, Namespace.validate());
|
|
226
|
+
Object.assign(validateClone, Namespace.misc.clone("validateClone"));
|
|
227
|
+
|
|
228
|
+
/* -----------------------------------------------------------
|
|
229
|
+
PRUNE
|
|
230
|
+
----------------------------------------------------------- */
|
|
231
|
+
/**
|
|
232
|
+
* Prune, erase superfluous properties.
|
|
233
|
+
*
|
|
234
|
+
* Remove every superfluous properties from the `input` object, even including nested
|
|
235
|
+
* objects. Note that, as every superfluous properties would be deleted, you never can
|
|
236
|
+
* read those superfluous properties after calling this `prune()` function.
|
|
237
|
+
*
|
|
238
|
+
* For reference, this `typia.misc.prune()` function does not validate the input value
|
|
239
|
+
* type. It just believes that the input value is following the type `T`. Therefore,
|
|
240
|
+
* if you can't ensure the input value type, it would better to call one of below
|
|
241
|
+
* functions instead.
|
|
242
|
+
*
|
|
243
|
+
* - {@link assertPrune}
|
|
244
|
+
* - {@link isPrune}
|
|
245
|
+
* - {@link validatePrune}
|
|
246
|
+
*
|
|
247
|
+
* @template T Type of the input value
|
|
248
|
+
* @param input Target instance to prune
|
|
249
|
+
*
|
|
250
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
251
|
+
*/
|
|
252
|
+
export function prune<T extends object>(input: T): void;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @internal
|
|
256
|
+
*/
|
|
257
|
+
export function prune(): never {
|
|
258
|
+
halt("prune");
|
|
259
|
+
}
|
|
260
|
+
Object.assign(prune, Namespace.misc.prune("prune"));
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Prune, erase superfluous properties, with type assertion.
|
|
264
|
+
*
|
|
265
|
+
* `typia.misc.assertPrune()` is a combination function of {@link assert} and
|
|
266
|
+
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
267
|
+
* object including nested objects, with type assertion.
|
|
268
|
+
*
|
|
269
|
+
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
270
|
+
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
|
|
271
|
+
* every superfluous properties would be removed, including nested objects.
|
|
272
|
+
*
|
|
273
|
+
* @template T Type of the input value
|
|
274
|
+
* @param input Target instance to assert and prune
|
|
275
|
+
*
|
|
276
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
277
|
+
*/
|
|
278
|
+
export function assertPrune<T>(input: T): T;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Prune, erase superfluous properties, with type assertion.
|
|
282
|
+
*
|
|
283
|
+
* `typia.misc.assertPrune()` is a combination function of {@link assert} and
|
|
284
|
+
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
285
|
+
* object including nested objects, with type assertion.
|
|
286
|
+
*
|
|
287
|
+
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
288
|
+
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
|
|
289
|
+
* every superfluous properties would be removed, including nested objects.
|
|
290
|
+
*
|
|
291
|
+
* @template T Type of the input value
|
|
292
|
+
* @param input Target instance to assert and prune
|
|
293
|
+
*
|
|
294
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
295
|
+
*/
|
|
296
|
+
export function assertPrune<T>(input: unknown): T;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @internal
|
|
300
|
+
*/
|
|
301
|
+
export function assertPrune(): unknown {
|
|
302
|
+
halt("assertPrune");
|
|
303
|
+
}
|
|
304
|
+
Object.assign(assertPrune, Namespace.assert("assertPrune"));
|
|
305
|
+
Object.assign(assertPrune, Namespace.misc.prune("assertPrune"));
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Prune, erase superfluous properties, with type checking.
|
|
309
|
+
*
|
|
310
|
+
* `typia.misc.assertPrune()` is a combination function of {@link is} and
|
|
311
|
+
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
312
|
+
* object including nested objects, with type checking.
|
|
313
|
+
*
|
|
314
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
315
|
+
* `false` value. Otherwise, there's no problem on the `input` value, it returns
|
|
316
|
+
* `true` after removing every superfluous properties, including nested objects.
|
|
317
|
+
*
|
|
318
|
+
* @template T Type of the input value
|
|
319
|
+
* @param input Target instance to check and prune
|
|
320
|
+
* @returns Whether the parametric value is following the type `T` or not
|
|
321
|
+
*
|
|
322
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
323
|
+
*/
|
|
324
|
+
export function isPrune<T>(input: T): input is T;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Prune, erase superfluous properties, with type checking.
|
|
328
|
+
*
|
|
329
|
+
* `typia.misc.assertPrune()` is a combination function of {@link is} and
|
|
330
|
+
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
331
|
+
* object including nested objects, with type checking.
|
|
332
|
+
*
|
|
333
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
334
|
+
* `false` value. Otherwise, there's no problem on the `input` value, it returns
|
|
335
|
+
* `true` after removing every superfluous properties, including nested objects.
|
|
336
|
+
*
|
|
337
|
+
* @template T Type of the input value
|
|
338
|
+
* @param input Target instance to check and prune
|
|
339
|
+
* @returns Whether the parametric value is following the type `T` or not
|
|
340
|
+
*
|
|
341
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
342
|
+
*/
|
|
343
|
+
export function isPrune<T>(input: unknown): input is T;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* @internal
|
|
347
|
+
*/
|
|
348
|
+
export function isPrune(): never {
|
|
349
|
+
halt("isPrune");
|
|
350
|
+
}
|
|
351
|
+
Object.assign(isPrune, Namespace.is());
|
|
352
|
+
Object.assign(isPrune, Namespace.misc.prune("isPrune"));
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Prune, erase superfluous properties, with type validation.
|
|
356
|
+
*
|
|
357
|
+
* `typia.misc.validatePrune()` is a combination function of {@link validate} and
|
|
358
|
+
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
359
|
+
* object including nested objects, with type validation.
|
|
360
|
+
*
|
|
361
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
362
|
+
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
|
|
363
|
+
* no problem on the `input` value, it returns {@link IValidation.ISucess} value after
|
|
364
|
+
* removing every superfluous properties, including nested objects.
|
|
365
|
+
*
|
|
366
|
+
* @template T Type of the input value
|
|
367
|
+
* @param input Target instance to validate and prune
|
|
368
|
+
* @returns Validation result
|
|
369
|
+
*
|
|
370
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
371
|
+
*/
|
|
372
|
+
export function validatePrune<T>(input: T): IValidation<T>;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Prune, erase superfluous properties, with type validation.
|
|
376
|
+
*
|
|
377
|
+
* `typia.misc.validatePrune()` is a combination function of {@link validate} and
|
|
378
|
+
* {@link prune}. Therefore, it removes every superfluous properties from the `input`
|
|
379
|
+
* object including nested objects, with type validation.
|
|
380
|
+
*
|
|
381
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
382
|
+
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
|
|
383
|
+
* no problem on the `input` value, it returns {@link IValidation.ISucess} value after
|
|
384
|
+
* removing every superfluous properties, including nested objects.
|
|
385
|
+
*
|
|
386
|
+
* @template T Type of the input value
|
|
387
|
+
* @param input Target instance to validate and prune
|
|
388
|
+
* @returns Validation result
|
|
389
|
+
*
|
|
390
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
391
|
+
*/
|
|
392
|
+
export function validatePrune<T>(input: unknown): IValidation<T>;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* @internal
|
|
396
|
+
*/
|
|
397
|
+
export function validatePrune<T>(): IValidation<T> {
|
|
398
|
+
halt("validatePrune");
|
|
399
|
+
}
|
|
400
|
+
Object.assign(validatePrune, Namespace.misc.prune("validatePrune"));
|
|
401
|
+
Object.assign(validatePrune, Namespace.validate());
|
|
402
|
+
|
|
403
|
+
/* -----------------------------------------------------------
|
|
404
|
+
FACTORY FUNCTIONS
|
|
405
|
+
----------------------------------------------------------- */
|
|
406
|
+
/**
|
|
407
|
+
* Creates a reusable {@link clone} function.
|
|
408
|
+
*
|
|
409
|
+
* @danger You must configure the generic argument `T`
|
|
410
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
411
|
+
* @throws compile error
|
|
412
|
+
*
|
|
413
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
414
|
+
*/
|
|
415
|
+
export function createClone(): never;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Creates a resuable {@link clone} function.
|
|
419
|
+
*
|
|
420
|
+
* @template T Type of the input value
|
|
421
|
+
* @returns A reusable `clone` function
|
|
422
|
+
*
|
|
423
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
424
|
+
*/
|
|
425
|
+
export function createClone<T>(): (input: T) => Resolved<T>;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @internal
|
|
429
|
+
*/
|
|
430
|
+
export function createClone(): never {
|
|
431
|
+
halt("createClone");
|
|
432
|
+
}
|
|
433
|
+
Object.assign(createClone, clone);
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Creates a reusable {@link assertClone} function.
|
|
437
|
+
*
|
|
438
|
+
* @danger You must configure the generic argument `T`
|
|
439
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
440
|
+
* @throws compile error
|
|
441
|
+
*
|
|
442
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
443
|
+
*/
|
|
444
|
+
export function createAssertClone(): never;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Creates a resuable {@link assertClone} function.
|
|
448
|
+
*
|
|
449
|
+
* @template T Type of the input value
|
|
450
|
+
* @returns A reusable `clone` function
|
|
451
|
+
*
|
|
452
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
453
|
+
*/
|
|
454
|
+
export function createAssertClone<T>(): (input: unknown) => Resolved<T>;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @internal
|
|
458
|
+
*/
|
|
459
|
+
export function createAssertClone(): never {
|
|
460
|
+
halt("createAssertClone");
|
|
461
|
+
}
|
|
462
|
+
Object.assign(createAssertClone, assertClone);
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Creates a reusable {@link isClone} function.
|
|
466
|
+
*
|
|
467
|
+
* @danger You must configure the generic argument `T`
|
|
468
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
469
|
+
* @throws compile error
|
|
470
|
+
*
|
|
471
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
472
|
+
*/
|
|
473
|
+
export function createIsClone(): never;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Creates a resuable {@link isClone} function.
|
|
477
|
+
*
|
|
478
|
+
* @template T Type of the input value
|
|
479
|
+
* @returns A reusable `clone` function
|
|
480
|
+
*
|
|
481
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
482
|
+
*/
|
|
483
|
+
export function createIsClone<T>(): (input: unknown) => Resolved<T> | null;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* @internal
|
|
487
|
+
*/
|
|
488
|
+
export function createIsClone(): never {
|
|
489
|
+
halt("createIsClone");
|
|
490
|
+
}
|
|
491
|
+
Object.assign(createIsClone, isClone);
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Creates a reusable {@link validateClone} function.
|
|
495
|
+
*
|
|
496
|
+
* @danger You must configure the generic argument `T`
|
|
497
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
498
|
+
* @throws compile error
|
|
499
|
+
*
|
|
500
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
501
|
+
*/
|
|
502
|
+
export function createValidateClone(): never;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Creates a resuable {@link validateClone} function.
|
|
506
|
+
*
|
|
507
|
+
* @template T Type of the input value
|
|
508
|
+
* @returns A reusable `clone` function
|
|
509
|
+
*
|
|
510
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
511
|
+
*/
|
|
512
|
+
export function createValidateClone<T>(): (
|
|
513
|
+
input: unknown,
|
|
514
|
+
) => IValidation<Resolved<T>>;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* @internal
|
|
518
|
+
*/
|
|
519
|
+
export function createValidateClone(): never {
|
|
520
|
+
halt("createValidateClone");
|
|
521
|
+
}
|
|
522
|
+
Object.assign(createValidateClone, validateClone);
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Creates a reusable {@link prune} function.
|
|
526
|
+
*
|
|
527
|
+
* @danger You must configure the generic argument `T`
|
|
528
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
529
|
+
* @throws compile error
|
|
530
|
+
*
|
|
531
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
532
|
+
*/
|
|
533
|
+
export function createPrune(): never;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Creates a resuable {@link prune} function.
|
|
537
|
+
*
|
|
538
|
+
* @template T Type of the input value
|
|
539
|
+
* @returns A reusable `prune` function
|
|
540
|
+
*
|
|
541
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
542
|
+
*/
|
|
543
|
+
export function createPrune<T extends object>(): (input: T) => void;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* @internal
|
|
547
|
+
*/
|
|
548
|
+
export function createPrune<T extends object>(): (input: T) => void {
|
|
549
|
+
halt("createPrune");
|
|
550
|
+
}
|
|
551
|
+
Object.assign(createPrune, prune);
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Creates a reusable {@link assertPrune} function.
|
|
555
|
+
*
|
|
556
|
+
* @danger You must configure the generic argument `T`
|
|
557
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
558
|
+
* @throws compile error
|
|
559
|
+
*
|
|
560
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
561
|
+
*/
|
|
562
|
+
export function createAssertPrune(): never;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Creates a resuable {@link assertPrune} function.
|
|
566
|
+
*
|
|
567
|
+
* @template T Type of the input value
|
|
568
|
+
* @returns A reusable `isPrune` function
|
|
569
|
+
*
|
|
570
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
571
|
+
*/
|
|
572
|
+
export function createAssertPrune<T extends object>(): (input: T) => T;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* @internal
|
|
576
|
+
*/
|
|
577
|
+
export function createAssertPrune<T extends object>(): (input: T) => T {
|
|
578
|
+
halt("createAssertPrune");
|
|
579
|
+
}
|
|
580
|
+
Object.assign(createAssertPrune, assertPrune);
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Creates a reusable {@link isPrune} function.
|
|
584
|
+
*
|
|
585
|
+
* @danger You must configure the generic argument `T`
|
|
586
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
587
|
+
* @throws compile error
|
|
588
|
+
*
|
|
589
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
590
|
+
*/
|
|
591
|
+
export function createIsPrune(): never;
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Creates a resuable {@link isPrune} function.
|
|
595
|
+
*
|
|
596
|
+
* @template T Type of the input value
|
|
597
|
+
* @returns A reusable `isPrune` function
|
|
598
|
+
*
|
|
599
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
600
|
+
*/
|
|
601
|
+
export function createIsPrune<T extends object>(): (input: T) => input is T;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* @internal
|
|
605
|
+
*/
|
|
606
|
+
export function createIsPrune<T extends object>(): (input: T) => input is T {
|
|
607
|
+
halt("createIsPrune");
|
|
608
|
+
}
|
|
609
|
+
Object.assign(createIsPrune, isPrune);
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Creates a reusable {@link validatePrune} function.
|
|
613
|
+
*
|
|
614
|
+
* @danger You must configure the generic argument `T`
|
|
615
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
616
|
+
* @throws compile error
|
|
617
|
+
*
|
|
618
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
619
|
+
*/
|
|
620
|
+
export function createValidatePrune(): never;
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Creates a resuable {@link validatePrune} function.
|
|
624
|
+
*
|
|
625
|
+
* @template T Type of the input value
|
|
626
|
+
* @returns A reusable `validatePrune` function
|
|
627
|
+
*
|
|
628
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
629
|
+
*/
|
|
630
|
+
export function createValidatePrune<T extends object>(): (
|
|
631
|
+
input: T,
|
|
632
|
+
) => IValidation<T>;
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* @internal
|
|
636
|
+
*/
|
|
637
|
+
export function createValidatePrune<T extends object>(): (
|
|
638
|
+
input: T,
|
|
639
|
+
) => IValidation<T> {
|
|
640
|
+
halt("createValidatePrune");
|
|
641
|
+
}
|
|
642
|
+
Object.assign(createValidatePrune, validatePrune);
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* @internal
|
|
646
|
+
*/
|
|
647
|
+
function halt(name: string): never {
|
|
648
|
+
throw new Error(
|
|
649
|
+
`Error on typia.misc.${name}(): no transform has been configured. Read and follow https://typia.misc.io/docs/setup please.`,
|
|
650
|
+
);
|
|
651
|
+
}
|