typia 5.3.5 → 5.3.6-dev.20231229
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 +2 -1
- package/lib/functional/$ProtobufReader.js +2 -2
- package/lib/functional/$ProtobufReader.js.map +1 -1
- package/package.json +1 -1
- package/src/AssertionGuard.ts +1 -1
- package/src/CamelCase.ts +114 -114
- package/src/IRandomGenerator.ts +35 -35
- package/src/IValidation.ts +21 -21
- package/src/PascalCase.ts +114 -114
- package/src/Primitive.ts +135 -135
- package/src/Resolved.ts +116 -116
- package/src/SnakeCase.ts +156 -156
- package/src/TypeGuardError.ts +36 -36
- package/src/executable/TypiaGenerateWizard.ts +83 -83
- package/src/executable/TypiaPatchWizard.ts +42 -42
- package/src/executable/TypiaSetupWizard.ts +151 -151
- package/src/executable/setup/ArgumentParser.ts +43 -43
- 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 +69 -69
- package/src/executable/typia.ts +55 -55
- package/src/factories/CommentFactory.ts +79 -79
- package/src/factories/ExpressionFactory.ts +150 -150
- package/src/factories/IdentifierFactory.ts +70 -70
- package/src/factories/JsonMetadataFactory.ts +53 -53
- package/src/factories/LiteralFactory.ts +47 -47
- package/src/factories/MetadataCollection.ts +269 -269
- package/src/factories/MetadataCommentTagFactory.ts +601 -601
- package/src/factories/MetadataFactory.ts +267 -267
- package/src/factories/MetadataTypeTagFactory.ts +313 -313
- package/src/factories/NumericRangeFactory.ts +72 -72
- package/src/factories/ProtobufFactory.ts +259 -259
- package/src/factories/StatementFactory.ts +72 -72
- package/src/factories/TemplateFactory.ts +56 -56
- package/src/factories/TypeFactory.ts +118 -118
- package/src/factories/ValueFactory.ts +12 -12
- package/src/factories/internal/metadata/MetadataHelper.ts +15 -15
- package/src/factories/internal/metadata/emend_metadata_atomics.ts +37 -37
- package/src/factories/internal/metadata/emplace_metadata_alias.ts +41 -41
- package/src/factories/internal/metadata/emplace_metadata_array_type.ts +38 -38
- package/src/factories/internal/metadata/emplace_metadata_object.ts +175 -175
- package/src/factories/internal/metadata/emplace_metadata_tuple.ts +57 -57
- package/src/factories/internal/metadata/explore_metadata.ts +28 -28
- package/src/factories/internal/metadata/iterate_metadata.ts +94 -94
- package/src/factories/internal/metadata/iterate_metadata_alias.ts +34 -34
- 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 +131 -131
- package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +26 -26
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +48 -48
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +230 -230
- package/src/factories/internal/metadata/iterate_metadata_map.ts +50 -50
- package/src/factories/internal/metadata/iterate_metadata_native.ts +208 -208
- package/src/factories/internal/metadata/iterate_metadata_object.ts +43 -43
- package/src/factories/internal/metadata/iterate_metadata_resolve.ts +52 -52
- package/src/factories/internal/metadata/iterate_metadata_set.ts +41 -41
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +61 -61
- package/src/factories/internal/metadata/iterate_metadata_template.ts +44 -44
- 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/$HeadersReader.ts +28 -28
- package/src/functional/$ParameterReader.ts +31 -31
- package/src/functional/$ProtobufReader.ts +199 -195
- package/src/functional/$ProtobufSizer.ts +147 -147
- package/src/functional/$ProtobufWriter.ts +150 -150
- package/src/functional/$QueryReader.ts +56 -56
- package/src/functional/$any.ts +4 -4
- package/src/functional/$clone.ts +4 -4
- package/src/functional/$convention.ts +37 -37
- package/src/functional/$dictionary.ts +22 -22
- package/src/functional/$every.ts +11 -11
- package/src/functional/$from.ts +5 -5
- 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 +12 -12
- package/src/functional/$report.ts +13 -13
- package/src/functional/$rest.ts +3 -3
- package/src/functional/$stoll.ts +8 -8
- 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 +174 -174
- package/src/http.ts +1149 -1149
- package/src/index.ts +4 -4
- package/src/json.ts +648 -648
- package/src/misc.ts +651 -651
- package/src/module.ts +897 -897
- package/src/notations.ts +855 -855
- package/src/programmers/AssertProgrammer.ts +293 -293
- package/src/programmers/CheckerProgrammer.ts +1025 -1025
- package/src/programmers/FeatureProgrammer.ts +460 -460
- package/src/programmers/IsProgrammer.ts +232 -232
- package/src/programmers/RandomProgrammer.ts +825 -825
- package/src/programmers/TypiaProgrammer.ts +167 -167
- package/src/programmers/ValidateProgrammer.ts +307 -307
- package/src/programmers/helpers/AtomicPredicator.ts +25 -25
- package/src/programmers/helpers/CloneJoiner.ts +130 -130
- package/src/programmers/helpers/FunctionImporeter.ts +87 -87
- package/src/programmers/helpers/HttpMetadataUtil.ts +21 -21
- package/src/programmers/helpers/ICheckEntry.ts +13 -13
- package/src/programmers/helpers/IExpressionEntry.ts +12 -12
- package/src/programmers/helpers/NotationJoiner.ts +132 -132
- 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 +141 -141
- package/src/programmers/helpers/RandomJoiner.ts +140 -140
- package/src/programmers/helpers/RandomRanger.ts +171 -171
- package/src/programmers/helpers/StringifyJoinder.ts +105 -105
- package/src/programmers/helpers/StringifyPredicator.ts +12 -12
- package/src/programmers/helpers/UnionExplorer.ts +269 -269
- package/src/programmers/helpers/UnionPredicator.ts +77 -77
- package/src/programmers/helpers/disable_function_importer_declare.ts +32 -32
- package/src/programmers/http/HttpAssertHeadersProgrammer.ts +77 -77
- package/src/programmers/http/HttpAssertQueryProgrammer.ts +75 -75
- package/src/programmers/http/HttpHeadersProgrammer.ts +314 -314
- package/src/programmers/http/HttpIsHeadersProgrammer.ts +84 -84
- package/src/programmers/http/HttpIsQueryProgrammer.ts +82 -82
- package/src/programmers/http/HttpParameterProgrammer.ts +97 -97
- package/src/programmers/http/HttpQueryProgrammer.ts +252 -252
- package/src/programmers/http/HttpValidateHeadersProgrammer.ts +77 -77
- package/src/programmers/http/HttpValidateQueryProgrammer.ts +75 -75
- 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 +59 -59
- package/src/programmers/internal/application_boolean.ts +30 -30
- 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_escaped.ts +53 -53
- package/src/programmers/internal/application_native.ts +38 -38
- package/src/programmers/internal/application_number.ts +94 -94
- package/src/programmers/internal/application_object.ts +153 -153
- package/src/programmers/internal/application_schema.ts +180 -180
- package/src/programmers/internal/application_string.ts +58 -58
- package/src/programmers/internal/application_templates.ts +25 -25
- package/src/programmers/internal/application_tuple.ts +55 -55
- package/src/programmers/internal/check_array_length.ts +45 -45
- package/src/programmers/internal/check_bigint.ts +49 -49
- package/src/programmers/internal/check_dynamic_key.ts +175 -175
- package/src/programmers/internal/check_dynamic_properties.ts +198 -198
- package/src/programmers/internal/check_everything.ts +23 -23
- package/src/programmers/internal/check_native.ts +21 -21
- package/src/programmers/internal/check_number.ts +106 -106
- package/src/programmers/internal/check_object.ts +60 -60
- package/src/programmers/internal/check_string.ts +48 -48
- package/src/programmers/internal/check_template.ts +61 -61
- package/src/programmers/internal/check_union_array_like.ts +307 -307
- package/src/programmers/internal/decode_union_object.ts +78 -78
- package/src/programmers/internal/feature_object_entries.ts +58 -58
- package/src/programmers/internal/metadata_to_pattern.ts +33 -33
- 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 +157 -157
- package/src/programmers/internal/stringify_native.ts +7 -7
- package/src/programmers/internal/stringify_regular_properties.ts +81 -81
- 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 +67 -67
- package/src/programmers/json/JsonAssertStringifyProgrammer.ts +61 -61
- package/src/programmers/json/JsonIsParseProgrammer.ts +73 -73
- package/src/programmers/json/JsonIsStringifyProgrammer.ts +75 -75
- package/src/programmers/json/JsonStringifyProgrammer.ts +893 -893
- package/src/programmers/json/JsonValidateParseProgrammer.ts +64 -64
- package/src/programmers/json/JsonValidateStringifyProgrammer.ts +83 -83
- package/src/programmers/misc/MiscAssertCloneProgrammer.ts +63 -63
- package/src/programmers/misc/MiscAssertPruneProgrammer.ts +60 -60
- package/src/programmers/misc/MiscCloneProgrammer.ts +713 -713
- package/src/programmers/misc/MiscIsCloneProgrammer.ts +70 -70
- package/src/programmers/misc/MiscIsPruneProgrammer.ts +66 -66
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +72 -72
- package/src/programmers/misc/MiscPruneProgrammer.ts +523 -523
- package/src/programmers/misc/MiscValidateCloneProgrammer.ts +80 -80
- package/src/programmers/misc/MiscValidatePruneProgrammer.ts +73 -73
- package/src/programmers/notations/NotationAssertGeneralProgrammer.ts +64 -64
- package/src/programmers/notations/NotationGeneralProgrammer.ts +647 -647
- package/src/programmers/notations/NotationIsGeneralProgrammer.ts +71 -71
- package/src/programmers/notations/NotationValidateGeneralProgrammer.ts +81 -81
- package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +61 -61
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +607 -607
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +819 -819
- package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +82 -82
- package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +160 -160
- package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +75 -75
- package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +83 -83
- package/src/protobuf.ts +887 -887
- package/src/reflect.ts +24 -24
- package/src/schemas/json/IJsonApplication.ts +8 -8
- package/src/schemas/json/IJsonComponents.ts +36 -36
- package/src/schemas/json/IJsonSchema.ts +113 -113
- 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/IMetadataComponents.ts +11 -11
- package/src/schemas/metadata/IMetadataConstant.ts +23 -23
- package/src/schemas/metadata/IMetadataDictionary.ts +11 -11
- 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 +15 -15
- package/src/schemas/metadata/Metadata.ts +612 -612
- package/src/schemas/metadata/MetadataAlias.ts +61 -61
- package/src/schemas/metadata/MetadataApplication.ts +44 -44
- package/src/schemas/metadata/MetadataArray.ts +49 -49
- package/src/schemas/metadata/MetadataArrayType.ts +57 -57
- package/src/schemas/metadata/MetadataAtomic.ts +84 -84
- package/src/schemas/metadata/MetadataComponents.ts +98 -98
- package/src/schemas/metadata/MetadataConstant.ts +46 -46
- package/src/schemas/metadata/MetadataEscaped.ts +51 -51
- package/src/schemas/metadata/MetadataObject.ts +135 -135
- package/src/schemas/metadata/MetadataProperty.ts +56 -56
- package/src/schemas/metadata/MetadataTuple.ts +32 -32
- package/src/schemas/metadata/MetadataTupleType.ts +67 -67
- package/src/tags/Default.ts +15 -15
- 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 +9 -9
- package/src/tags/TagBase.ts +68 -68
- package/src/tags/Type.ts +27 -27
- package/src/tags/index.ts +14 -14
- package/src/transform.ts +35 -35
- package/src/transformers/CallExpressionTransformer.ts +351 -351
- package/src/transformers/FileTransformer.ts +91 -91
- 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 +16 -16
- package/src/transformers/features/CreateAssertTransformer.ts +16 -16
- package/src/transformers/features/CreateIsTransformer.ts +10 -10
- package/src/transformers/features/CreateRandomTransformer.ts +40 -40
- package/src/transformers/features/CreateValidateTransformer.ts +13 -13
- package/src/transformers/features/IsTransformer.ts +10 -10
- package/src/transformers/features/RandomTransformer.ts +44 -44
- package/src/transformers/features/ValidateTransformer.ts +11 -11
- package/src/transformers/features/http/CreateHttpAssertHeadersTransformer.ts +11 -11
- package/src/transformers/features/http/CreateHttpAssertQueryTransformer.ts +9 -9
- package/src/transformers/features/http/CreateHttpHeadersTransformer.ts +9 -9
- package/src/transformers/features/http/CreateHttpIsHeadersTransformer.ts +9 -9
- package/src/transformers/features/http/CreateHttpIsQueryTransformer.ts +9 -9
- package/src/transformers/features/http/CreateHttpParameterTransformer.ts +9 -9
- package/src/transformers/features/http/CreateHttpQueryTransformer.ts +9 -9
- package/src/transformers/features/http/CreateHttpValidateHeadersTransformer.ts +12 -12
- package/src/transformers/features/http/CreateHttpValidateQueryTransformer.ts +11 -11
- package/src/transformers/features/http/HttpAssertHeadersTransformer.ts +9 -9
- package/src/transformers/features/http/HttpAssertQueryTransformer.ts +9 -9
- package/src/transformers/features/http/HttpHeadersTransformer.ts +9 -9
- package/src/transformers/features/http/HttpIsHeadersTransformer.ts +9 -9
- package/src/transformers/features/http/HttpIsQueryTransformer.ts +9 -9
- package/src/transformers/features/http/HttpParameterTransformer.ts +9 -9
- package/src/transformers/features/http/HttpQueryTransformer.ts +9 -9
- package/src/transformers/features/http/HttpValidateHeadersTransformer.ts +10 -10
- package/src/transformers/features/http/HttpValidateQueryTransformer.ts +9 -9
- package/src/transformers/features/json/JsonApplicationTransformer.ts +121 -121
- package/src/transformers/features/json/JsonAssertParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
- package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +9 -9
- 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 +9 -9
- package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +11 -11
- 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 +9 -9
- package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
- package/src/transformers/features/json/JsonValidateParseTransformer.ts +9 -9
- package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
- package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +9 -9
- package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +9 -9
- 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 +11 -11
- package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +11 -11
- 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 +9 -9
- package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +9 -9
- package/src/transformers/features/notations/NotationAssertGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationCreateAssertGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationCreateGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationCreateIsGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationCreateValidateGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationGeneralTransformer.ts +11 -11
- package/src/transformers/features/notations/NotationIsGeneralTransformer.ts +15 -15
- package/src/transformers/features/notations/NotationValidateGeneralTransformer.ts +15 -15
- package/src/transformers/features/protobuf/ProtobufAssertDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufAssertEncodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufCreateAssertDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufCreateAssertEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufCreateDecodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufCreateEncodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufCreateIsDecodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufCreateIsEncodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufCreateValidateDecodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufCreateValidateEncodeTransformer.ts +12 -12
- package/src/transformers/features/protobuf/ProtobufDecodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufEncodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufIsDecodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufIsEncodeTransformer.ts +9 -9
- package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
- package/src/transformers/features/protobuf/ProtobufValidateDecodeTransformer.ts +10 -10
- package/src/transformers/features/protobuf/ProtobufValidateEncodeTransformer.ts +10 -10
- package/src/transformers/features/reflect/ReflectMetadataTransformer.ts +73 -73
- package/src/transformers/internal/GenericTransformer.ts +96 -96
- package/src/typings/Atomic.ts +13 -13
- 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 +43 -43
- package/src/utils/Escaper.ts +46 -46
- package/src/utils/MapUtil.ts +12 -12
- package/src/utils/NameEncoder.ts +32 -32
- package/src/utils/NamingConvention.ts +87 -87
- package/src/utils/PatternUtil.ts +29 -29
- package/src/utils/RandomGenerator.ts +83 -83
- package/src/utils/Singleton.ts +16 -16
- package/src/utils/StringUtil.ts +4 -4
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
export namespace $QueryReader {
|
|
2
|
-
export const boolean = (str: string | null): boolean | null | undefined =>
|
|
3
|
-
str === null
|
|
4
|
-
? undefined
|
|
5
|
-
: str === "null"
|
|
6
|
-
? null
|
|
7
|
-
: str.length === 0
|
|
8
|
-
? true
|
|
9
|
-
: str === "true" || str === "1"
|
|
10
|
-
? true
|
|
11
|
-
: str === "false" || str === "0"
|
|
12
|
-
? false
|
|
13
|
-
: (str as any); // wrong type
|
|
14
|
-
|
|
15
|
-
export const number = (str: string | null): number | null | undefined =>
|
|
16
|
-
!!str?.length
|
|
17
|
-
? str === "null"
|
|
18
|
-
? null
|
|
19
|
-
: (toNumber(str) as any)
|
|
20
|
-
: undefined;
|
|
21
|
-
|
|
22
|
-
export const bigint = (str: string | null): bigint | null | undefined =>
|
|
23
|
-
!!str?.length
|
|
24
|
-
? str === "null"
|
|
25
|
-
? null
|
|
26
|
-
: (toBigint(str) as any)
|
|
27
|
-
: undefined;
|
|
28
|
-
|
|
29
|
-
export const string = (str: string | null): string | null | undefined =>
|
|
30
|
-
str === null ? undefined : str === "null" ? null : str;
|
|
31
|
-
|
|
32
|
-
export const params = (input: string | URLSearchParams) => {
|
|
33
|
-
if (typeof input === "string") {
|
|
34
|
-
const index: number = input.indexOf("?");
|
|
35
|
-
input = index === -1 ? "" : input.substring(index + 1);
|
|
36
|
-
return new URLSearchParams(input);
|
|
37
|
-
}
|
|
38
|
-
return input;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const array = (input: any[], alternative: null | undefined) =>
|
|
42
|
-
input.length ? input : alternative;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const toNumber = (str: string): number | string => {
|
|
46
|
-
const value: number = Number(str);
|
|
47
|
-
return isNaN(value) ? str : value;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const toBigint = (str: string): bigint | string => {
|
|
51
|
-
try {
|
|
52
|
-
return BigInt(str);
|
|
53
|
-
} catch {
|
|
54
|
-
return str;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
1
|
+
export namespace $QueryReader {
|
|
2
|
+
export const boolean = (str: string | null): boolean | null | undefined =>
|
|
3
|
+
str === null
|
|
4
|
+
? undefined
|
|
5
|
+
: str === "null"
|
|
6
|
+
? null
|
|
7
|
+
: str.length === 0
|
|
8
|
+
? true
|
|
9
|
+
: str === "true" || str === "1"
|
|
10
|
+
? true
|
|
11
|
+
: str === "false" || str === "0"
|
|
12
|
+
? false
|
|
13
|
+
: (str as any); // wrong type
|
|
14
|
+
|
|
15
|
+
export const number = (str: string | null): number | null | undefined =>
|
|
16
|
+
!!str?.length
|
|
17
|
+
? str === "null"
|
|
18
|
+
? null
|
|
19
|
+
: (toNumber(str) as any)
|
|
20
|
+
: undefined;
|
|
21
|
+
|
|
22
|
+
export const bigint = (str: string | null): bigint | null | undefined =>
|
|
23
|
+
!!str?.length
|
|
24
|
+
? str === "null"
|
|
25
|
+
? null
|
|
26
|
+
: (toBigint(str) as any)
|
|
27
|
+
: undefined;
|
|
28
|
+
|
|
29
|
+
export const string = (str: string | null): string | null | undefined =>
|
|
30
|
+
str === null ? undefined : str === "null" ? null : str;
|
|
31
|
+
|
|
32
|
+
export const params = (input: string | URLSearchParams) => {
|
|
33
|
+
if (typeof input === "string") {
|
|
34
|
+
const index: number = input.indexOf("?");
|
|
35
|
+
input = index === -1 ? "" : input.substring(index + 1);
|
|
36
|
+
return new URLSearchParams(input);
|
|
37
|
+
}
|
|
38
|
+
return input;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const array = (input: any[], alternative: null | undefined) =>
|
|
42
|
+
input.length ? input : alternative;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const toNumber = (str: string): number | string => {
|
|
46
|
+
const value: number = Number(str);
|
|
47
|
+
return isNaN(value) ? str : value;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const toBigint = (str: string): bigint | string => {
|
|
51
|
+
try {
|
|
52
|
+
return BigInt(str);
|
|
53
|
+
} catch {
|
|
54
|
+
return str;
|
|
55
|
+
}
|
|
56
|
+
};
|
package/src/functional/$any.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $clone } from "./$clone";
|
|
2
|
-
|
|
3
|
-
export const $any = (val: any): any =>
|
|
4
|
-
val !== undefined ? $clone(val) : undefined;
|
|
1
|
+
import { $clone } from "./$clone";
|
|
2
|
+
|
|
3
|
+
export const $any = (val: any): any =>
|
|
4
|
+
val !== undefined ? $clone(val) : undefined;
|
package/src/functional/$clone.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Primitive } from "../Primitive";
|
|
2
|
-
|
|
3
|
-
export const $clone = <T>(value: T): Primitive<T> =>
|
|
4
|
-
JSON.parse(JSON.stringify(value));
|
|
1
|
+
import { Primitive } from "../Primitive";
|
|
2
|
+
|
|
3
|
+
export const $clone = <T>(value: T): Primitive<T> =>
|
|
4
|
+
JSON.parse(JSON.stringify(value));
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
export const $convention = (rename: (str: string) => string) => {
|
|
2
|
-
const main = (input: any): any => {
|
|
3
|
-
if (typeof input === "object")
|
|
4
|
-
if (input === null) return null;
|
|
5
|
-
else if (Array.isArray(input)) return input.map(main);
|
|
6
|
-
else if (
|
|
7
|
-
input instanceof Boolean ||
|
|
8
|
-
input instanceof BigInt ||
|
|
9
|
-
input instanceof Number ||
|
|
10
|
-
input instanceof String
|
|
11
|
-
)
|
|
12
|
-
return input.valueOf();
|
|
13
|
-
else if (input instanceof Date) return new Date(input);
|
|
14
|
-
else if (
|
|
15
|
-
input instanceof Uint8Array ||
|
|
16
|
-
input instanceof Uint8ClampedArray ||
|
|
17
|
-
input instanceof Uint16Array ||
|
|
18
|
-
input instanceof Uint32Array ||
|
|
19
|
-
input instanceof BigUint64Array ||
|
|
20
|
-
input instanceof Int8Array ||
|
|
21
|
-
input instanceof Int16Array ||
|
|
22
|
-
input instanceof Int32Array ||
|
|
23
|
-
input instanceof BigInt64Array ||
|
|
24
|
-
input instanceof Float32Array ||
|
|
25
|
-
input instanceof Float64Array ||
|
|
26
|
-
input instanceof DataView
|
|
27
|
-
)
|
|
28
|
-
return input;
|
|
29
|
-
else return object(input);
|
|
30
|
-
return input;
|
|
31
|
-
};
|
|
32
|
-
const object = (input: Record<string, any>) =>
|
|
33
|
-
Object.fromEntries(
|
|
34
|
-
Object.entries(input).map(([key, value]) => [rename(key), main(value)]),
|
|
35
|
-
);
|
|
36
|
-
return main;
|
|
37
|
-
};
|
|
1
|
+
export const $convention = (rename: (str: string) => string) => {
|
|
2
|
+
const main = (input: any): any => {
|
|
3
|
+
if (typeof input === "object")
|
|
4
|
+
if (input === null) return null;
|
|
5
|
+
else if (Array.isArray(input)) return input.map(main);
|
|
6
|
+
else if (
|
|
7
|
+
input instanceof Boolean ||
|
|
8
|
+
input instanceof BigInt ||
|
|
9
|
+
input instanceof Number ||
|
|
10
|
+
input instanceof String
|
|
11
|
+
)
|
|
12
|
+
return input.valueOf();
|
|
13
|
+
else if (input instanceof Date) return new Date(input);
|
|
14
|
+
else if (
|
|
15
|
+
input instanceof Uint8Array ||
|
|
16
|
+
input instanceof Uint8ClampedArray ||
|
|
17
|
+
input instanceof Uint16Array ||
|
|
18
|
+
input instanceof Uint32Array ||
|
|
19
|
+
input instanceof BigUint64Array ||
|
|
20
|
+
input instanceof Int8Array ||
|
|
21
|
+
input instanceof Int16Array ||
|
|
22
|
+
input instanceof Int32Array ||
|
|
23
|
+
input instanceof BigInt64Array ||
|
|
24
|
+
input instanceof Float32Array ||
|
|
25
|
+
input instanceof Float64Array ||
|
|
26
|
+
input instanceof DataView
|
|
27
|
+
)
|
|
28
|
+
return input;
|
|
29
|
+
else return object(input);
|
|
30
|
+
return input;
|
|
31
|
+
};
|
|
32
|
+
const object = (input: Record<string, any>) =>
|
|
33
|
+
Object.fromEntries(
|
|
34
|
+
Object.entries(input).map(([key, value]) => [rename(key), main(value)]),
|
|
35
|
+
);
|
|
36
|
+
return main;
|
|
37
|
+
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Customizable } from "../typings/Customizable";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
const blackhole: any = {};
|
|
7
|
-
|
|
8
|
-
export const $dictionary = (() => {
|
|
9
|
-
const glob: {
|
|
10
|
-
__typia_custom_validator: Map<
|
|
11
|
-
`${string}`,
|
|
12
|
-
Map<keyof Customizable, (tagText: string) => (value: any) => boolean>
|
|
13
|
-
>;
|
|
14
|
-
} =
|
|
15
|
-
typeof global === "object" &&
|
|
16
|
-
typeof global.process === "object" &&
|
|
17
|
-
typeof global.process.versions === "object" &&
|
|
18
|
-
typeof global.process.versions.node !== "undefined"
|
|
19
|
-
? ((global ?? blackhole) as any)
|
|
20
|
-
: ((self ?? blackhole) as any);
|
|
21
|
-
return (glob.__typia_custom_validator ??= new Map());
|
|
22
|
-
})();
|
|
1
|
+
import { Customizable } from "../typings/Customizable";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
const blackhole: any = {};
|
|
7
|
+
|
|
8
|
+
export const $dictionary = (() => {
|
|
9
|
+
const glob: {
|
|
10
|
+
__typia_custom_validator: Map<
|
|
11
|
+
`${string}`,
|
|
12
|
+
Map<keyof Customizable, (tagText: string) => (value: any) => boolean>
|
|
13
|
+
>;
|
|
14
|
+
} =
|
|
15
|
+
typeof global === "object" &&
|
|
16
|
+
typeof global.process === "object" &&
|
|
17
|
+
typeof global.process.versions === "object" &&
|
|
18
|
+
typeof global.process.versions.node !== "undefined"
|
|
19
|
+
? ((global ?? blackhole) as any)
|
|
20
|
+
: ((self ?? blackhole) as any);
|
|
21
|
+
return (glob.__typia_custom_validator ??= new Map());
|
|
22
|
+
})();
|
package/src/functional/$every.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
-
|
|
3
|
-
export const $every = <T>(
|
|
4
|
-
array: T[],
|
|
5
|
-
pred: (value: T, i: number) => null | Omit<TypeGuardError.IProps, "method">,
|
|
6
|
-
): null | Omit<TypeGuardError.IProps, "method"> => {
|
|
7
|
-
let error: null | Omit<TypeGuardError.IProps, "method"> = null;
|
|
8
|
-
for (let i: number = 0; i < array.length; ++i)
|
|
9
|
-
if (null !== (error = pred(array[i]!, i))) return error;
|
|
10
|
-
return null;
|
|
11
|
-
};
|
|
1
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
+
|
|
3
|
+
export const $every = <T>(
|
|
4
|
+
array: T[],
|
|
5
|
+
pred: (value: T, i: number) => null | Omit<TypeGuardError.IProps, "method">,
|
|
6
|
+
): null | Omit<TypeGuardError.IProps, "method"> => {
|
|
7
|
+
let error: null | Omit<TypeGuardError.IProps, "method"> = null;
|
|
8
|
+
for (let i: number = 0; i < array.length; ++i)
|
|
9
|
+
if (null !== (error = pred(array[i]!, i))) return error;
|
|
10
|
+
return null;
|
|
11
|
+
};
|
package/src/functional/$from.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IMetadataApplication } from "../schemas/metadata/IMetadataApplication";
|
|
2
|
-
import { MetadataApplication } from "../schemas/metadata/MetadataApplication";
|
|
3
|
-
|
|
4
|
-
export const $from = (json: IMetadataApplication): MetadataApplication =>
|
|
5
|
-
MetadataApplication.from(json);
|
|
1
|
+
import { IMetadataApplication } from "../schemas/metadata/IMetadataApplication";
|
|
2
|
+
import { MetadataApplication } from "../schemas/metadata/MetadataApplication";
|
|
3
|
+
|
|
4
|
+
export const $from = (json: IMetadataApplication): MetadataApplication =>
|
|
5
|
+
MetadataApplication.from(json);
|
package/src/functional/$guard.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
-
|
|
3
|
-
/* -----------------------------------------------------------
|
|
4
|
-
ASSERT V2 -> USE (NULL OR ERROR) CONDITION
|
|
5
|
-
----------------------------------------------------------- */
|
|
6
|
-
// /**
|
|
7
|
-
// * @internal
|
|
8
|
-
// */
|
|
9
|
-
// export const $guardV2 =
|
|
10
|
-
// (method: string) => (props: Omit<TypeGuardError.IProps, "method">) =>
|
|
11
|
-
// new TypeGuardError({
|
|
12
|
-
// method,
|
|
13
|
-
// path: props.path,
|
|
14
|
-
// expected: props.expected,
|
|
15
|
-
// value: props.value,
|
|
16
|
-
// });
|
|
17
|
-
|
|
18
|
-
/* -----------------------------------------------------------
|
|
19
|
-
ASSERT V3 -> (CONDITION OR THROW(exceptable): FALSE)
|
|
20
|
-
----------------------------------------------------------- */
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export const $guard =
|
|
25
|
-
(method: string) =>
|
|
26
|
-
(exceptionable: boolean, props: Omit<TypeGuardError.IProps, "method">) => {
|
|
27
|
-
if (exceptionable === true)
|
|
28
|
-
throw new TypeGuardError({
|
|
29
|
-
method,
|
|
30
|
-
path: props.path,
|
|
31
|
-
expected: props.expected,
|
|
32
|
-
value: props.value,
|
|
33
|
-
});
|
|
34
|
-
return false;
|
|
35
|
-
};
|
|
1
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
+
|
|
3
|
+
/* -----------------------------------------------------------
|
|
4
|
+
ASSERT V2 -> USE (NULL OR ERROR) CONDITION
|
|
5
|
+
----------------------------------------------------------- */
|
|
6
|
+
// /**
|
|
7
|
+
// * @internal
|
|
8
|
+
// */
|
|
9
|
+
// export const $guardV2 =
|
|
10
|
+
// (method: string) => (props: Omit<TypeGuardError.IProps, "method">) =>
|
|
11
|
+
// new TypeGuardError({
|
|
12
|
+
// method,
|
|
13
|
+
// path: props.path,
|
|
14
|
+
// expected: props.expected,
|
|
15
|
+
// value: props.value,
|
|
16
|
+
// });
|
|
17
|
+
|
|
18
|
+
/* -----------------------------------------------------------
|
|
19
|
+
ASSERT V3 -> (CONDITION OR THROW(exceptable): FALSE)
|
|
20
|
+
----------------------------------------------------------- */
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const $guard =
|
|
25
|
+
(method: string) =>
|
|
26
|
+
(exceptionable: boolean, props: Omit<TypeGuardError.IProps, "method">) => {
|
|
27
|
+
if (exceptionable === true)
|
|
28
|
+
throw new TypeGuardError({
|
|
29
|
+
method,
|
|
30
|
+
path: props.path,
|
|
31
|
+
expected: props.expected,
|
|
32
|
+
value: props.value,
|
|
33
|
+
});
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const $is_between = (value: number, minimum: number, maximum: number) =>
|
|
2
|
-
minimum <= value && value <= maximum;
|
|
1
|
+
export const $is_between = (value: number, minimum: number, maximum: number) =>
|
|
2
|
+
minimum <= value && value <= maximum;
|
package/src/functional/$join.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
export const $join = (str: string): string =>
|
|
2
|
-
variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
|
|
3
|
-
|
|
4
|
-
const variable = (str: string): boolean =>
|
|
5
|
-
reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
|
|
6
|
-
|
|
7
|
-
const reserved = (str: string): boolean => RESERVED.has(str);
|
|
8
|
-
|
|
9
|
-
const RESERVED: Set<string> = new Set([
|
|
10
|
-
"break",
|
|
11
|
-
"case",
|
|
12
|
-
"catch",
|
|
13
|
-
"class",
|
|
14
|
-
"const",
|
|
15
|
-
"continue",
|
|
16
|
-
"debugger",
|
|
17
|
-
"default",
|
|
18
|
-
"delete",
|
|
19
|
-
"do",
|
|
20
|
-
"else",
|
|
21
|
-
"enum",
|
|
22
|
-
"export",
|
|
23
|
-
"extends",
|
|
24
|
-
"false",
|
|
25
|
-
"finally",
|
|
26
|
-
"for",
|
|
27
|
-
"function",
|
|
28
|
-
"if",
|
|
29
|
-
"import",
|
|
30
|
-
"in",
|
|
31
|
-
"instanceof",
|
|
32
|
-
"new",
|
|
33
|
-
"null",
|
|
34
|
-
"return",
|
|
35
|
-
"super",
|
|
36
|
-
"switch",
|
|
37
|
-
"this",
|
|
38
|
-
"throw",
|
|
39
|
-
"true",
|
|
40
|
-
"try",
|
|
41
|
-
"typeof",
|
|
42
|
-
"var",
|
|
43
|
-
"void",
|
|
44
|
-
"while",
|
|
45
|
-
"with",
|
|
46
|
-
]);
|
|
1
|
+
export const $join = (str: string): string =>
|
|
2
|
+
variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
|
|
3
|
+
|
|
4
|
+
const variable = (str: string): boolean =>
|
|
5
|
+
reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
|
|
6
|
+
|
|
7
|
+
const reserved = (str: string): boolean => RESERVED.has(str);
|
|
8
|
+
|
|
9
|
+
const RESERVED: Set<string> = new Set([
|
|
10
|
+
"break",
|
|
11
|
+
"case",
|
|
12
|
+
"catch",
|
|
13
|
+
"class",
|
|
14
|
+
"const",
|
|
15
|
+
"continue",
|
|
16
|
+
"debugger",
|
|
17
|
+
"default",
|
|
18
|
+
"delete",
|
|
19
|
+
"do",
|
|
20
|
+
"else",
|
|
21
|
+
"enum",
|
|
22
|
+
"export",
|
|
23
|
+
"extends",
|
|
24
|
+
"false",
|
|
25
|
+
"finally",
|
|
26
|
+
"for",
|
|
27
|
+
"function",
|
|
28
|
+
"if",
|
|
29
|
+
"import",
|
|
30
|
+
"in",
|
|
31
|
+
"instanceof",
|
|
32
|
+
"new",
|
|
33
|
+
"null",
|
|
34
|
+
"return",
|
|
35
|
+
"super",
|
|
36
|
+
"switch",
|
|
37
|
+
"this",
|
|
38
|
+
"throw",
|
|
39
|
+
"true",
|
|
40
|
+
"try",
|
|
41
|
+
"typeof",
|
|
42
|
+
"var",
|
|
43
|
+
"void",
|
|
44
|
+
"while",
|
|
45
|
+
"with",
|
|
46
|
+
]);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
-
|
|
3
|
-
export const $number = (value: number): number => {
|
|
4
|
-
if (isFinite(value) === false)
|
|
5
|
-
throw new TypeGuardError({
|
|
6
|
-
method: "typia.json.stringify",
|
|
7
|
-
expected: "number",
|
|
8
|
-
value,
|
|
9
|
-
message: "Error on typia.json.stringify(): infinite or not a number.",
|
|
10
|
-
});
|
|
11
|
-
return value;
|
|
12
|
-
};
|
|
1
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
+
|
|
3
|
+
export const $number = (value: number): number => {
|
|
4
|
+
if (isFinite(value) === false)
|
|
5
|
+
throw new TypeGuardError({
|
|
6
|
+
method: "typia.json.stringify",
|
|
7
|
+
expected: "number",
|
|
8
|
+
value,
|
|
9
|
+
message: "Error on typia.json.stringify(): infinite or not a number.",
|
|
10
|
+
});
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { IValidation } from "../IValidation";
|
|
2
|
-
|
|
3
|
-
export const $report = (array: IValidation.IError[]) => {
|
|
4
|
-
const reportable = (path: string): boolean => {
|
|
5
|
-
if (array.length === 0) return true;
|
|
6
|
-
const last: string = array[array.length - 1]!.path;
|
|
7
|
-
return path.length > last.length || last.substring(0, path.length) !== path;
|
|
8
|
-
};
|
|
9
|
-
return (exceptable: boolean, error: IValidation.IError): false => {
|
|
10
|
-
if (exceptable && reportable(error.path)) array.push(error);
|
|
11
|
-
return false;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
1
|
+
import { IValidation } from "../IValidation";
|
|
2
|
+
|
|
3
|
+
export const $report = (array: IValidation.IError[]) => {
|
|
4
|
+
const reportable = (path: string): boolean => {
|
|
5
|
+
if (array.length === 0) return true;
|
|
6
|
+
const last: string = array[array.length - 1]!.path;
|
|
7
|
+
return path.length > last.length || last.substring(0, path.length) !== path;
|
|
8
|
+
};
|
|
9
|
+
return (exceptable: boolean, error: IValidation.IError): false => {
|
|
10
|
+
if (exceptable && reportable(error.path)) array.push(error);
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
13
|
+
};
|
package/src/functional/$rest.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const $rest = (str: string): string => {
|
|
2
|
-
return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
|
|
3
|
-
};
|
|
1
|
+
export const $rest = (str: string): string => {
|
|
2
|
+
return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
|
|
3
|
+
};
|
package/src/functional/$stoll.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export const $is_bigint_string = (str: string): boolean => {
|
|
2
|
-
try {
|
|
3
|
-
BigInt(str);
|
|
4
|
-
return true;
|
|
5
|
-
} catch {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
1
|
+
export const $is_bigint_string = (str: string): boolean => {
|
|
2
|
+
try {
|
|
3
|
+
BigInt(str);
|
|
4
|
+
return true;
|
|
5
|
+
} catch {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In the past, name of `typia` was `typescript-json`, and supported
|
|
3
|
-
* JSON serialization by wrapping `fast-json-stringify. `typescript-json` was
|
|
4
|
-
* a helper library of `fast-json-stringify`, which can skip manual JSON schema
|
|
5
|
-
* definition just by putting pure TypeScript type.
|
|
6
|
-
*
|
|
7
|
-
* This `$string` function is a part of `fast-json-stringify` at that time, and
|
|
8
|
-
* still being used in `typia` for the string serialization.
|
|
9
|
-
*
|
|
10
|
-
* @internal
|
|
11
|
-
* @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
|
|
12
|
-
* @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
|
|
13
|
-
*/
|
|
14
|
-
export const $string = (str: string): string => {
|
|
15
|
-
if (STR_ESCAPE.test(str) === false) return `"${str}"`;
|
|
16
|
-
|
|
17
|
-
const length: number = str.length;
|
|
18
|
-
if (length > 41) return JSON.stringify(str);
|
|
19
|
-
|
|
20
|
-
let result = "";
|
|
21
|
-
let last = -1;
|
|
22
|
-
let point = 255;
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line
|
|
25
|
-
for (let i = 0; i < length; ++i) {
|
|
26
|
-
point = str.charCodeAt(i);
|
|
27
|
-
if (point < 32) {
|
|
28
|
-
return JSON.stringify(str);
|
|
29
|
-
}
|
|
30
|
-
if (point >= 0xd800 && point <= 0xdfff) {
|
|
31
|
-
// The current character is a surrogate.
|
|
32
|
-
return JSON.stringify(str);
|
|
33
|
-
}
|
|
34
|
-
if (
|
|
35
|
-
point === 0x22 || // '"'
|
|
36
|
-
point === 0x5c // '\'
|
|
37
|
-
) {
|
|
38
|
-
last === -1 && (last = 0);
|
|
39
|
-
result += str.slice(last, i) + "\\";
|
|
40
|
-
last = i;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
(last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const STR_ESCAPE =
|
|
50
|
-
/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
|
|
1
|
+
/**
|
|
2
|
+
* In the past, name of `typia` was `typescript-json`, and supported
|
|
3
|
+
* JSON serialization by wrapping `fast-json-stringify. `typescript-json` was
|
|
4
|
+
* a helper library of `fast-json-stringify`, which can skip manual JSON schema
|
|
5
|
+
* definition just by putting pure TypeScript type.
|
|
6
|
+
*
|
|
7
|
+
* This `$string` function is a part of `fast-json-stringify` at that time, and
|
|
8
|
+
* still being used in `typia` for the string serialization.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
* @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
|
|
12
|
+
* @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
|
|
13
|
+
*/
|
|
14
|
+
export const $string = (str: string): string => {
|
|
15
|
+
if (STR_ESCAPE.test(str) === false) return `"${str}"`;
|
|
16
|
+
|
|
17
|
+
const length: number = str.length;
|
|
18
|
+
if (length > 41) return JSON.stringify(str);
|
|
19
|
+
|
|
20
|
+
let result = "";
|
|
21
|
+
let last = -1;
|
|
22
|
+
let point = 255;
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line
|
|
25
|
+
for (let i = 0; i < length; ++i) {
|
|
26
|
+
point = str.charCodeAt(i);
|
|
27
|
+
if (point < 32) {
|
|
28
|
+
return JSON.stringify(str);
|
|
29
|
+
}
|
|
30
|
+
if (point >= 0xd800 && point <= 0xdfff) {
|
|
31
|
+
// The current character is a surrogate.
|
|
32
|
+
return JSON.stringify(str);
|
|
33
|
+
}
|
|
34
|
+
if (
|
|
35
|
+
point === 0x22 || // '"'
|
|
36
|
+
point === 0x5c // '\'
|
|
37
|
+
) {
|
|
38
|
+
last === -1 && (last = 0);
|
|
39
|
+
result += str.slice(last, i) + "\\";
|
|
40
|
+
last = i;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
(last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const STR_ESCAPE =
|
|
50
|
+
/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const $strlen = (s: string): number => {
|
|
2
|
-
let b: number;
|
|
3
|
-
let i: number;
|
|
4
|
-
let c: number;
|
|
5
|
-
for (b = i = 0; (c = s.charCodeAt(i++)); b += c >> 11 ? 3 : c >> 7 ? 2 : 1);
|
|
6
|
-
return b;
|
|
7
|
-
};
|
|
1
|
+
export const $strlen = (s: string): number => {
|
|
2
|
+
let b: number;
|
|
3
|
+
let i: number;
|
|
4
|
+
let c: number;
|
|
5
|
+
for (b = i = 0; (c = s.charCodeAt(i++)); b += c >> 11 ? 3 : c >> 7 ? 2 : 1);
|
|
6
|
+
return b;
|
|
7
|
+
};
|