typia 3.6.9 → 3.6.10

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.
Files changed (205) hide show
  1. package/lib/factories/TypiaFileFactory.js +61 -54
  2. package/lib/factories/TypiaFileFactory.js.map +1 -1
  3. package/package.json +10 -8
  4. package/src/IRandomGenerator.ts +17 -17
  5. package/src/IValidation.ts +21 -21
  6. package/src/Primitive.ts +104 -104
  7. package/src/TypeGuardError.ts +36 -36
  8. package/src/executable/TypiaGenerateWizard.ts +87 -87
  9. package/src/executable/TypiaSetupWizard.ts +152 -152
  10. package/src/executable/setup/ArgumentParser.ts +91 -91
  11. package/src/executable/setup/CommandExecutor.ts +8 -8
  12. package/src/executable/setup/FileRetriever.ts +33 -33
  13. package/src/executable/setup/PackageManager.ts +92 -92
  14. package/src/executable/setup/PluginConfigurator.ts +99 -99
  15. package/src/executable/typia.ts +38 -38
  16. package/src/factories/CommentFactory.ts +10 -10
  17. package/src/factories/ExpressionFactory.ts +77 -77
  18. package/src/factories/IdentifierFactory.ts +73 -73
  19. package/src/factories/LiteralFactory.ts +44 -44
  20. package/src/factories/MetadataCollection.ts +122 -122
  21. package/src/factories/MetadataFactory.ts +51 -51
  22. package/src/factories/MetadataTagFactory.ts +276 -276
  23. package/src/factories/StatementFactory.ts +60 -60
  24. package/src/factories/TemplateFactory.ts +56 -56
  25. package/src/factories/TypeFactory.ts +129 -129
  26. package/src/factories/TypiaFileFactory.ts +120 -117
  27. package/src/factories/ValueFactory.ts +12 -12
  28. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  29. package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -142
  30. package/src/factories/internal/metadata/explore_metadata.ts +92 -92
  31. package/src/factories/internal/metadata/iterate_metadata.ts +80 -80
  32. package/src/factories/internal/metadata/iterate_metadata_array.ts +29 -29
  33. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
  34. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  35. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  36. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  37. package/src/factories/internal/metadata/iterate_metadata_native.ts +222 -222
  38. package/src/factories/internal/metadata/iterate_metadata_object.ts +48 -48
  39. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
  40. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  41. package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
  42. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +45 -45
  43. package/src/factories/internal/metadata/iterate_metadata_union.ts +59 -59
  44. package/src/functional/$any.ts +3 -3
  45. package/src/functional/$every.ts +11 -11
  46. package/src/functional/$guard.ts +35 -35
  47. package/src/functional/$is_between.ts +7 -7
  48. package/src/functional/$is_date.ts +4 -4
  49. package/src/functional/$is_datetime.ts +3 -3
  50. package/src/functional/$is_email.ts +5 -5
  51. package/src/functional/$is_ipv4.ts +5 -5
  52. package/src/functional/$is_ipv6.ts +5 -5
  53. package/src/functional/$is_url.ts +5 -5
  54. package/src/functional/$is_uuid.ts +5 -5
  55. package/src/functional/$join.ts +50 -50
  56. package/src/functional/$number.ts +12 -12
  57. package/src/functional/$report.ts +15 -15
  58. package/src/functional/$rest.ts +3 -3
  59. package/src/functional/$string.ts +37 -37
  60. package/src/functional/$tail.ts +6 -6
  61. package/src/functional/Namespace.ts +125 -125
  62. package/src/index.ts +4 -4
  63. package/src/metadata/IJsDocTagInfo.ts +10 -10
  64. package/src/metadata/IMetadata.ts +25 -25
  65. package/src/metadata/IMetadataApplication.ts +7 -7
  66. package/src/metadata/IMetadataConstant.ts +16 -16
  67. package/src/metadata/IMetadataEntry.ts +6 -6
  68. package/src/metadata/IMetadataObject.ts +29 -29
  69. package/src/metadata/IMetadataProperty.ts +11 -11
  70. package/src/metadata/IMetadataTag.ts +105 -105
  71. package/src/metadata/Metadata.ts +534 -534
  72. package/src/metadata/MetadataConstant.ts +3 -3
  73. package/src/metadata/MetadataObject.ts +131 -131
  74. package/src/metadata/MetadataProperty.ts +64 -64
  75. package/src/module.ts +1946 -1946
  76. package/src/programmers/ApplicationProgrammer.ts +55 -55
  77. package/src/programmers/AssertCloneProgrammer.ts +70 -70
  78. package/src/programmers/AssertParseProgrammer.ts +65 -65
  79. package/src/programmers/AssertProgrammer.ts +232 -232
  80. package/src/programmers/AssertPruneProgrammer.ts +67 -67
  81. package/src/programmers/AssertStringifyProgrammer.ts +71 -71
  82. package/src/programmers/CheckerProgrammer.ts +893 -893
  83. package/src/programmers/CloneProgrammer.ts +386 -386
  84. package/src/programmers/FeatureProgrammer.ts +505 -505
  85. package/src/programmers/IsCloneProgrammer.ts +80 -80
  86. package/src/programmers/IsParseProgrammer.ts +74 -74
  87. package/src/programmers/IsProgrammer.ts +200 -200
  88. package/src/programmers/IsPruneProgrammer.ts +75 -75
  89. package/src/programmers/IsStringifyProgrammer.ts +81 -81
  90. package/src/programmers/PruneProgrammer.ts +341 -341
  91. package/src/programmers/RandomProgrammer.ts +388 -388
  92. package/src/programmers/StringifyProgrammer.ts +795 -795
  93. package/src/programmers/ValidateCloneProgrammer.ts +90 -90
  94. package/src/programmers/ValidateParseProgrammer.ts +69 -69
  95. package/src/programmers/ValidateProgrammer.ts +266 -266
  96. package/src/programmers/ValidatePruneProgrammer.ts +83 -83
  97. package/src/programmers/ValidateStringifyProgrammer.ts +89 -89
  98. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  99. package/src/programmers/helpers/CloneJoiner.ts +134 -134
  100. package/src/programmers/helpers/FunctionImporeter.ts +55 -55
  101. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  102. package/src/programmers/helpers/OptionPredicator.ts +19 -19
  103. package/src/programmers/helpers/PruneJoiner.ts +52 -52
  104. package/src/programmers/helpers/RandomJoiner.ts +149 -149
  105. package/src/programmers/helpers/RandomRanger.ts +216 -216
  106. package/src/programmers/helpers/StringifyJoinder.ts +114 -114
  107. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  108. package/src/programmers/helpers/UnionExplorer.ts +274 -274
  109. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  110. package/src/programmers/internal/application_array.ts +37 -37
  111. package/src/programmers/internal/application_boolean.ts +17 -17
  112. package/src/programmers/internal/application_constant.ts +29 -29
  113. package/src/programmers/internal/application_default.ts +17 -17
  114. package/src/programmers/internal/application_default_string.ts +32 -32
  115. package/src/programmers/internal/application_native.ts +29 -29
  116. package/src/programmers/internal/application_number.ts +73 -73
  117. package/src/programmers/internal/application_object.ts +153 -153
  118. package/src/programmers/internal/application_schema.ts +184 -184
  119. package/src/programmers/internal/application_string.ts +45 -45
  120. package/src/programmers/internal/application_templates.ts +27 -27
  121. package/src/programmers/internal/application_tuple.ts +29 -29
  122. package/src/programmers/internal/check_array.ts +22 -22
  123. package/src/programmers/internal/check_array_length.ts +44 -44
  124. package/src/programmers/internal/check_bigint.ts +64 -64
  125. package/src/programmers/internal/check_dynamic_properties.ts +197 -197
  126. package/src/programmers/internal/check_everything.ts +28 -28
  127. package/src/programmers/internal/check_native.ts +21 -21
  128. package/src/programmers/internal/check_number.ts +145 -145
  129. package/src/programmers/internal/check_object.ts +48 -48
  130. package/src/programmers/internal/check_string.ts +24 -24
  131. package/src/programmers/internal/check_string_tags.ts +63 -63
  132. package/src/programmers/internal/check_template.ts +50 -50
  133. package/src/programmers/internal/check_union_array_like.ts +260 -260
  134. package/src/programmers/internal/check_union_tuple.ts +33 -33
  135. package/src/programmers/internal/decode_union_object.ts +73 -73
  136. package/src/programmers/internal/feature_object_entries.ts +59 -59
  137. package/src/programmers/internal/metadata_to_pattern.ts +31 -31
  138. package/src/programmers/internal/prune_object_properties.ts +60 -60
  139. package/src/programmers/internal/stringify_dynamic_properties.ts +165 -165
  140. package/src/programmers/internal/stringify_native.ts +8 -8
  141. package/src/programmers/internal/stringify_regular_properties.ts +81 -81
  142. package/src/programmers/internal/template_to_pattern.ts +15 -15
  143. package/src/schemas/IJsonApplication.ts +9 -9
  144. package/src/schemas/IJsonComponents.ts +26 -26
  145. package/src/schemas/IJsonSchema.ts +121 -121
  146. package/src/transform.ts +21 -21
  147. package/src/transformers/CallExpressionTransformer.ts +172 -172
  148. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  149. package/src/transformers/FileTransformer.ts +49 -49
  150. package/src/transformers/IProject.ts +11 -11
  151. package/src/transformers/ITransformOptions.ts +62 -62
  152. package/src/transformers/ImportTransformer.ts +60 -60
  153. package/src/transformers/NodeTransformer.ts +19 -19
  154. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +120 -120
  155. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  156. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  157. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  158. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  159. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  160. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  161. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  162. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  163. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  164. package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +42 -42
  165. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  166. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  167. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  168. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  169. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
  170. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  171. package/src/transformers/features/miscellaneous/RandomTransformer.ts +48 -48
  172. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  173. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  174. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  175. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  176. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  177. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  178. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  179. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  180. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  181. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +9 -9
  182. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  183. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  184. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +11 -11
  185. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  186. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  187. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  188. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  189. package/src/transformers/features/validators/CreateAssertTransformer.ts +12 -12
  190. package/src/transformers/features/validators/CreateIsTransformer.ts +10 -10
  191. package/src/transformers/features/validators/CreateValidateTransformer.ts +12 -12
  192. package/src/transformers/features/validators/IsTransformer.ts +10 -10
  193. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  194. package/src/transformers/internal/GenericTransformer.ts +99 -99
  195. package/src/typings/Atomic.ts +17 -17
  196. package/src/typings/ClassProperties.ts +5 -5
  197. package/src/typings/OmitNever.ts +3 -3
  198. package/src/typings/SpecialFields.ts +3 -3
  199. package/src/typings/Writable.ts +11 -11
  200. package/src/utils/ArrayUtil.ts +49 -49
  201. package/src/utils/Escaper.ts +50 -50
  202. package/src/utils/MapUtil.ts +14 -14
  203. package/src/utils/PatternUtil.ts +30 -30
  204. package/src/utils/RandomGenerator.ts +96 -96
  205. package/src/utils/Singleton.ts +17 -17
@@ -1,5 +1,5 @@
1
- export function $is_email(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
1
+ export function $is_email(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
@@ -1,5 +1,5 @@
1
- export function $is_ipv4(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
1
+ export function $is_ipv4(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
@@ -1,5 +1,5 @@
1
- export function $is_ipv6(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
1
+ export function $is_ipv6(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
@@ -1,5 +1,5 @@
1
- export function $is_url(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^[a-zA-Z0-9]+:\/\/(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/;
1
+ export function $is_url(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^[a-zA-Z0-9]+:\/\/(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/;
@@ -1,5 +1,5 @@
1
- export function $is_uuid(str: string): boolean {
2
- return REGEX.test(str);
3
- }
4
- const REGEX =
5
- /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
1
+ export function $is_uuid(str: string): boolean {
2
+ return REGEX.test(str);
3
+ }
4
+ const REGEX =
5
+ /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
@@ -1,50 +1,50 @@
1
- export function $join(str: string): string {
2
- return variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
3
- }
4
-
5
- function variable(str: string): boolean {
6
- return reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
7
- }
8
-
9
- function reserved(str: string): boolean {
10
- return RESERVED.has(str);
11
- }
12
-
13
- const RESERVED: Set<string> = new Set([
14
- "break",
15
- "case",
16
- "catch",
17
- "class",
18
- "const",
19
- "continue",
20
- "debugger",
21
- "default",
22
- "delete",
23
- "do",
24
- "else",
25
- "enum",
26
- "export",
27
- "extends",
28
- "false",
29
- "finally",
30
- "for",
31
- "function",
32
- "if",
33
- "import",
34
- "in",
35
- "instanceof",
36
- "new",
37
- "null",
38
- "return",
39
- "super",
40
- "switch",
41
- "this",
42
- "throw",
43
- "true",
44
- "try",
45
- "typeof",
46
- "var",
47
- "void",
48
- "while",
49
- "with",
50
- ]);
1
+ export function $join(str: string): string {
2
+ return variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
3
+ }
4
+
5
+ function variable(str: string): boolean {
6
+ return reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
7
+ }
8
+
9
+ function reserved(str: string): boolean {
10
+ return RESERVED.has(str);
11
+ }
12
+
13
+ const RESERVED: Set<string> = new Set([
14
+ "break",
15
+ "case",
16
+ "catch",
17
+ "class",
18
+ "const",
19
+ "continue",
20
+ "debugger",
21
+ "default",
22
+ "delete",
23
+ "do",
24
+ "else",
25
+ "enum",
26
+ "export",
27
+ "extends",
28
+ "false",
29
+ "finally",
30
+ "for",
31
+ "function",
32
+ "if",
33
+ "import",
34
+ "in",
35
+ "instanceof",
36
+ "new",
37
+ "null",
38
+ "return",
39
+ "super",
40
+ "switch",
41
+ "this",
42
+ "throw",
43
+ "true",
44
+ "try",
45
+ "typeof",
46
+ "var",
47
+ "void",
48
+ "while",
49
+ "with",
50
+ ]);
@@ -1,12 +1,12 @@
1
- import { TypeGuardError } from "../TypeGuardError";
2
-
3
- export function $number(value: number): number {
4
- if (isFinite(value) === false)
5
- throw new TypeGuardError({
6
- method: "typia.stringify",
7
- expected: "number",
8
- value,
9
- message: "Error on typia.stringify(): infinite or not a number.",
10
- });
11
- return value;
12
- }
1
+ import { TypeGuardError } from "../TypeGuardError";
2
+
3
+ export function $number(value: number): number {
4
+ if (isFinite(value) === false)
5
+ throw new TypeGuardError({
6
+ method: "typia.stringify",
7
+ expected: "number",
8
+ value,
9
+ message: "Error on typia.stringify(): infinite or not a number.",
10
+ });
11
+ return value;
12
+ }
@@ -1,15 +1,15 @@
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 (
8
- path.length > last.length || last.substring(0, path.length) !== path
9
- );
10
- };
11
- return (exceptable: boolean, error: IValidation.IError): false => {
12
- if (exceptable && reportable(error.path)) array.push(error);
13
- return false;
14
- };
15
- };
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 (
8
+ path.length > last.length || last.substring(0, path.length) !== path
9
+ );
10
+ };
11
+ return (exceptable: boolean, error: IValidation.IError): false => {
12
+ if (exceptable && reportable(error.path)) array.push(error);
13
+ return false;
14
+ };
15
+ };
@@ -1,3 +1,3 @@
1
- export function $rest(str: string): string {
2
- return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
3
- }
1
+ export function $rest(str: string): string {
2
+ return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
3
+ }
@@ -1,37 +1,37 @@
1
- /**
2
- * @internal
3
- */
4
- export function $string(str: string): string {
5
- if (str.length > 41) return JSON.stringify(str);
6
-
7
- const length = str.length;
8
- let result = "";
9
- let last = 0;
10
- let found = false;
11
- let surrogateFound = false;
12
- let point = 255;
13
-
14
- // eslint-disable-next-line
15
- for (let i = 0; i < length && point >= 32; i++) {
16
- point = str.charCodeAt(i);
17
- if (0xd800 <= point && point <= 0xdfff) {
18
- // The current character is a surrogate.
19
- surrogateFound = true;
20
- break;
21
- }
22
- if (point === 34 || point === 92) {
23
- result += str.slice(last, i) + "\\";
24
- last = i;
25
- found = true;
26
- }
27
- }
28
-
29
- if (!found) {
30
- result = str;
31
- } else {
32
- result += str.slice(last);
33
- }
34
- return point < 32 || surrogateFound === true
35
- ? JSON.stringify(str)
36
- : `"${result}"`;
37
- }
1
+ /**
2
+ * @internal
3
+ */
4
+ export function $string(str: string): string {
5
+ if (str.length > 41) return JSON.stringify(str);
6
+
7
+ const length = str.length;
8
+ let result = "";
9
+ let last = 0;
10
+ let found = false;
11
+ let surrogateFound = false;
12
+ let point = 255;
13
+
14
+ // eslint-disable-next-line
15
+ for (let i = 0; i < length && point >= 32; i++) {
16
+ point = str.charCodeAt(i);
17
+ if (0xd800 <= point && point <= 0xdfff) {
18
+ // The current character is a surrogate.
19
+ surrogateFound = true;
20
+ break;
21
+ }
22
+ if (point === 34 || point === 92) {
23
+ result += str.slice(last, i) + "\\";
24
+ last = i;
25
+ found = true;
26
+ }
27
+ }
28
+
29
+ if (!found) {
30
+ result = str;
31
+ } else {
32
+ result += str.slice(last);
33
+ }
34
+ return point < 32 || surrogateFound === true
35
+ ? JSON.stringify(str)
36
+ : `"${result}"`;
37
+ }
@@ -1,6 +1,6 @@
1
- /**
2
- * @internal
3
- */
4
- export function $tail(str: string): string {
5
- return str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
6
- }
1
+ /**
2
+ * @internal
3
+ */
4
+ export function $tail(str: string): string {
5
+ return str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
6
+ }
@@ -1,125 +1,125 @@
1
- import { RandomGenerator } from "../utils/RandomGenerator";
2
-
3
- import { IValidation } from "../IValidation";
4
- import { TypeGuardError } from "../TypeGuardError";
5
- import { $any } from "./$any";
6
- import { $every } from "./$every";
7
- import { $guard } from "./$guard";
8
- import { $is_between } from "./$is_between";
9
- import { $is_date } from "./$is_date";
10
- import { $is_datetime } from "./$is_datetime";
11
- import { $is_email } from "./$is_email";
12
- import { $is_ipv4 } from "./$is_ipv4";
13
- import { $is_ipv6 } from "./$is_ipv6";
14
- import { $is_url } from "./$is_url";
15
- import { $is_uuid } from "./$is_uuid";
16
- import { $join } from "./$join";
17
- import { $number } from "./$number";
18
- import { $report } from "./$report";
19
- import { $rest } from "./$rest";
20
- import { $string } from "./$string";
21
- import { $tail } from "./$tail";
22
-
23
- /**
24
- * @internal
25
- */
26
- export namespace Namespace {
27
- export const is = () => ({
28
- is_uuid: $is_uuid,
29
- is_email: $is_email,
30
- is_url: $is_url,
31
- is_ipv4: $is_ipv4,
32
- is_ipv6: $is_ipv6,
33
- is_between: $is_between,
34
- is_date: $is_date,
35
- is_datetime: $is_datetime,
36
- });
37
-
38
- export const assert = (method: string) => ({
39
- ...is(),
40
- join: $join,
41
- every: $every,
42
- guard: $guard(`typia.${method}`),
43
- predicate: (
44
- matched: boolean,
45
- exceptionable: boolean,
46
- closure: () => Omit<TypeGuardError.IProps, "method">,
47
- ): boolean => {
48
- if (matched === false && exceptionable === true)
49
- throw new TypeGuardError({
50
- ...closure(),
51
- method: `typia.${method}`,
52
- });
53
- return matched;
54
- },
55
- });
56
-
57
- export const validate = () => ({
58
- ...is(),
59
- join: $join,
60
- report: $report,
61
- predicate:
62
- (res: IValidation) =>
63
- (
64
- matched: boolean,
65
- exceptionable: boolean,
66
- closure: () => IValidation.IError,
67
- ) => {
68
- // CHECK FAILURE
69
- if (matched === false && exceptionable === true)
70
- (() => {
71
- res.success &&= false;
72
- const errorList = (res as IValidation.IFailure).errors;
73
-
74
- // TRACE ERROR
75
- const error = closure();
76
- if (errorList.length) {
77
- const last = errorList[errorList.length - 1]!.path;
78
- if (
79
- last.length >= error.path.length &&
80
- last.substring(0, error.path.length) ===
81
- error.path
82
- )
83
- return;
84
- }
85
- errorList.push(error);
86
- return;
87
- })();
88
- return matched;
89
- },
90
- });
91
-
92
- export const stringify = (method: string) => ({
93
- ...is(),
94
- number: $number,
95
- string: $string,
96
- tail: $tail,
97
- rest: $rest,
98
- throws: $throws(method),
99
- });
100
-
101
- export const clone = (method: string) => ({
102
- ...is(),
103
- throws: $throws(method),
104
- any: $any,
105
- });
106
-
107
- export const prune = (method: string) => ({
108
- ...is(),
109
- throws: $throws(method),
110
- });
111
-
112
- export const random = () => ({
113
- generator: RandomGenerator,
114
- pick: RandomGenerator.pick,
115
- });
116
-
117
- const $throws =
118
- (method: string) =>
119
- (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
120
- throw new TypeGuardError({
121
- ...props,
122
- method: `typia.${method}`,
123
- });
124
- };
125
- }
1
+ import { RandomGenerator } from "../utils/RandomGenerator";
2
+
3
+ import { IValidation } from "../IValidation";
4
+ import { TypeGuardError } from "../TypeGuardError";
5
+ import { $any } from "./$any";
6
+ import { $every } from "./$every";
7
+ import { $guard } from "./$guard";
8
+ import { $is_between } from "./$is_between";
9
+ import { $is_date } from "./$is_date";
10
+ import { $is_datetime } from "./$is_datetime";
11
+ import { $is_email } from "./$is_email";
12
+ import { $is_ipv4 } from "./$is_ipv4";
13
+ import { $is_ipv6 } from "./$is_ipv6";
14
+ import { $is_url } from "./$is_url";
15
+ import { $is_uuid } from "./$is_uuid";
16
+ import { $join } from "./$join";
17
+ import { $number } from "./$number";
18
+ import { $report } from "./$report";
19
+ import { $rest } from "./$rest";
20
+ import { $string } from "./$string";
21
+ import { $tail } from "./$tail";
22
+
23
+ /**
24
+ * @internal
25
+ */
26
+ export namespace Namespace {
27
+ export const is = () => ({
28
+ is_uuid: $is_uuid,
29
+ is_email: $is_email,
30
+ is_url: $is_url,
31
+ is_ipv4: $is_ipv4,
32
+ is_ipv6: $is_ipv6,
33
+ is_between: $is_between,
34
+ is_date: $is_date,
35
+ is_datetime: $is_datetime,
36
+ });
37
+
38
+ export const assert = (method: string) => ({
39
+ ...is(),
40
+ join: $join,
41
+ every: $every,
42
+ guard: $guard(`typia.${method}`),
43
+ predicate: (
44
+ matched: boolean,
45
+ exceptionable: boolean,
46
+ closure: () => Omit<TypeGuardError.IProps, "method">,
47
+ ): boolean => {
48
+ if (matched === false && exceptionable === true)
49
+ throw new TypeGuardError({
50
+ ...closure(),
51
+ method: `typia.${method}`,
52
+ });
53
+ return matched;
54
+ },
55
+ });
56
+
57
+ export const validate = () => ({
58
+ ...is(),
59
+ join: $join,
60
+ report: $report,
61
+ predicate:
62
+ (res: IValidation) =>
63
+ (
64
+ matched: boolean,
65
+ exceptionable: boolean,
66
+ closure: () => IValidation.IError,
67
+ ) => {
68
+ // CHECK FAILURE
69
+ if (matched === false && exceptionable === true)
70
+ (() => {
71
+ res.success &&= false;
72
+ const errorList = (res as IValidation.IFailure).errors;
73
+
74
+ // TRACE ERROR
75
+ const error = closure();
76
+ if (errorList.length) {
77
+ const last = errorList[errorList.length - 1]!.path;
78
+ if (
79
+ last.length >= error.path.length &&
80
+ last.substring(0, error.path.length) ===
81
+ error.path
82
+ )
83
+ return;
84
+ }
85
+ errorList.push(error);
86
+ return;
87
+ })();
88
+ return matched;
89
+ },
90
+ });
91
+
92
+ export const stringify = (method: string) => ({
93
+ ...is(),
94
+ number: $number,
95
+ string: $string,
96
+ tail: $tail,
97
+ rest: $rest,
98
+ throws: $throws(method),
99
+ });
100
+
101
+ export const clone = (method: string) => ({
102
+ ...is(),
103
+ throws: $throws(method),
104
+ any: $any,
105
+ });
106
+
107
+ export const prune = (method: string) => ({
108
+ ...is(),
109
+ throws: $throws(method),
110
+ });
111
+
112
+ export const random = () => ({
113
+ generator: RandomGenerator,
114
+ pick: RandomGenerator.pick,
115
+ });
116
+
117
+ const $throws =
118
+ (method: string) =>
119
+ (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
120
+ throw new TypeGuardError({
121
+ ...props,
122
+ method: `typia.${method}`,
123
+ });
124
+ };
125
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as typia from "./module";
2
-
3
- export default typia;
4
- export * from "./module";
1
+ import * as typia from "./module";
2
+
3
+ export default typia;
4
+ export * from "./module";
@@ -1,10 +1,10 @@
1
- export interface IJsDocTagInfo {
2
- name: string;
3
- text?: IJsDocTagInfo.IText[];
4
- }
5
- export namespace IJsDocTagInfo {
6
- export interface IText {
7
- text: string;
8
- kind: string;
9
- }
10
- }
1
+ export interface IJsDocTagInfo {
2
+ name: string;
3
+ text?: IJsDocTagInfo.IText[];
4
+ }
5
+ export namespace IJsDocTagInfo {
6
+ export interface IText {
7
+ text: string;
8
+ kind: string;
9
+ }
10
+ }
@@ -1,25 +1,25 @@
1
- import { Atomic } from "../typings/Atomic";
2
-
3
- import { IMetadataConstant } from "./IMetadataConstant";
4
- import { IMetadataEntry } from "./IMetadataEntry";
5
-
6
- export interface IMetadata {
7
- any: boolean;
8
- required: boolean;
9
- nullable: boolean;
10
- functional: boolean;
11
-
12
- atomics: Atomic.Literal[];
13
- constants: IMetadataConstant[];
14
- templates: IMetadata[][];
15
- resolved: IMetadata | null;
16
-
17
- rest: IMetadata | null;
18
- arrays: IMetadata[];
19
- tuples: IMetadata[][];
20
- objects: string[];
21
-
22
- natives: string[];
23
- sets: IMetadata[];
24
- maps: IMetadataEntry[];
25
- }
1
+ import { Atomic } from "../typings/Atomic";
2
+
3
+ import { IMetadataConstant } from "./IMetadataConstant";
4
+ import { IMetadataEntry } from "./IMetadataEntry";
5
+
6
+ export interface IMetadata {
7
+ any: boolean;
8
+ required: boolean;
9
+ nullable: boolean;
10
+ functional: boolean;
11
+
12
+ atomics: Atomic.Literal[];
13
+ constants: IMetadataConstant[];
14
+ templates: IMetadata[][];
15
+ resolved: IMetadata | null;
16
+
17
+ rest: IMetadata | null;
18
+ arrays: IMetadata[];
19
+ tuples: IMetadata[][];
20
+ objects: string[];
21
+
22
+ natives: string[];
23
+ sets: IMetadata[];
24
+ maps: IMetadataEntry[];
25
+ }
@@ -1,7 +1,7 @@
1
- import { IMetadata } from "./IMetadata";
2
- import { IMetadataObject } from "./IMetadataObject";
3
-
4
- export interface IMetadataApplication {
5
- metadatas: IMetadata[];
6
- collection: IMetadataObject[];
7
- }
1
+ import { IMetadata } from "./IMetadata";
2
+ import { IMetadataObject } from "./IMetadataObject";
3
+
4
+ export interface IMetadataApplication {
5
+ metadatas: IMetadata[];
6
+ collection: IMetadataObject[];
7
+ }