typia 12.0.0-dev.20260309 → 12.0.0-dev.20260310

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,159 +1,159 @@
1
- export const _isUniqueItems = (elements: any[]): boolean => {
2
- // EMPTY OR ONLY ONE
3
- if (elements.length < 2) return true;
4
-
5
- // SHALLOW COMPARISON
6
- if (["boolean", "bigint", "number", "string"].includes(typeof elements[0]))
7
- return new Set(elements).size === elements.length;
8
-
9
- // DEEP COMPARISON
10
- for (let i = 0; i < elements.length; i++)
11
- for (let j = i + 1; j < elements.length; j++)
12
- if (equals(new WeakMap())(elements[i], elements[j])) return false;
13
- return true;
14
- };
15
-
16
- const equals = (visited: WeakMap<object, WeakMap<object, boolean>>) => {
17
- const next = (a: any, b: any): boolean => {
18
- // SHALLOW EQUAL
19
- if (a === b) return true;
20
- else if (typeof a !== typeof b || typeof a !== "object") return false;
21
- // COMPARE CONTAINERS
22
- else if (Array.isArray(a))
23
- return Array.isArray(b) && a.map((x, i) => next(x, b[i])).every((x) => x);
24
- else if (a instanceof Set)
25
- return (
26
- b instanceof Set && a.size === b.size && [...a].every((x) => b.has(x))
27
- );
28
- else if (a instanceof Map)
29
- return (
30
- b instanceof Map &&
31
- a.size === b.size &&
32
- [...a].every(([k, v]) => b.has(k) && next(v, b.get(k)))
33
- );
34
- // ATOMIC CLASSES
35
- else if (a instanceof Boolean)
36
- return b instanceof Boolean
37
- ? a.valueOf() === b.valueOf()
38
- : a.valueOf() === b;
39
- else if (a instanceof BigInt)
40
- return b instanceof BigInt ? a === b : a === BigInt(b);
41
- else if (a instanceof Number)
42
- return b instanceof Number
43
- ? a.valueOf() === b.valueOf()
44
- : a.valueOf() === b;
45
- else if (a instanceof String)
46
- return b instanceof String
47
- ? a.valueOf() === b.valueOf()
48
- : a.valueOf() === b;
49
- else if (a instanceof Date)
50
- return b instanceof Date && a.getTime() === b.getTime();
51
- // BINARY DATA
52
- else if (a instanceof Uint8Array)
53
- return (
54
- b instanceof Uint8Array &&
55
- a.length === b.length &&
56
- a.every((x, i) => x === b[i])
57
- );
58
- else if (a instanceof Uint8ClampedArray)
59
- return (
60
- b instanceof Uint8ClampedArray &&
61
- a.length === b.length &&
62
- a.every((x, i) => x === b[i])
63
- );
64
- else if (a instanceof Uint16Array)
65
- return (
66
- b instanceof Uint16Array &&
67
- a.length === b.length &&
68
- a.every((x, i) => x === b[i])
69
- );
70
- else if (a instanceof Uint32Array)
71
- return (
72
- b instanceof Uint32Array &&
73
- a.length === b.length &&
74
- a.every((x, i) => x === b[i])
75
- );
76
- else if (a instanceof BigUint64Array)
77
- return (
78
- b instanceof BigUint64Array &&
79
- a.length === b.length &&
80
- a.every((x, i) => x === b[i])
81
- );
82
- else if (a instanceof Int8Array)
83
- return (
84
- b instanceof Int8Array &&
85
- a.length === b.length &&
86
- a.every((x, i) => x === b[i])
87
- );
88
- else if (a instanceof Int16Array)
89
- return (
90
- b instanceof Int16Array &&
91
- a.length === b.length &&
92
- a.every((x, i) => x === b[i])
93
- );
94
- else if (a instanceof Int32Array)
95
- return (
96
- b instanceof Int32Array &&
97
- a.length === b.length &&
98
- a.every((x, i) => x === b[i])
99
- );
100
- else if (a instanceof BigInt64Array)
101
- return (
102
- b instanceof BigInt64Array &&
103
- a.length === b.length &&
104
- a.every((x, i) => x === b[i])
105
- );
106
- else if (a instanceof Float32Array)
107
- return (
108
- b instanceof Float32Array &&
109
- a.length === b.length &&
110
- a.every((x, i) => x === b[i])
111
- );
112
- else if (a instanceof Float64Array)
113
- return (
114
- b instanceof Float64Array &&
115
- a.length === b.length &&
116
- a.every((x, i) => x === b[i])
117
- );
118
- else if (a instanceof ArrayBuffer) {
119
- if (!(b instanceof ArrayBuffer) || a.byteLength !== b.byteLength)
120
- return false;
121
- const x: Uint8Array = new Uint8Array(a);
122
- const y: Uint8Array = new Uint8Array(b);
123
- return x.every((v, i) => v === y[i]);
124
- } else if (a instanceof SharedArrayBuffer) {
125
- if (!(b instanceof SharedArrayBuffer) || a.byteLength !== b.byteLength)
126
- return false;
127
- const x: Uint8Array = new Uint8Array(a);
128
- const y: Uint8Array = new Uint8Array(b);
129
- return x.every((v, i) => v === y[i]);
130
- } else if (a instanceof DataView) {
131
- if (!(b instanceof DataView) || a.byteLength !== b.byteLength)
132
- return false;
133
- const x: Uint8Array = new Uint8Array(a.buffer);
134
- const y: Uint8Array = new Uint8Array(b.buffer);
135
- return x.every((v, i) => v === y[i]);
136
- } else if (a instanceof File)
137
- return (
138
- b instanceof File &&
139
- a.name === b.name &&
140
- a.size === b.size &&
141
- a.type === b.type &&
142
- next(a.slice(), b.slice())
143
- );
144
- // JUST PLAIN OBJECTS
145
- else if (a !== null && b !== null) {
146
- if (visited.has(a) && visited.get(a)!.has(b))
147
- return visited.get(a)!.get(b)!;
148
- if (!visited.has(a)) visited.set(a, new WeakMap());
149
- visited.get(a)!.set(b, true);
150
- const res: boolean =
151
- Object.keys(a).length === Object.keys(b).length &&
152
- Object.keys(a).every((x) => next(a[x], b[x]));
153
- visited.get(a)!.set(b, res);
154
- return res;
155
- }
156
- return false;
157
- };
158
- return next;
159
- };
1
+ export const _isUniqueItems = (elements: any[]): boolean => {
2
+ // EMPTY OR ONLY ONE
3
+ if (elements.length < 2) return true;
4
+
5
+ // SHALLOW COMPARISON
6
+ if (["boolean", "bigint", "number", "string"].includes(typeof elements[0]))
7
+ return new Set(elements).size === elements.length;
8
+
9
+ // DEEP COMPARISON
10
+ for (let i = 0; i < elements.length; i++)
11
+ for (let j = i + 1; j < elements.length; j++)
12
+ if (equals(new WeakMap())(elements[i], elements[j])) return false;
13
+ return true;
14
+ };
15
+
16
+ const equals = (visited: WeakMap<object, WeakMap<object, boolean>>) => {
17
+ const next = (a: any, b: any): boolean => {
18
+ // SHALLOW EQUAL
19
+ if (a === b) return true;
20
+ else if (typeof a !== typeof b || typeof a !== "object") return false;
21
+ // COMPARE CONTAINERS
22
+ else if (Array.isArray(a))
23
+ return Array.isArray(b) && a.map((x, i) => next(x, b[i])).every((x) => x);
24
+ else if (a instanceof Set)
25
+ return (
26
+ b instanceof Set && a.size === b.size && [...a].every((x) => b.has(x))
27
+ );
28
+ else if (a instanceof Map)
29
+ return (
30
+ b instanceof Map &&
31
+ a.size === b.size &&
32
+ [...a].every(([k, v]) => b.has(k) && next(v, b.get(k)))
33
+ );
34
+ // ATOMIC CLASSES
35
+ else if (a instanceof Boolean)
36
+ return b instanceof Boolean
37
+ ? a.valueOf() === b.valueOf()
38
+ : a.valueOf() === b;
39
+ else if (a instanceof BigInt)
40
+ return b instanceof BigInt ? a === b : a === BigInt(b);
41
+ else if (a instanceof Number)
42
+ return b instanceof Number
43
+ ? a.valueOf() === b.valueOf()
44
+ : a.valueOf() === b;
45
+ else if (a instanceof String)
46
+ return b instanceof String
47
+ ? a.valueOf() === b.valueOf()
48
+ : a.valueOf() === b;
49
+ else if (a instanceof Date)
50
+ return b instanceof Date && a.getTime() === b.getTime();
51
+ // BINARY DATA
52
+ else if (a instanceof Uint8Array)
53
+ return (
54
+ b instanceof Uint8Array &&
55
+ a.length === b.length &&
56
+ a.every((x, i) => x === b[i])
57
+ );
58
+ else if (a instanceof Uint8ClampedArray)
59
+ return (
60
+ b instanceof Uint8ClampedArray &&
61
+ a.length === b.length &&
62
+ a.every((x, i) => x === b[i])
63
+ );
64
+ else if (a instanceof Uint16Array)
65
+ return (
66
+ b instanceof Uint16Array &&
67
+ a.length === b.length &&
68
+ a.every((x, i) => x === b[i])
69
+ );
70
+ else if (a instanceof Uint32Array)
71
+ return (
72
+ b instanceof Uint32Array &&
73
+ a.length === b.length &&
74
+ a.every((x, i) => x === b[i])
75
+ );
76
+ else if (a instanceof BigUint64Array)
77
+ return (
78
+ b instanceof BigUint64Array &&
79
+ a.length === b.length &&
80
+ a.every((x, i) => x === b[i])
81
+ );
82
+ else if (a instanceof Int8Array)
83
+ return (
84
+ b instanceof Int8Array &&
85
+ a.length === b.length &&
86
+ a.every((x, i) => x === b[i])
87
+ );
88
+ else if (a instanceof Int16Array)
89
+ return (
90
+ b instanceof Int16Array &&
91
+ a.length === b.length &&
92
+ a.every((x, i) => x === b[i])
93
+ );
94
+ else if (a instanceof Int32Array)
95
+ return (
96
+ b instanceof Int32Array &&
97
+ a.length === b.length &&
98
+ a.every((x, i) => x === b[i])
99
+ );
100
+ else if (a instanceof BigInt64Array)
101
+ return (
102
+ b instanceof BigInt64Array &&
103
+ a.length === b.length &&
104
+ a.every((x, i) => x === b[i])
105
+ );
106
+ else if (a instanceof Float32Array)
107
+ return (
108
+ b instanceof Float32Array &&
109
+ a.length === b.length &&
110
+ a.every((x, i) => x === b[i])
111
+ );
112
+ else if (a instanceof Float64Array)
113
+ return (
114
+ b instanceof Float64Array &&
115
+ a.length === b.length &&
116
+ a.every((x, i) => x === b[i])
117
+ );
118
+ else if (a instanceof ArrayBuffer) {
119
+ if (!(b instanceof ArrayBuffer) || a.byteLength !== b.byteLength)
120
+ return false;
121
+ const x: Uint8Array = new Uint8Array(a);
122
+ const y: Uint8Array = new Uint8Array(b);
123
+ return x.every((v, i) => v === y[i]);
124
+ } else if (a instanceof SharedArrayBuffer) {
125
+ if (!(b instanceof SharedArrayBuffer) || a.byteLength !== b.byteLength)
126
+ return false;
127
+ const x: Uint8Array = new Uint8Array(a);
128
+ const y: Uint8Array = new Uint8Array(b);
129
+ return x.every((v, i) => v === y[i]);
130
+ } else if (a instanceof DataView) {
131
+ if (!(b instanceof DataView) || a.byteLength !== b.byteLength)
132
+ return false;
133
+ const x: Uint8Array = new Uint8Array(a.buffer);
134
+ const y: Uint8Array = new Uint8Array(b.buffer);
135
+ return x.every((v, i) => v === y[i]);
136
+ } else if (a instanceof File)
137
+ return (
138
+ b instanceof File &&
139
+ a.name === b.name &&
140
+ a.size === b.size &&
141
+ a.type === b.type &&
142
+ next(a.slice(), b.slice())
143
+ );
144
+ // JUST PLAIN OBJECTS
145
+ else if (a !== null && b !== null) {
146
+ if (visited.has(a) && visited.get(a)!.has(b))
147
+ return visited.get(a)!.get(b)!;
148
+ if (!visited.has(a)) visited.set(a, new WeakMap());
149
+ visited.get(a)!.set(b, true);
150
+ const res: boolean =
151
+ Object.keys(a).length === Object.keys(b).length &&
152
+ Object.keys(a).every((x) => next(a[x], b[x]));
153
+ visited.get(a)!.set(b, res);
154
+ return res;
155
+ }
156
+ return false;
157
+ };
158
+ return next;
159
+ };
@@ -1,12 +1,12 @@
1
- import { TypeGuardError } from "../TypeGuardError";
2
-
3
- export const _jsonStringifyNumber = (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 _jsonStringifyNumber = (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,3 +1,3 @@
1
- export const _jsonStringifyRest = (str: string): string => {
2
- return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
3
- };
1
+ export const _jsonStringifyRest = (str: string): string => {
2
+ return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
3
+ };
@@ -1,42 +1,42 @@
1
- /**
2
- * In the past, name of `typia` was `typescript-json`, and supported JSON
3
- * serialization by wrapping `fast-json-stringify. `typescript-json`was a helper
4
- * library of`fast-json-stringify`, which can skip manual JSON schema definition
5
- * 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
- * @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
11
- * @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
12
- */
13
- export const _jsonStringifyString = (str: string): string => {
14
- const len = str.length;
15
- let result = "";
16
- let last = -1;
17
- let point = 255;
18
-
19
- // eslint-disable-next-line
20
- for (var i = 0; i < len; i++) {
21
- point = str.charCodeAt(i);
22
- if (point < 32) {
23
- return JSON.stringify(str);
24
- }
25
- if (point >= 0xd800 && point <= 0xdfff) {
26
- // The current character is a surrogate.
27
- return JSON.stringify(str);
28
- }
29
- if (
30
- point === 0x22 || // '"'
31
- point === 0x5c // '\'
32
- ) {
33
- last === -1 && (last = 0);
34
- result += str.slice(last, i) + "\\";
35
- last = i;
36
- }
37
- }
38
-
39
- return (
40
- (last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
41
- );
42
- };
1
+ /**
2
+ * In the past, name of `typia` was `typescript-json`, and supported JSON
3
+ * serialization by wrapping `fast-json-stringify. `typescript-json`was a helper
4
+ * library of`fast-json-stringify`, which can skip manual JSON schema definition
5
+ * 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
+ * @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
11
+ * @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
12
+ */
13
+ export const _jsonStringifyString = (str: string): string => {
14
+ const len = str.length;
15
+ let result = "";
16
+ let last = -1;
17
+ let point = 255;
18
+
19
+ // eslint-disable-next-line
20
+ for (var i = 0; i < len; i++) {
21
+ point = str.charCodeAt(i);
22
+ if (point < 32) {
23
+ return JSON.stringify(str);
24
+ }
25
+ if (point >= 0xd800 && point <= 0xdfff) {
26
+ // The current character is a surrogate.
27
+ return JSON.stringify(str);
28
+ }
29
+ if (
30
+ point === 0x22 || // '"'
31
+ point === 0x5c // '\'
32
+ ) {
33
+ last === -1 && (last = 0);
34
+ result += str.slice(last, i) + "\\";
35
+ last = i;
36
+ }
37
+ }
38
+
39
+ return (
40
+ (last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
41
+ );
42
+ };
@@ -1,2 +1,2 @@
1
- export const _jsonStringifyTail = (str: string): string =>
2
- str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
1
+ export const _jsonStringifyTail = (str: string): string =>
2
+ str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
@@ -1,24 +1,24 @@
1
- import { IJsonParseResult, ILlmApplication } from "@typia/interface";
2
- import { LlmJson, LlmSchemaConverter } from "@typia/utils";
3
-
4
- export const _llmApplicationFinalize = <Class extends object = any>(
5
- app: ILlmApplication.__IPrimitive<Class>,
6
- config?: Partial<
7
- Pick<ILlmApplication.IConfig, "validate"> & {
8
- equals?: boolean;
9
- }
10
- >,
11
- ): ILlmApplication<Class> => ({
12
- ...app,
13
- config: {
14
- ...LlmSchemaConverter.getConfig(),
15
- validate: config?.validate ?? null,
16
- },
17
- functions: app.functions.map((func) => ({
18
- ...func,
19
- parse: (input: string): IJsonParseResult<unknown> =>
20
- LlmJson.parse(input, func.parameters),
21
- coerce: (input: unknown): unknown => LlmJson.coerce(input, func.parameters),
22
- validate: config?.validate?.[func.name] ?? func.validate,
23
- })),
24
- });
1
+ import { IJsonParseResult, ILlmApplication } from "@typia/interface";
2
+ import { LlmJson, LlmSchemaConverter } from "@typia/utils";
3
+
4
+ export const _llmApplicationFinalize = <Class extends object = any>(
5
+ app: ILlmApplication.__IPrimitive<Class>,
6
+ config?: Partial<
7
+ Pick<ILlmApplication.IConfig, "validate"> & {
8
+ equals?: boolean;
9
+ }
10
+ >,
11
+ ): ILlmApplication<Class> => ({
12
+ ...app,
13
+ config: {
14
+ ...LlmSchemaConverter.getConfig(),
15
+ validate: config?.validate ?? null,
16
+ },
17
+ functions: app.functions.map((func) => ({
18
+ ...func,
19
+ parse: (input: string): IJsonParseResult<unknown> =>
20
+ LlmJson.parse(input, func.parameters),
21
+ coerce: (input: unknown): unknown => LlmJson.coerce(input, func.parameters),
22
+ validate: config?.validate?.[func.name] ?? func.validate,
23
+ })),
24
+ });
@@ -1,46 +1,46 @@
1
- import { Resolved } from "@typia/interface";
2
-
3
- export const _miscCloneAny = <T>(value: T): Resolved<T> =>
4
- cloneMain(value) as Resolved<T>;
5
-
6
- const cloneMain = (value: any): any => {
7
- if (value === undefined) return undefined;
8
- else if (typeof value === "object")
9
- if (value === null) return null;
10
- else if (Array.isArray(value)) return value.map(cloneMain);
11
- else if (value instanceof Date) return new Date(value);
12
- else if (value instanceof Uint8Array) return new Uint8Array(value);
13
- else if (value instanceof Uint8ClampedArray)
14
- return new Uint8ClampedArray(value);
15
- else if (value instanceof Uint16Array) return new Uint16Array(value);
16
- else if (value instanceof Uint32Array) return new Uint32Array(value);
17
- else if (value instanceof BigUint64Array) return new BigUint64Array(value);
18
- else if (value instanceof Int8Array) return new Int8Array(value);
19
- else if (value instanceof Int16Array) return new Int16Array(value);
20
- else if (value instanceof Int32Array) return new Int32Array(value);
21
- else if (value instanceof BigInt64Array) return new BigInt64Array(value);
22
- else if (value instanceof Float32Array) return new Float32Array(value);
23
- else if (value instanceof Float64Array) return new Float64Array(value);
24
- else if (value instanceof ArrayBuffer) return value.slice(0);
25
- else if (value instanceof SharedArrayBuffer) return value.slice(0);
26
- else if (value instanceof DataView)
27
- return new DataView(value.buffer.slice(0));
28
- else if (typeof File !== "undefined" && value instanceof File)
29
- return new File([value], value.name, { type: value.type });
30
- else if (typeof Blob !== "undefined" && value instanceof Blob)
31
- return new Blob([value], { type: value.type });
32
- else if (value instanceof Set) return new Set([...value].map(cloneMain));
33
- else if (value instanceof Map)
34
- return new Map([...value].map(([k, v]) => [cloneMain(k), cloneMain(v)]));
35
- else if (value instanceof WeakSet || value instanceof WeakMap)
36
- throw new Error("WeakSet and WeakMap are not supported");
37
- else if (value.valueOf() !== value) return cloneMain(value.valueOf());
38
- else
39
- return Object.fromEntries(
40
- Object.entries(value)
41
- .map(([k, v]) => [k, cloneMain(v)])
42
- .filter(([, v]) => v !== undefined),
43
- );
44
- else if (typeof value === "function") return undefined;
45
- return value;
46
- };
1
+ import { Resolved } from "@typia/interface";
2
+
3
+ export const _miscCloneAny = <T>(value: T): Resolved<T> =>
4
+ cloneMain(value) as Resolved<T>;
5
+
6
+ const cloneMain = (value: any): any => {
7
+ if (value === undefined) return undefined;
8
+ else if (typeof value === "object")
9
+ if (value === null) return null;
10
+ else if (Array.isArray(value)) return value.map(cloneMain);
11
+ else if (value instanceof Date) return new Date(value);
12
+ else if (value instanceof Uint8Array) return new Uint8Array(value);
13
+ else if (value instanceof Uint8ClampedArray)
14
+ return new Uint8ClampedArray(value);
15
+ else if (value instanceof Uint16Array) return new Uint16Array(value);
16
+ else if (value instanceof Uint32Array) return new Uint32Array(value);
17
+ else if (value instanceof BigUint64Array) return new BigUint64Array(value);
18
+ else if (value instanceof Int8Array) return new Int8Array(value);
19
+ else if (value instanceof Int16Array) return new Int16Array(value);
20
+ else if (value instanceof Int32Array) return new Int32Array(value);
21
+ else if (value instanceof BigInt64Array) return new BigInt64Array(value);
22
+ else if (value instanceof Float32Array) return new Float32Array(value);
23
+ else if (value instanceof Float64Array) return new Float64Array(value);
24
+ else if (value instanceof ArrayBuffer) return value.slice(0);
25
+ else if (value instanceof SharedArrayBuffer) return value.slice(0);
26
+ else if (value instanceof DataView)
27
+ return new DataView(value.buffer.slice(0));
28
+ else if (typeof File !== "undefined" && value instanceof File)
29
+ return new File([value], value.name, { type: value.type });
30
+ else if (typeof Blob !== "undefined" && value instanceof Blob)
31
+ return new Blob([value], { type: value.type });
32
+ else if (value instanceof Set) return new Set([...value].map(cloneMain));
33
+ else if (value instanceof Map)
34
+ return new Map([...value].map(([k, v]) => [cloneMain(k), cloneMain(v)]));
35
+ else if (value instanceof WeakSet || value instanceof WeakMap)
36
+ throw new Error("WeakSet and WeakMap are not supported");
37
+ else if (value.valueOf() !== value) return cloneMain(value.valueOf());
38
+ else
39
+ return Object.fromEntries(
40
+ Object.entries(value)
41
+ .map(([k, v]) => [k, cloneMain(v)])
42
+ .filter(([, v]) => v !== undefined),
43
+ );
44
+ else if (typeof value === "function") return undefined;
45
+ return value;
46
+ };
@@ -1,37 +1,37 @@
1
- export const _notationAny = (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 _notationAny = (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
+ };