typia 3.4.21 → 3.4.23

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 (127) hide show
  1. package/README.md +57 -23
  2. package/lib/programmers/AssertProgrammer.js +79 -70
  3. package/lib/programmers/AssertProgrammer.js.map +1 -1
  4. package/lib/programmers/IsProgrammer.d.ts +1 -0
  5. package/lib/programmers/IsProgrammer.js +4 -0
  6. package/lib/programmers/IsProgrammer.js.map +1 -1
  7. package/lib/programmers/ValidateProgrammer.js +68 -59
  8. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  9. package/lib/programmers/helpers/OptionPredicator.d.ts +1 -0
  10. package/lib/programmers/helpers/OptionPredicator.js +4 -0
  11. package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
  12. package/lib/programmers/internal/application_schema.js +23 -21
  13. package/lib/programmers/internal/application_schema.js.map +1 -1
  14. package/lib/programmers/internal/check_dynamic_properties.js +5 -0
  15. package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
  16. package/lib/programmers/internal/check_object.d.ts +1 -0
  17. package/lib/programmers/internal/check_object.js.map +1 -1
  18. package/lib/transformers/ITransformOptions.d.ts +10 -0
  19. package/package.json +2 -2
  20. package/src/IValidation.ts +21 -21
  21. package/src/Primitive.ts +82 -82
  22. package/src/TypeGuardError.ts +36 -36
  23. package/src/executable/internal/CommandParser.ts +15 -15
  24. package/src/factories/CommentFactory.ts +10 -10
  25. package/src/factories/ExpressionFactory.ts +66 -66
  26. package/src/factories/IdentifierFactory.ts +72 -72
  27. package/src/factories/LiteralFactory.ts +44 -44
  28. package/src/factories/StatementFactory.ts +60 -60
  29. package/src/factories/TemplateFactory.ts +56 -56
  30. package/src/factories/TypeFactory.ts +101 -101
  31. package/src/factories/ValueFactory.ts +12 -12
  32. package/src/functional/$every.ts +11 -11
  33. package/src/functional/$is_email.ts +5 -5
  34. package/src/functional/$is_ipv4.ts +5 -5
  35. package/src/functional/$is_ipv6.ts +5 -5
  36. package/src/functional/$is_url.ts +5 -5
  37. package/src/functional/$is_uuid.ts +5 -5
  38. package/src/functional/$join.ts +50 -50
  39. package/src/functional/$report.ts +15 -15
  40. package/src/functional/$rest.ts +3 -3
  41. package/src/functional/$string.ts +37 -37
  42. package/src/functional/$tail.ts +6 -6
  43. package/src/index.ts +4 -4
  44. package/src/metadata/IJsDocTagInfo.ts +10 -10
  45. package/src/metadata/IMetadata.ts +25 -25
  46. package/src/metadata/IMetadataApplication.ts +7 -7
  47. package/src/metadata/IMetadataConstant.ts +16 -16
  48. package/src/metadata/IMetadataEntry.ts +6 -6
  49. package/src/metadata/IMetadataObject.ts +29 -29
  50. package/src/metadata/IMetadataProperty.ts +11 -11
  51. package/src/metadata/MetadataConstant.ts +3 -3
  52. package/src/metadata/MetadataObject.ts +131 -131
  53. package/src/metadata/MetadataProperty.ts +64 -64
  54. package/src/programmers/ApplicationProgrammer.ts +55 -55
  55. package/src/programmers/AssertProgrammer.ts +36 -29
  56. package/src/programmers/IsProgrammer.ts +5 -0
  57. package/src/programmers/ValidateProgrammer.ts +36 -29
  58. package/src/programmers/helpers/AtomicPredicator.ts +15 -15
  59. package/src/programmers/helpers/FunctionImporeter.ts +31 -31
  60. package/src/programmers/helpers/IExpressionEntry.ts +10 -10
  61. package/src/programmers/helpers/OptionPredicator.ts +4 -0
  62. package/src/programmers/helpers/StringifyJoinder.ts +111 -111
  63. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  64. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  65. package/src/programmers/internal/application_array.ts +47 -47
  66. package/src/programmers/internal/application_boolean.ts +17 -17
  67. package/src/programmers/internal/application_constant.ts +29 -29
  68. package/src/programmers/internal/application_default_string.ts +32 -32
  69. package/src/programmers/internal/application_native.ts +29 -29
  70. package/src/programmers/internal/application_number.ts +76 -76
  71. package/src/programmers/internal/application_schema.ts +9 -6
  72. package/src/programmers/internal/application_string.ts +49 -49
  73. package/src/programmers/internal/application_templates.ts +27 -27
  74. package/src/programmers/internal/application_tuple.ts +29 -29
  75. package/src/programmers/internal/check_dynamic_properties.ts +164 -146
  76. package/src/programmers/internal/check_everything.ts +25 -25
  77. package/src/programmers/internal/check_length.ts +46 -46
  78. package/src/programmers/internal/check_native.ts +9 -9
  79. package/src/programmers/internal/check_object.ts +43 -42
  80. package/src/programmers/internal/check_string.ts +24 -24
  81. package/src/programmers/internal/check_string_tags.ts +63 -63
  82. package/src/programmers/internal/check_template.ts +50 -50
  83. package/src/programmers/internal/decode_union_object.ts +73 -73
  84. package/src/programmers/internal/feature_object_entries.ts +49 -49
  85. package/src/programmers/internal/metadata_to_pattern.ts +31 -31
  86. package/src/programmers/internal/stringify_dynamic_properties.ts +164 -164
  87. package/src/programmers/internal/stringify_native.ts +8 -8
  88. package/src/programmers/internal/stringify_regular_properties.ts +81 -81
  89. package/src/programmers/internal/template_to_pattern.ts +15 -15
  90. package/src/schemas/IJsonApplication.ts +9 -9
  91. package/src/schemas/IJsonComponents.ts +26 -26
  92. package/src/transform.ts +20 -20
  93. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  94. package/src/transformers/FileTransformer.ts +49 -49
  95. package/src/transformers/IProject.ts +11 -11
  96. package/src/transformers/ITransformOptions.ts +11 -0
  97. package/src/transformers/NodeTransformer.ts +19 -19
  98. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
  99. package/src/transformers/features/parsers/AssertParseTransformer.ts +36 -36
  100. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +32 -32
  101. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +32 -32
  102. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +32 -32
  103. package/src/transformers/features/parsers/IsParseTransformer.ts +36 -36
  104. package/src/transformers/features/parsers/ValidateParseTransformer.ts +36 -36
  105. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +38 -38
  106. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +32 -32
  107. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +32 -32
  108. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +31 -31
  109. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +32 -32
  110. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +38 -38
  111. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +38 -38
  112. package/src/transformers/features/validators/AssertTransformer.ts +43 -43
  113. package/src/transformers/features/validators/CreateAssertTransformer.ts +35 -35
  114. package/src/transformers/features/validators/CreateIsTransformer.ts +35 -35
  115. package/src/transformers/features/validators/CreateValidateTransformer.ts +35 -35
  116. package/src/transformers/features/validators/IsTransformer.ts +43 -43
  117. package/src/transformers/features/validators/ValidateTransformer.ts +43 -43
  118. package/src/typings/Atomic.ts +17 -17
  119. package/src/typings/ClassProperties.ts +5 -5
  120. package/src/typings/OmitNever.ts +3 -3
  121. package/src/typings/SpecialFields.ts +3 -3
  122. package/src/typings/Writable.ts +11 -11
  123. package/src/utils/ArrayUtil.ts +49 -49
  124. package/src/utils/Escaper.ts +50 -50
  125. package/src/utils/MapUtil.ts +14 -14
  126. package/src/utils/PatternUtil.ts +30 -30
  127. package/src/utils/Singleton.ts +17 -17
@@ -1,101 +1,101 @@
1
- import ts from "typescript";
2
-
3
- export namespace TypeFactory {
4
- export function resolve(
5
- checker: ts.TypeChecker,
6
- type: ts.Type,
7
- ): ts.Type | null {
8
- return getReturnType(checker, type, "toJSON");
9
- }
10
-
11
- export function isFunction(type: ts.Type): boolean {
12
- return getFunction(type) !== null;
13
- }
14
- function getFunction(type: ts.Type) {
15
- const node = type.symbol?.declarations?.[0];
16
- if (node === undefined) return null;
17
-
18
- return ts.isFunctionLike(node)
19
- ? node
20
- : ts.isPropertyAssignment(node) || ts.isPropertyDeclaration(node)
21
- ? ts.isFunctionLike(node.initializer)
22
- ? node.initializer
23
- : null
24
- : null;
25
- }
26
-
27
- export function getReturnType(
28
- checker: ts.TypeChecker,
29
- type: ts.Type,
30
- name: string,
31
- ): ts.Type | null {
32
- // FIND TO-JSON METHOD
33
- const symbol: ts.Symbol | undefined = type.getProperty(name);
34
- if (!symbol) return null;
35
- else if (!symbol.valueDeclaration) return null;
36
-
37
- // GET FUNCTION DECLARATION
38
- const functor: ts.Type = checker.getTypeOfSymbolAtLocation(
39
- symbol,
40
- symbol.valueDeclaration,
41
- );
42
-
43
- // RETURNS THE RETURN-TYPE
44
- const signature: ts.Signature | undefined = checker.getSignaturesOfType(
45
- functor,
46
- ts.SignatureKind.Call,
47
- )[0];
48
- return signature ? signature.getReturnType() : null;
49
- }
50
-
51
- export function getFullName(
52
- checker: ts.TypeChecker,
53
- type: ts.Type,
54
- symbol?: ts.Symbol,
55
- ): string {
56
- // PRIMITIVE
57
- symbol ||= type.aliasSymbol || type.getSymbol();
58
- if (symbol === undefined) return checker.typeToString(type);
59
-
60
- // UNION OR INTERSECT
61
- if (type.aliasSymbol === undefined && type.isUnionOrIntersection()) {
62
- const joiner: string = type.isIntersection() ? " & " : " | ";
63
- return type.types
64
- .map((child) => getFullName(checker, child))
65
- .join(joiner);
66
- }
67
-
68
- //----
69
- // SPECIALIZATION
70
- //----
71
- const name: string = get_name(symbol);
72
-
73
- // CHECK GENERIC
74
- const generic: readonly ts.Type[] = type.aliasSymbol
75
- ? type.aliasTypeArguments || []
76
- : checker.getTypeArguments(type as ts.TypeReference);
77
- return generic.length
78
- ? name === "Promise"
79
- ? getFullName(checker, generic[0]!)
80
- : `${name}<${generic
81
- .map((child) => getFullName(checker, child))
82
- .join(", ")}>`
83
- : name;
84
- }
85
-
86
- function explore_name(name: string, decl: ts.Node): string {
87
- return ts.isModuleBlock(decl)
88
- ? explore_name(
89
- `${decl.parent.name.getText()}.${name}`,
90
- decl.parent.parent,
91
- )
92
- : name;
93
- }
94
-
95
- function get_name(symbol: ts.Symbol): string {
96
- const parent = symbol.getDeclarations()?.[0]?.parent;
97
- return parent
98
- ? explore_name(symbol.escapedName.toString(), parent)
99
- : "__type";
100
- }
101
- }
1
+ import ts from "typescript";
2
+
3
+ export namespace TypeFactory {
4
+ export function resolve(
5
+ checker: ts.TypeChecker,
6
+ type: ts.Type,
7
+ ): ts.Type | null {
8
+ return getReturnType(checker, type, "toJSON");
9
+ }
10
+
11
+ export function isFunction(type: ts.Type): boolean {
12
+ return getFunction(type) !== null;
13
+ }
14
+ function getFunction(type: ts.Type) {
15
+ const node = type.symbol?.declarations?.[0];
16
+ if (node === undefined) return null;
17
+
18
+ return ts.isFunctionLike(node)
19
+ ? node
20
+ : ts.isPropertyAssignment(node) || ts.isPropertyDeclaration(node)
21
+ ? ts.isFunctionLike(node.initializer)
22
+ ? node.initializer
23
+ : null
24
+ : null;
25
+ }
26
+
27
+ export function getReturnType(
28
+ checker: ts.TypeChecker,
29
+ type: ts.Type,
30
+ name: string,
31
+ ): ts.Type | null {
32
+ // FIND TO-JSON METHOD
33
+ const symbol: ts.Symbol | undefined = type.getProperty(name);
34
+ if (!symbol) return null;
35
+ else if (!symbol.valueDeclaration) return null;
36
+
37
+ // GET FUNCTION DECLARATION
38
+ const functor: ts.Type = checker.getTypeOfSymbolAtLocation(
39
+ symbol,
40
+ symbol.valueDeclaration,
41
+ );
42
+
43
+ // RETURNS THE RETURN-TYPE
44
+ const signature: ts.Signature | undefined = checker.getSignaturesOfType(
45
+ functor,
46
+ ts.SignatureKind.Call,
47
+ )[0];
48
+ return signature ? signature.getReturnType() : null;
49
+ }
50
+
51
+ export function getFullName(
52
+ checker: ts.TypeChecker,
53
+ type: ts.Type,
54
+ symbol?: ts.Symbol,
55
+ ): string {
56
+ // PRIMITIVE
57
+ symbol ||= type.aliasSymbol || type.getSymbol();
58
+ if (symbol === undefined) return checker.typeToString(type);
59
+
60
+ // UNION OR INTERSECT
61
+ if (type.aliasSymbol === undefined && type.isUnionOrIntersection()) {
62
+ const joiner: string = type.isIntersection() ? " & " : " | ";
63
+ return type.types
64
+ .map((child) => getFullName(checker, child))
65
+ .join(joiner);
66
+ }
67
+
68
+ //----
69
+ // SPECIALIZATION
70
+ //----
71
+ const name: string = get_name(symbol);
72
+
73
+ // CHECK GENERIC
74
+ const generic: readonly ts.Type[] = type.aliasSymbol
75
+ ? type.aliasTypeArguments || []
76
+ : checker.getTypeArguments(type as ts.TypeReference);
77
+ return generic.length
78
+ ? name === "Promise"
79
+ ? getFullName(checker, generic[0]!)
80
+ : `${name}<${generic
81
+ .map((child) => getFullName(checker, child))
82
+ .join(", ")}>`
83
+ : name;
84
+ }
85
+
86
+ function explore_name(name: string, decl: ts.Node): string {
87
+ return ts.isModuleBlock(decl)
88
+ ? explore_name(
89
+ `${decl.parent.name.getText()}.${name}`,
90
+ decl.parent.parent,
91
+ )
92
+ : name;
93
+ }
94
+
95
+ function get_name(symbol: ts.Symbol): string {
96
+ const parent = symbol.getDeclarations()?.[0]?.parent;
97
+ return parent
98
+ ? explore_name(symbol.escapedName.toString(), parent)
99
+ : "__type";
100
+ }
101
+ }
@@ -1,12 +1,12 @@
1
- import ts from "typescript";
2
-
3
- export namespace ValueFactory {
4
- export const NULL = () => ts.factory.createNull();
5
- export const UNDEFINED = () => ts.factory.createIdentifier("undefined");
6
- export const BOOLEAN = (value: boolean) =>
7
- value ? ts.factory.createTrue() : ts.factory.createFalse();
8
- export const INPUT = (str: string = "input") =>
9
- ts.factory.createIdentifier(str);
10
- export const TYPEOF = (input: ts.Expression) =>
11
- ts.factory.createTypeOfExpression(input);
12
- }
1
+ import ts from "typescript";
2
+
3
+ export namespace ValueFactory {
4
+ export const NULL = () => ts.factory.createNull();
5
+ export const UNDEFINED = () => ts.factory.createIdentifier("undefined");
6
+ export const BOOLEAN = (value: boolean) =>
7
+ value ? ts.factory.createTrue() : ts.factory.createFalse();
8
+ export const INPUT = (str: string = "input") =>
9
+ ts.factory.createIdentifier(str);
10
+ export const TYPEOF = (input: ts.Expression) =>
11
+ ts.factory.createTypeOfExpression(input);
12
+ }
@@ -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
+ };
@@ -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}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/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}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/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,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
+ }
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
+ }