typia 12.0.0-dev.20260309 → 12.0.0-dev.20260311

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 (134) hide show
  1. package/lib/executable/setup/PluginConfigurator.js +3 -3
  2. package/lib/executable/setup/PluginConfigurator.mjs +3 -3
  3. package/lib/executable/setup/PluginConfigurator.mjs.map +1 -1
  4. package/lib/executable/typia.js +15 -15
  5. package/lib/executable/typia.mjs +15 -15
  6. package/package.json +5 -5
  7. package/src/TypeGuardError.ts +145 -145
  8. package/src/executable/TypiaGenerateWizard.ts +82 -82
  9. package/src/executable/TypiaPatchWizard.ts +45 -45
  10. package/src/executable/TypiaSetupWizard.ts +171 -171
  11. package/src/executable/setup/ArgumentParser.ts +42 -42
  12. package/src/executable/setup/CommandExecutor.ts +8 -8
  13. package/src/executable/setup/FileRetriever.ts +19 -19
  14. package/src/executable/setup/PackageManager.ts +87 -87
  15. package/src/executable/setup/PluginConfigurator.ts +74 -74
  16. package/src/executable/typia.ts +55 -55
  17. package/src/functional.ts +600 -600
  18. package/src/http.ts +843 -843
  19. package/src/index.ts +4 -4
  20. package/src/internal/_IProtobufWriter.ts +18 -18
  21. package/src/internal/_ProtobufReader.ts +187 -187
  22. package/src/internal/_ProtobufSizer.ts +137 -137
  23. package/src/internal/_ProtobufWriter.ts +135 -135
  24. package/src/internal/_accessExpressionAsString.ts +46 -46
  25. package/src/internal/_assertGuard.ts +13 -13
  26. package/src/internal/_coerceLlmArguments.ts +7 -7
  27. package/src/internal/_createStandardSchema.ts +133 -133
  28. package/src/internal/_functionalTypeGuardErrorFactory.ts +4 -4
  29. package/src/internal/_httpFormDataReadArray.ts +4 -4
  30. package/src/internal/_httpFormDataReadBigint.ts +18 -18
  31. package/src/internal/_httpFormDataReadBlob.ts +10 -10
  32. package/src/internal/_httpFormDataReadBoolean.ts +16 -16
  33. package/src/internal/_httpFormDataReadFile.ts +10 -10
  34. package/src/internal/_httpFormDataReadNumber.ts +15 -15
  35. package/src/internal/_httpFormDataReadString.ts +10 -10
  36. package/src/internal/_httpHeaderReadBigint.ts +10 -10
  37. package/src/internal/_httpHeaderReadBoolean.ts +8 -8
  38. package/src/internal/_httpHeaderReadNumber.ts +7 -7
  39. package/src/internal/_httpParameterReadBigint.ts +10 -10
  40. package/src/internal/_httpParameterReadBoolean.ts +8 -8
  41. package/src/internal/_httpParameterReadNumber.ts +7 -7
  42. package/src/internal/_httpParameterReadString.ts +2 -2
  43. package/src/internal/_httpQueryParseURLSearchParams.ts +12 -12
  44. package/src/internal/_httpQueryReadArray.ts +4 -4
  45. package/src/internal/_httpQueryReadBigint.ts +12 -12
  46. package/src/internal/_httpQueryReadBoolean.ts +14 -14
  47. package/src/internal/_httpQueryReadNumber.ts +9 -9
  48. package/src/internal/_httpQueryReadString.ts +4 -4
  49. package/src/internal/_isBetween.ts +2 -2
  50. package/src/internal/_isBigintString.ts +8 -8
  51. package/src/internal/_isFormatByte.ts +7 -7
  52. package/src/internal/_isFormatDate.ts +3 -3
  53. package/src/internal/_isFormatDateTime.ts +4 -4
  54. package/src/internal/_isFormatDuration.ts +4 -4
  55. package/src/internal/_isFormatEmail.ts +4 -4
  56. package/src/internal/_isFormatHostname.ts +4 -4
  57. package/src/internal/_isFormatIdnEmail.ts +4 -4
  58. package/src/internal/_isFormatIdnHostname.ts +4 -4
  59. package/src/internal/_isFormatIpv4.ts +4 -4
  60. package/src/internal/_isFormatIpv6.ts +4 -4
  61. package/src/internal/_isFormatIri.ts +3 -3
  62. package/src/internal/_isFormatIriReference.ts +4 -4
  63. package/src/internal/_isFormatJsonPointer.ts +3 -3
  64. package/src/internal/_isFormatPassword.ts +1 -1
  65. package/src/internal/_isFormatRegex.ts +8 -8
  66. package/src/internal/_isFormatRelativeJsonPointer.ts +4 -4
  67. package/src/internal/_isFormatTime.ts +4 -4
  68. package/src/internal/_isFormatUri.ts +6 -6
  69. package/src/internal/_isFormatUriReference.ts +5 -5
  70. package/src/internal/_isFormatUriTemplate.ts +4 -4
  71. package/src/internal/_isFormatUrl.ts +4 -4
  72. package/src/internal/_isFormatUuid.ts +3 -3
  73. package/src/internal/_isTypeFloat.ts +5 -5
  74. package/src/internal/_isTypeInt32.ts +5 -5
  75. package/src/internal/_isTypeInt64.ts +5 -5
  76. package/src/internal/_isTypeUint32.ts +5 -5
  77. package/src/internal/_isTypeUint64.ts +5 -5
  78. package/src/internal/_isUniqueItems.ts +159 -159
  79. package/src/internal/_jsonStringifyNumber.ts +12 -12
  80. package/src/internal/_jsonStringifyRest.ts +3 -3
  81. package/src/internal/_jsonStringifyString.ts +42 -42
  82. package/src/internal/_jsonStringifyTail.ts +2 -2
  83. package/src/internal/_llmApplicationFinalize.ts +24 -24
  84. package/src/internal/_miscCloneAny.ts +46 -46
  85. package/src/internal/_notationAny.ts +37 -37
  86. package/src/internal/_notationCamel.ts +13 -13
  87. package/src/internal/_notationPascal.ts +8 -8
  88. package/src/internal/_notationSnake.ts +43 -43
  89. package/src/internal/_parseLlmArguments.ts +7 -7
  90. package/src/internal/_randomArray.ts +21 -21
  91. package/src/internal/_randomBigint.ts +6 -6
  92. package/src/internal/_randomBoolean.ts +1 -1
  93. package/src/internal/_randomFormatByte.ts +3 -3
  94. package/src/internal/_randomFormatDate.ts +18 -18
  95. package/src/internal/_randomFormatDatetime.ts +16 -16
  96. package/src/internal/_randomFormatDuration.ts +27 -27
  97. package/src/internal/_randomFormatEmail.ts +11 -11
  98. package/src/internal/_randomFormatHostname.ts +6 -6
  99. package/src/internal/_randomFormatIdnEmail.ts +3 -3
  100. package/src/internal/_randomFormatIdnHostname.ts +3 -3
  101. package/src/internal/_randomFormatIpv4.ts +11 -11
  102. package/src/internal/_randomFormatIpv6.ts +11 -11
  103. package/src/internal/_randomFormatIri.ts +3 -3
  104. package/src/internal/_randomFormatIriReference.ts +3 -3
  105. package/src/internal/_randomFormatJsonPointer.ts +7 -7
  106. package/src/internal/_randomFormatPassword.ts +8 -8
  107. package/src/internal/_randomFormatRegex.ts +4 -4
  108. package/src/internal/_randomFormatRelativeJsonPointer.ts +8 -8
  109. package/src/internal/_randomFormatTime.ts +14 -14
  110. package/src/internal/_randomFormatUri.ts +3 -3
  111. package/src/internal/_randomFormatUriReference.ts +3 -3
  112. package/src/internal/_randomFormatUriTemplate.ts +3 -3
  113. package/src/internal/_randomFormatUrl.ts +11 -11
  114. package/src/internal/_randomFormatUuid.ts +6 -6
  115. package/src/internal/_randomInteger.ts +53 -53
  116. package/src/internal/_randomNumber.ts +80 -80
  117. package/src/internal/_randomPattern.ts +10 -10
  118. package/src/internal/_randomPick.ts +9 -9
  119. package/src/internal/_randomString.ts +24 -24
  120. package/src/internal/_throwTypeGuardError.ts +5 -5
  121. package/src/internal/_validateReport.ts +21 -21
  122. package/src/internal/private/__notationCapitalize.ts +2 -2
  123. package/src/internal/private/__notationUnsnake.ts +24 -24
  124. package/src/json.ts +553 -553
  125. package/src/llm.ts +408 -408
  126. package/src/misc.ts +448 -448
  127. package/src/module.ts +811 -811
  128. package/src/notations.ts +624 -624
  129. package/src/programmers/TypiaProgrammer.ts +8 -8
  130. package/src/protobuf.ts +499 -499
  131. package/src/re-exports.ts +33 -33
  132. package/src/reflect.ts +75 -75
  133. package/src/transform.ts +5 -5
  134. package/src/transformers/NoTransformConfigurationError.ts +16 -16
@@ -1,133 +1,133 @@
1
- import { StandardSchemaV1 } from "@standard-schema/spec";
2
- import { IValidation } from "@typia/interface";
3
-
4
- export const _createStandardSchema = <T>(
5
- fn: (input: unknown) => IValidation<T>,
6
- ): ((input: unknown) => IValidation<T>) & StandardSchemaV1<T, T> =>
7
- Object.assign(fn, {
8
- "~standard": {
9
- version: 1,
10
- vendor: "typia",
11
- validate: (input: unknown): StandardSchemaV1.Result<T> => {
12
- const result = fn(input);
13
- if (result.success) {
14
- return {
15
- value: result.data,
16
- } satisfies StandardSchemaV1.SuccessResult<T>;
17
- } else {
18
- return {
19
- issues: result.errors.map((error) => ({
20
- message: `expected ${error.expected}, got ${error.value}`,
21
- path: typiaPathToStandardSchemaPath(error.path),
22
- })),
23
- } satisfies StandardSchemaV1.FailureResult;
24
- }
25
- },
26
- },
27
- } satisfies StandardSchemaV1<T, T>);
28
-
29
- enum PathParserState {
30
- // Start of a new segment
31
- // When the parser is in this state,
32
- // the pointer must point `.` or `[` or equal to length of the path
33
- Start,
34
- // Parsing a property key (`.hoge`)
35
- Property,
36
- // Parsing a string key (`["fuga"]`)
37
- StringKey,
38
- // Parsing a number key (`[42]`)
39
- NumberKey,
40
- }
41
-
42
- const typiaPathToStandardSchemaPath = (
43
- path: string,
44
- ): ReadonlyArray<StandardSchemaV1.PathSegment> => {
45
- if (!path.startsWith("$input")) {
46
- throw new Error(`Invalid path: ${JSON.stringify(path)}`);
47
- }
48
-
49
- const segments: StandardSchemaV1.PathSegment[] = [];
50
- let currentSegment = "";
51
- let state: PathParserState = PathParserState.Start;
52
- let index = "$input".length - 1;
53
- while (index < path.length - 1) {
54
- index++;
55
- const char = path[index];
56
-
57
- if (state === PathParserState.Property) {
58
- if (char === "." || char === "[") {
59
- // End of property
60
- segments.push({
61
- key: currentSegment,
62
- });
63
- state = PathParserState.Start;
64
- } else if (index === path.length - 1) {
65
- // End of path
66
- currentSegment += char;
67
- segments.push({
68
- key: currentSegment,
69
- });
70
- index++;
71
- state = PathParserState.Start;
72
- } else {
73
- currentSegment += char;
74
- }
75
- } else if (state === PathParserState.StringKey) {
76
- if (char === '"') {
77
- // End of string key
78
- segments.push({
79
- key: JSON.parse(currentSegment + char),
80
- });
81
- // Skip `"` and `]`
82
- index += 2;
83
- state = PathParserState.Start;
84
- } else if (char === "\\") {
85
- // Skip the next character from parsing
86
- currentSegment += path[index];
87
- index++;
88
- currentSegment += path[index];
89
- } else {
90
- currentSegment += char;
91
- }
92
- } else if (state === PathParserState.NumberKey) {
93
- if (char === "]") {
94
- // End of number key
95
- segments.push({
96
- key: Number.parseInt(currentSegment),
97
- });
98
- index++;
99
- state = PathParserState.Start;
100
- } else {
101
- currentSegment += char;
102
- }
103
- }
104
-
105
- if (state === PathParserState.Start && index < path.length - 1) {
106
- const newChar = path[index];
107
- currentSegment = "";
108
- if (newChar === "[") {
109
- if (path[index + 1] === '"') {
110
- // Start of string key
111
- // NOTE: Typia uses JSON.stringify for this kind of keys, so `'` will not used as a string delimiter
112
- state = PathParserState.StringKey;
113
- index++;
114
- currentSegment = '"';
115
- } else {
116
- // Start of number key
117
- state = PathParserState.NumberKey;
118
- }
119
- } else if (newChar === ".") {
120
- // Start of property
121
- state = PathParserState.Property;
122
- } else {
123
- throw new Error("Unreachable: pointer points invalid character");
124
- }
125
- }
126
- }
127
-
128
- if (state !== PathParserState.Start) {
129
- throw new Error(`Failed to parse path: ${JSON.stringify(path)}`);
130
- }
131
-
132
- return segments;
133
- };
1
+ import { StandardSchemaV1 } from "@standard-schema/spec";
2
+ import { IValidation } from "@typia/interface";
3
+
4
+ export const _createStandardSchema = <T>(
5
+ fn: (input: unknown) => IValidation<T>,
6
+ ): ((input: unknown) => IValidation<T>) & StandardSchemaV1<T, T> =>
7
+ Object.assign(fn, {
8
+ "~standard": {
9
+ version: 1,
10
+ vendor: "typia",
11
+ validate: (input: unknown): StandardSchemaV1.Result<T> => {
12
+ const result = fn(input);
13
+ if (result.success) {
14
+ return {
15
+ value: result.data,
16
+ } satisfies StandardSchemaV1.SuccessResult<T>;
17
+ } else {
18
+ return {
19
+ issues: result.errors.map((error) => ({
20
+ message: `expected ${error.expected}, got ${error.value}`,
21
+ path: typiaPathToStandardSchemaPath(error.path),
22
+ })),
23
+ } satisfies StandardSchemaV1.FailureResult;
24
+ }
25
+ },
26
+ },
27
+ } satisfies StandardSchemaV1<T, T>);
28
+
29
+ enum PathParserState {
30
+ // Start of a new segment
31
+ // When the parser is in this state,
32
+ // the pointer must point `.` or `[` or equal to length of the path
33
+ Start,
34
+ // Parsing a property key (`.hoge`)
35
+ Property,
36
+ // Parsing a string key (`["fuga"]`)
37
+ StringKey,
38
+ // Parsing a number key (`[42]`)
39
+ NumberKey,
40
+ }
41
+
42
+ const typiaPathToStandardSchemaPath = (
43
+ path: string,
44
+ ): ReadonlyArray<StandardSchemaV1.PathSegment> => {
45
+ if (!path.startsWith("$input")) {
46
+ throw new Error(`Invalid path: ${JSON.stringify(path)}`);
47
+ }
48
+
49
+ const segments: StandardSchemaV1.PathSegment[] = [];
50
+ let currentSegment = "";
51
+ let state: PathParserState = PathParserState.Start;
52
+ let index = "$input".length - 1;
53
+ while (index < path.length - 1) {
54
+ index++;
55
+ const char = path[index];
56
+
57
+ if (state === PathParserState.Property) {
58
+ if (char === "." || char === "[") {
59
+ // End of property
60
+ segments.push({
61
+ key: currentSegment,
62
+ });
63
+ state = PathParserState.Start;
64
+ } else if (index === path.length - 1) {
65
+ // End of path
66
+ currentSegment += char;
67
+ segments.push({
68
+ key: currentSegment,
69
+ });
70
+ index++;
71
+ state = PathParserState.Start;
72
+ } else {
73
+ currentSegment += char;
74
+ }
75
+ } else if (state === PathParserState.StringKey) {
76
+ if (char === '"') {
77
+ // End of string key
78
+ segments.push({
79
+ key: JSON.parse(currentSegment + char),
80
+ });
81
+ // Skip `"` and `]`
82
+ index += 2;
83
+ state = PathParserState.Start;
84
+ } else if (char === "\\") {
85
+ // Skip the next character from parsing
86
+ currentSegment += path[index];
87
+ index++;
88
+ currentSegment += path[index];
89
+ } else {
90
+ currentSegment += char;
91
+ }
92
+ } else if (state === PathParserState.NumberKey) {
93
+ if (char === "]") {
94
+ // End of number key
95
+ segments.push({
96
+ key: Number.parseInt(currentSegment),
97
+ });
98
+ index++;
99
+ state = PathParserState.Start;
100
+ } else {
101
+ currentSegment += char;
102
+ }
103
+ }
104
+
105
+ if (state === PathParserState.Start && index < path.length - 1) {
106
+ const newChar = path[index];
107
+ currentSegment = "";
108
+ if (newChar === "[") {
109
+ if (path[index + 1] === '"') {
110
+ // Start of string key
111
+ // NOTE: Typia uses JSON.stringify for this kind of keys, so `'` will not used as a string delimiter
112
+ state = PathParserState.StringKey;
113
+ index++;
114
+ currentSegment = '"';
115
+ } else {
116
+ // Start of number key
117
+ state = PathParserState.NumberKey;
118
+ }
119
+ } else if (newChar === ".") {
120
+ // Start of property
121
+ state = PathParserState.Property;
122
+ } else {
123
+ throw new Error("Unreachable: pointer points invalid character");
124
+ }
125
+ }
126
+ }
127
+
128
+ if (state !== PathParserState.Start) {
129
+ throw new Error(`Failed to parse path: ${JSON.stringify(path)}`);
130
+ }
131
+
132
+ return segments;
133
+ };
@@ -1,4 +1,4 @@
1
- import { TypeGuardError } from "../TypeGuardError";
2
-
3
- export const _functionalTypeGuardErrorFactory = (p: TypeGuardError.IProps) =>
4
- new TypeGuardError(p);
1
+ import { TypeGuardError } from "../TypeGuardError";
2
+
3
+ export const _functionalTypeGuardErrorFactory = (p: TypeGuardError.IProps) =>
4
+ new TypeGuardError(p);
@@ -1,4 +1,4 @@
1
- export const _httpFormDataReadArray = (
2
- input: any[],
3
- alternative: null | undefined,
4
- ) => (input.length ? input : alternative);
1
+ export const _httpFormDataReadArray = (
2
+ input: any[],
3
+ alternative: null | undefined,
4
+ ) => (input.length ? input : alternative);
@@ -1,18 +1,18 @@
1
- export const _httpFormDataReadBigint = (
2
- input: string | File | null,
3
- ): bigint | null | undefined =>
4
- input instanceof File
5
- ? (input as any)
6
- : !!input?.length
7
- ? input === "null"
8
- ? null
9
- : (toBigint(input) as any)
10
- : undefined;
11
-
12
- const toBigint = (str: string): bigint | string => {
13
- try {
14
- return BigInt(str);
15
- } catch {
16
- return str;
17
- }
18
- };
1
+ export const _httpFormDataReadBigint = (
2
+ input: string | File | null,
3
+ ): bigint | null | undefined =>
4
+ input instanceof File
5
+ ? (input as any)
6
+ : !!input?.length
7
+ ? input === "null"
8
+ ? null
9
+ : (toBigint(input) as any)
10
+ : undefined;
11
+
12
+ const toBigint = (str: string): bigint | string => {
13
+ try {
14
+ return BigInt(str);
15
+ } catch {
16
+ return str;
17
+ }
18
+ };
@@ -1,10 +1,10 @@
1
- export const _httpFormDataReadBlob = (
2
- input: string | Blob | null,
3
- ): Blob | null | undefined =>
4
- input instanceof Blob
5
- ? input
6
- : input === null
7
- ? undefined
8
- : input === "null"
9
- ? null
10
- : (input as any);
1
+ export const _httpFormDataReadBlob = (
2
+ input: string | Blob | null,
3
+ ): Blob | null | undefined =>
4
+ input instanceof Blob
5
+ ? input
6
+ : input === null
7
+ ? undefined
8
+ : input === "null"
9
+ ? null
10
+ : (input as any);
@@ -1,16 +1,16 @@
1
- export const _httpFormDataReadBoolean = (
2
- input: string | File | null,
3
- ): boolean | null | undefined =>
4
- input instanceof File
5
- ? (input as any)
6
- : input === null
7
- ? undefined
8
- : input === "null"
9
- ? null
10
- : input.length === 0
11
- ? true
12
- : input === "true" || input === "1"
13
- ? true
14
- : input === "false" || input === "0"
15
- ? false
16
- : (input as any); // wrong type
1
+ export const _httpFormDataReadBoolean = (
2
+ input: string | File | null,
3
+ ): boolean | null | undefined =>
4
+ input instanceof File
5
+ ? (input as any)
6
+ : input === null
7
+ ? undefined
8
+ : input === "null"
9
+ ? null
10
+ : input.length === 0
11
+ ? true
12
+ : input === "true" || input === "1"
13
+ ? true
14
+ : input === "false" || input === "0"
15
+ ? false
16
+ : (input as any); // wrong type
@@ -1,10 +1,10 @@
1
- export const _httpFormDataReadFile = (
2
- input: string | File | null,
3
- ): File | null | undefined =>
4
- input instanceof File
5
- ? input
6
- : input === null
7
- ? undefined
8
- : input === "null"
9
- ? null
10
- : (input as any);
1
+ export const _httpFormDataReadFile = (
2
+ input: string | File | null,
3
+ ): File | null | undefined =>
4
+ input instanceof File
5
+ ? input
6
+ : input === null
7
+ ? undefined
8
+ : input === "null"
9
+ ? null
10
+ : (input as any);
@@ -1,15 +1,15 @@
1
- export const _httpFormDataReadNumber = (
2
- input: string | File | null,
3
- ): number | null | undefined =>
4
- input instanceof File
5
- ? (input as any)
6
- : !!input?.length
7
- ? input === "null"
8
- ? null
9
- : (toNumber(input) as any)
10
- : undefined;
11
-
12
- const toNumber = (str: string): number | string => {
13
- const value: number = Number(str);
14
- return isNaN(value) ? str : value;
15
- };
1
+ export const _httpFormDataReadNumber = (
2
+ input: string | File | null,
3
+ ): number | null | undefined =>
4
+ input instanceof File
5
+ ? (input as any)
6
+ : !!input?.length
7
+ ? input === "null"
8
+ ? null
9
+ : (toNumber(input) as any)
10
+ : undefined;
11
+
12
+ const toNumber = (str: string): number | string => {
13
+ const value: number = Number(str);
14
+ return isNaN(value) ? str : value;
15
+ };
@@ -1,10 +1,10 @@
1
- export const _httpFormDataReadString = (
2
- input: string | File | null,
3
- ): string | null | undefined =>
4
- input instanceof File
5
- ? (input as any)
6
- : input === null
7
- ? undefined
8
- : input === "null"
9
- ? null
10
- : input;
1
+ export const _httpFormDataReadString = (
2
+ input: string | File | null,
3
+ ): string | null | undefined =>
4
+ input instanceof File
5
+ ? (input as any)
6
+ : input === null
7
+ ? undefined
8
+ : input === "null"
9
+ ? null
10
+ : input;
@@ -1,10 +1,10 @@
1
- export const _httpHeaderReadBigint = (value: string | undefined) =>
2
- value !== undefined ? toBigint(value) : undefined;
3
-
4
- const toBigint = (str: string): bigint | string => {
5
- try {
6
- return BigInt(str);
7
- } catch {
8
- return str;
9
- }
10
- };
1
+ export const _httpHeaderReadBigint = (value: string | undefined) =>
2
+ value !== undefined ? toBigint(value) : undefined;
3
+
4
+ const toBigint = (str: string): bigint | string => {
5
+ try {
6
+ return BigInt(str);
7
+ } catch {
8
+ return str;
9
+ }
10
+ };
@@ -1,8 +1,8 @@
1
- export const _httpHeaderReadBoolean = (value: string | undefined) =>
2
- value !== undefined
3
- ? value === "true"
4
- ? true
5
- : value === "false"
6
- ? false
7
- : value
8
- : undefined;
1
+ export const _httpHeaderReadBoolean = (value: string | undefined) =>
2
+ value !== undefined
3
+ ? value === "true"
4
+ ? true
5
+ : value === "false"
6
+ ? false
7
+ : value
8
+ : undefined;
@@ -1,7 +1,7 @@
1
- export const _httpHeaderReadNumber = (value: string | undefined) =>
2
- value !== undefined ? toNumber(value) : undefined;
3
-
4
- const toNumber = (str: string): number | string => {
5
- const value: number = Number(str);
6
- return isNaN(value) ? str : value;
7
- };
1
+ export const _httpHeaderReadNumber = (value: string | undefined) =>
2
+ value !== undefined ? toNumber(value) : undefined;
3
+
4
+ const toNumber = (str: string): number | string => {
5
+ const value: number = Number(str);
6
+ return isNaN(value) ? str : value;
7
+ };
@@ -1,10 +1,10 @@
1
- export const _httpParameterReadBigint = (value: string) =>
2
- value !== "null" ? toBigint(value) : null;
3
-
4
- const toBigint = (str: string): bigint | string => {
5
- try {
6
- return BigInt(str);
7
- } catch {
8
- return str;
9
- }
10
- };
1
+ export const _httpParameterReadBigint = (value: string) =>
2
+ value !== "null" ? toBigint(value) : null;
3
+
4
+ const toBigint = (str: string): bigint | string => {
5
+ try {
6
+ return BigInt(str);
7
+ } catch {
8
+ return str;
9
+ }
10
+ };
@@ -1,8 +1,8 @@
1
- export const _httpParameterReadBoolean = (value: string) =>
2
- value !== "null"
3
- ? value === "true" || value === "1"
4
- ? true
5
- : value === "false" || value === "0"
6
- ? false
7
- : value
8
- : null;
1
+ export const _httpParameterReadBoolean = (value: string) =>
2
+ value !== "null"
3
+ ? value === "true" || value === "1"
4
+ ? true
5
+ : value === "false" || value === "0"
6
+ ? false
7
+ : value
8
+ : null;
@@ -1,7 +1,7 @@
1
- export const _httpParameterReadNumber = (value: string) =>
2
- value !== "null" ? toNumber(value) : null;
3
-
4
- const toNumber = (str: string): number | string => {
5
- const value: number = Number(str);
6
- return isNaN(value) ? str : value;
7
- };
1
+ export const _httpParameterReadNumber = (value: string) =>
2
+ value !== "null" ? toNumber(value) : null;
3
+
4
+ const toNumber = (str: string): number | string => {
5
+ const value: number = Number(str);
6
+ return isNaN(value) ? str : value;
7
+ };
@@ -1,2 +1,2 @@
1
- export const _httpParameterReadString = (value: string) =>
2
- value !== "null" ? value : null;
1
+ export const _httpParameterReadString = (value: string) =>
2
+ value !== "null" ? value : null;
@@ -1,12 +1,12 @@
1
- import { IReadableURLSearchParams } from "@typia/interface";
2
-
3
- export const _httpQueryParseURLSearchParams = (
4
- input: string | IReadableURLSearchParams,
5
- ): IReadableURLSearchParams => {
6
- if (typeof input === "string") {
7
- const index: number = input.indexOf("?");
8
- input = index === -1 ? "" : input.substring(index + 1);
9
- return new URLSearchParams(input);
10
- }
11
- return input;
12
- };
1
+ import { IReadableURLSearchParams } from "@typia/interface";
2
+
3
+ export const _httpQueryParseURLSearchParams = (
4
+ input: string | IReadableURLSearchParams,
5
+ ): IReadableURLSearchParams => {
6
+ if (typeof input === "string") {
7
+ const index: number = input.indexOf("?");
8
+ input = index === -1 ? "" : input.substring(index + 1);
9
+ return new URLSearchParams(input);
10
+ }
11
+ return input;
12
+ };
@@ -1,4 +1,4 @@
1
- export const _httpQueryReadArray = (
2
- input: any[],
3
- alternative: null | undefined,
4
- ) => (input.length ? input : alternative);
1
+ export const _httpQueryReadArray = (
2
+ input: any[],
3
+ alternative: null | undefined,
4
+ ) => (input.length ? input : alternative);
@@ -1,12 +1,12 @@
1
- export const _httpQueryReadBigint = (
2
- str: string | null,
3
- ): bigint | null | undefined =>
4
- !!str?.length ? (str === "null" ? null : (toBigint(str) as any)) : undefined;
5
-
6
- const toBigint = (str: string): bigint | string => {
7
- try {
8
- return BigInt(str);
9
- } catch {
10
- return str;
11
- }
12
- };
1
+ export const _httpQueryReadBigint = (
2
+ str: string | null,
3
+ ): bigint | null | undefined =>
4
+ !!str?.length ? (str === "null" ? null : (toBigint(str) as any)) : undefined;
5
+
6
+ const toBigint = (str: string): bigint | string => {
7
+ try {
8
+ return BigInt(str);
9
+ } catch {
10
+ return str;
11
+ }
12
+ };
@@ -1,14 +1,14 @@
1
- export const _httpQueryReadBoolean = (
2
- str: string | null,
3
- ): boolean | null | undefined =>
4
- str === null
5
- ? undefined
6
- : str === "null"
7
- ? null
8
- : str.length === 0
9
- ? true
10
- : str === "true" || str === "1"
11
- ? true
12
- : str === "false" || str === "0"
13
- ? false
14
- : (str as any); // wrong type
1
+ export const _httpQueryReadBoolean = (
2
+ str: string | null,
3
+ ): boolean | null | undefined =>
4
+ str === null
5
+ ? undefined
6
+ : str === "null"
7
+ ? null
8
+ : str.length === 0
9
+ ? true
10
+ : str === "true" || str === "1"
11
+ ? true
12
+ : str === "false" || str === "0"
13
+ ? false
14
+ : (str as any); // wrong type