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,137 +1,137 @@
1
- import { _IProtobufWriter } from "./_IProtobufWriter";
2
-
3
- /// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedSizer.ts
4
- export class _ProtobufSizer implements _IProtobufWriter {
5
- /** Total length. */
6
- public len: number;
7
-
8
- /** Position stack. */
9
- public readonly pos: Array<number>;
10
-
11
- /** Variable length list. */
12
- public readonly varlen: Array<number>;
13
-
14
- /** Variable length index stack. */
15
- public readonly varlenidx: Array<number>;
16
-
17
- public constructor(length: number = 0) {
18
- this.len = length;
19
- this.pos = [];
20
- this.varlen = [];
21
- this.varlenidx = [];
22
- }
23
-
24
- public bool(): void {
25
- this.len += 1;
26
- }
27
- public int32(value: number): void {
28
- if (value < 0) {
29
- // 10 bytes to encode negative number
30
- this.len += 10;
31
- } else {
32
- this.varint32(value);
33
- }
34
- }
35
- public sint32(value: number): void {
36
- this.varint32((value << 1) ^ (value >> 31));
37
- }
38
- public uint32(value: number): void {
39
- this.varint32(value);
40
- }
41
-
42
- public int64(value: bigint | number): void {
43
- this.varint64(typeof value === "number" ? BigInt(value) : value);
44
- }
45
- public sint64(value: bigint | number): void {
46
- if (typeof value === "number") value = BigInt(value);
47
- this.varint64((value << BigInt(1)) ^ (value >> BigInt(63)));
48
- }
49
- public uint64(value: bigint | number): void {
50
- this.varint64(typeof value === "number" ? BigInt(value) : value);
51
- }
52
-
53
- // public fixed32(_value: number): void {
54
- // this.len += 4;
55
- // }
56
- // public sfixed32(_value: number): void {
57
- // this.len += 4;
58
- // }
59
- // public fixed64(_value: number | bigint): void {
60
- // this.len += 8;
61
- // }
62
- // public sfixed64(_value: number | bigint): void {
63
- // this.len += 8;
64
- // }
65
- public float(_value: number): void {
66
- this.len += 4;
67
- }
68
- public double(_value: number): void {
69
- this.len += 8;
70
- }
71
-
72
- public bytes(value: Uint8Array): void {
73
- this.uint32(value.byteLength);
74
- this.len += value.byteLength;
75
- }
76
- public string(value: string): void {
77
- const len: number = strlen(value);
78
- this.varlen.push(len);
79
- this.uint32(len);
80
- this.len += len;
81
- }
82
-
83
- public fork(): void {
84
- this.pos.push(this.len); // save current position
85
- this.varlenidx.push(this.varlen.length); // save current index in varlen array
86
- this.varlen.push(0); // add 0 length to varlen array (to be updated in ldelim())
87
- }
88
-
89
- public ldelim(): void {
90
- if (!(this.pos.length && this.varlenidx.length))
91
- throw new Error(
92
- "Error on typia.protobuf.encode(): missing fork() before ldelim() call.",
93
- );
94
-
95
- const endPos = this.len; // current position is end position
96
- const startPos = this.pos.pop()!; // get start position from stack
97
- const idx = this.varlenidx.pop()!; // get varlen index from stack
98
- const len = endPos - startPos; // calculate length
99
-
100
- this.varlen[idx] = len; // update variable length
101
- this.uint32(len); // add uint32 that should be called in fork()
102
- }
103
-
104
- public reset(): void {
105
- this.len = 0;
106
- // re-use arrays
107
- this.pos.length = 0;
108
- this.varlen.length = 0;
109
- this.varlenidx.length = 0;
110
- }
111
-
112
- private varint32(value: number): void {
113
- this.len +=
114
- value < 0
115
- ? 10 // 10 bits with leading 1's
116
- : value < 0x80
117
- ? 1
118
- : value < 0x4000
119
- ? 2
120
- : value < 0x200000
121
- ? 3
122
- : value < 0x10000000
123
- ? 4
124
- : 5;
125
- }
126
-
127
- private varint64(val: bigint): void {
128
- val = BigInt.asUintN(64, val);
129
- while (val > BigInt(0x7f)) {
130
- ++this.len;
131
- val = val >> BigInt(0x07);
132
- }
133
- ++this.len;
134
- }
135
- }
136
-
137
- const strlen = (str: string): number => new Blob([str]).size;
1
+ import { _IProtobufWriter } from "./_IProtobufWriter";
2
+
3
+ /// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedSizer.ts
4
+ export class _ProtobufSizer implements _IProtobufWriter {
5
+ /** Total length. */
6
+ public len: number;
7
+
8
+ /** Position stack. */
9
+ public readonly pos: Array<number>;
10
+
11
+ /** Variable length list. */
12
+ public readonly varlen: Array<number>;
13
+
14
+ /** Variable length index stack. */
15
+ public readonly varlenidx: Array<number>;
16
+
17
+ public constructor(length: number = 0) {
18
+ this.len = length;
19
+ this.pos = [];
20
+ this.varlen = [];
21
+ this.varlenidx = [];
22
+ }
23
+
24
+ public bool(): void {
25
+ this.len += 1;
26
+ }
27
+ public int32(value: number): void {
28
+ if (value < 0) {
29
+ // 10 bytes to encode negative number
30
+ this.len += 10;
31
+ } else {
32
+ this.varint32(value);
33
+ }
34
+ }
35
+ public sint32(value: number): void {
36
+ this.varint32((value << 1) ^ (value >> 31));
37
+ }
38
+ public uint32(value: number): void {
39
+ this.varint32(value);
40
+ }
41
+
42
+ public int64(value: bigint | number): void {
43
+ this.varint64(typeof value === "number" ? BigInt(value) : value);
44
+ }
45
+ public sint64(value: bigint | number): void {
46
+ if (typeof value === "number") value = BigInt(value);
47
+ this.varint64((value << BigInt(1)) ^ (value >> BigInt(63)));
48
+ }
49
+ public uint64(value: bigint | number): void {
50
+ this.varint64(typeof value === "number" ? BigInt(value) : value);
51
+ }
52
+
53
+ // public fixed32(_value: number): void {
54
+ // this.len += 4;
55
+ // }
56
+ // public sfixed32(_value: number): void {
57
+ // this.len += 4;
58
+ // }
59
+ // public fixed64(_value: number | bigint): void {
60
+ // this.len += 8;
61
+ // }
62
+ // public sfixed64(_value: number | bigint): void {
63
+ // this.len += 8;
64
+ // }
65
+ public float(_value: number): void {
66
+ this.len += 4;
67
+ }
68
+ public double(_value: number): void {
69
+ this.len += 8;
70
+ }
71
+
72
+ public bytes(value: Uint8Array): void {
73
+ this.uint32(value.byteLength);
74
+ this.len += value.byteLength;
75
+ }
76
+ public string(value: string): void {
77
+ const len: number = strlen(value);
78
+ this.varlen.push(len);
79
+ this.uint32(len);
80
+ this.len += len;
81
+ }
82
+
83
+ public fork(): void {
84
+ this.pos.push(this.len); // save current position
85
+ this.varlenidx.push(this.varlen.length); // save current index in varlen array
86
+ this.varlen.push(0); // add 0 length to varlen array (to be updated in ldelim())
87
+ }
88
+
89
+ public ldelim(): void {
90
+ if (!(this.pos.length && this.varlenidx.length))
91
+ throw new Error(
92
+ "Error on typia.protobuf.encode(): missing fork() before ldelim() call.",
93
+ );
94
+
95
+ const endPos = this.len; // current position is end position
96
+ const startPos = this.pos.pop()!; // get start position from stack
97
+ const idx = this.varlenidx.pop()!; // get varlen index from stack
98
+ const len = endPos - startPos; // calculate length
99
+
100
+ this.varlen[idx] = len; // update variable length
101
+ this.uint32(len); // add uint32 that should be called in fork()
102
+ }
103
+
104
+ public reset(): void {
105
+ this.len = 0;
106
+ // re-use arrays
107
+ this.pos.length = 0;
108
+ this.varlen.length = 0;
109
+ this.varlenidx.length = 0;
110
+ }
111
+
112
+ private varint32(value: number): void {
113
+ this.len +=
114
+ value < 0
115
+ ? 10 // 10 bits with leading 1's
116
+ : value < 0x80
117
+ ? 1
118
+ : value < 0x4000
119
+ ? 2
120
+ : value < 0x200000
121
+ ? 3
122
+ : value < 0x10000000
123
+ ? 4
124
+ : 5;
125
+ }
126
+
127
+ private varint64(val: bigint): void {
128
+ val = BigInt.asUintN(64, val);
129
+ while (val > BigInt(0x7f)) {
130
+ ++this.len;
131
+ val = val >> BigInt(0x07);
132
+ }
133
+ ++this.len;
134
+ }
135
+ }
136
+
137
+ const strlen = (str: string): number => new Blob([str]).size;
@@ -1,135 +1,135 @@
1
- import { Singleton } from "@typia/utils";
2
-
3
- import { _IProtobufWriter } from "./_IProtobufWriter";
4
- import { _ProtobufSizer } from "./_ProtobufSizer";
5
-
6
- /// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedWriter.ts
7
- export class _ProtobufWriter implements _IProtobufWriter {
8
- /** Related sizer */
9
- private readonly sizer: _ProtobufSizer;
10
-
11
- /** Current pointer. */
12
- private ptr: number;
13
-
14
- /** Protobuf buffer. */
15
- private buf: Uint8Array;
16
-
17
- /** DataView for buffer. */
18
- private view: DataView;
19
-
20
- /** Index in varlen array from sizer. */
21
- private varlenidx: number;
22
-
23
- constructor(sizer: _ProtobufSizer) {
24
- this.sizer = sizer;
25
- this.buf = new Uint8Array(sizer.len);
26
- this.view = new DataView(this.buf.buffer);
27
- this.ptr = 0;
28
- this.varlenidx = 0;
29
- }
30
-
31
- buffer(): Uint8Array {
32
- return this.buf;
33
- }
34
-
35
- bool(value: boolean): void {
36
- this.byte(value ? 1 : 0);
37
- }
38
-
39
- byte(value: number): void {
40
- this.buf[this.ptr++] = value & 255;
41
- }
42
-
43
- int32(value: number): void {
44
- if (value < 0) this.int64(value);
45
- else this.variant32(value >>> 0);
46
- }
47
-
48
- sint32(value: number): void {
49
- this.variant32((value << 1) ^ (value >> 31));
50
- }
51
-
52
- uint32(value: number): void {
53
- this.variant32(value);
54
- }
55
-
56
- sint64(value: number | bigint): void {
57
- value = BigInt(value);
58
- this.variant64((value << BigInt(0x01)) ^ (value >> BigInt(0x3f)));
59
- }
60
-
61
- int64(value: number | bigint): void {
62
- this.variant64(BigInt(value));
63
- }
64
-
65
- uint64(value: number | bigint): void {
66
- this.variant64(BigInt(value));
67
- }
68
-
69
- float(val: number): void {
70
- this.view.setFloat32(this.ptr, val, true);
71
- this.ptr += 4;
72
- }
73
-
74
- double(val: number): void {
75
- this.view.setFloat64(this.ptr, val, true);
76
- this.ptr += 8;
77
- }
78
-
79
- bytes(value: Uint8Array): void {
80
- this.uint32(value.byteLength);
81
- for (let i = 0; i < value.byteLength; i++) this.buf[this.ptr++] = value[i]!;
82
- }
83
-
84
- string(value: string): void {
85
- const len: number = this.varlen(); // use precomputed length
86
- this.uint32(len);
87
-
88
- const binary: Uint8Array = utf8.get().encode(value);
89
- for (let i = 0; i < binary.byteLength; i++)
90
- this.buf[this.ptr++] = binary[i]!;
91
- }
92
-
93
- fork(): void {
94
- this.uint32(this.varlen()); // use precomputed length
95
- }
96
-
97
- ldelim(): void {
98
- // nothing to do - all dirty work done by sizer
99
- }
100
-
101
- finish(): Uint8Array {
102
- return this.buf;
103
- }
104
-
105
- reset(): void {
106
- this.buf = new Uint8Array(this.sizer.len);
107
- this.view = new DataView(this.buf.buffer);
108
- this.ptr = 0;
109
- this.varlenidx = 0;
110
- }
111
-
112
- private variant32(val: number): void {
113
- while (val > 0x7f) {
114
- this.buf[this.ptr++] = (val & 0x7f) | 0x80;
115
- val = val >>> 7;
116
- }
117
- this.buf[this.ptr++] = val;
118
- }
119
-
120
- private variant64(val: bigint): void {
121
- val = BigInt.asUintN(64, val);
122
- while (val > BigInt(0x7f)) {
123
- this.buf[this.ptr++] = Number((val & BigInt(0x7f)) | BigInt(0x80));
124
- val = val >> BigInt(0x07);
125
- }
126
- this.buf[this.ptr++] = Number(val);
127
- }
128
-
129
- private varlen(): number {
130
- return this.varlenidx >= this.sizer.varlen.length
131
- ? 0
132
- : this.sizer.varlen[this.varlenidx++]!;
133
- }
134
- }
135
- const utf8 = new Singleton(() => new TextEncoder());
1
+ import { Singleton } from "@typia/utils";
2
+
3
+ import { _IProtobufWriter } from "./_IProtobufWriter";
4
+ import { _ProtobufSizer } from "./_ProtobufSizer";
5
+
6
+ /// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedWriter.ts
7
+ export class _ProtobufWriter implements _IProtobufWriter {
8
+ /** Related sizer */
9
+ private readonly sizer: _ProtobufSizer;
10
+
11
+ /** Current pointer. */
12
+ private ptr: number;
13
+
14
+ /** Protobuf buffer. */
15
+ private buf: Uint8Array;
16
+
17
+ /** DataView for buffer. */
18
+ private view: DataView;
19
+
20
+ /** Index in varlen array from sizer. */
21
+ private varlenidx: number;
22
+
23
+ constructor(sizer: _ProtobufSizer) {
24
+ this.sizer = sizer;
25
+ this.buf = new Uint8Array(sizer.len);
26
+ this.view = new DataView(this.buf.buffer);
27
+ this.ptr = 0;
28
+ this.varlenidx = 0;
29
+ }
30
+
31
+ buffer(): Uint8Array {
32
+ return this.buf;
33
+ }
34
+
35
+ bool(value: boolean): void {
36
+ this.byte(value ? 1 : 0);
37
+ }
38
+
39
+ byte(value: number): void {
40
+ this.buf[this.ptr++] = value & 255;
41
+ }
42
+
43
+ int32(value: number): void {
44
+ if (value < 0) this.int64(value);
45
+ else this.variant32(value >>> 0);
46
+ }
47
+
48
+ sint32(value: number): void {
49
+ this.variant32((value << 1) ^ (value >> 31));
50
+ }
51
+
52
+ uint32(value: number): void {
53
+ this.variant32(value);
54
+ }
55
+
56
+ sint64(value: number | bigint): void {
57
+ value = BigInt(value);
58
+ this.variant64((value << BigInt(0x01)) ^ (value >> BigInt(0x3f)));
59
+ }
60
+
61
+ int64(value: number | bigint): void {
62
+ this.variant64(BigInt(value));
63
+ }
64
+
65
+ uint64(value: number | bigint): void {
66
+ this.variant64(BigInt(value));
67
+ }
68
+
69
+ float(val: number): void {
70
+ this.view.setFloat32(this.ptr, val, true);
71
+ this.ptr += 4;
72
+ }
73
+
74
+ double(val: number): void {
75
+ this.view.setFloat64(this.ptr, val, true);
76
+ this.ptr += 8;
77
+ }
78
+
79
+ bytes(value: Uint8Array): void {
80
+ this.uint32(value.byteLength);
81
+ for (let i = 0; i < value.byteLength; i++) this.buf[this.ptr++] = value[i]!;
82
+ }
83
+
84
+ string(value: string): void {
85
+ const len: number = this.varlen(); // use precomputed length
86
+ this.uint32(len);
87
+
88
+ const binary: Uint8Array = utf8.get().encode(value);
89
+ for (let i = 0; i < binary.byteLength; i++)
90
+ this.buf[this.ptr++] = binary[i]!;
91
+ }
92
+
93
+ fork(): void {
94
+ this.uint32(this.varlen()); // use precomputed length
95
+ }
96
+
97
+ ldelim(): void {
98
+ // nothing to do - all dirty work done by sizer
99
+ }
100
+
101
+ finish(): Uint8Array {
102
+ return this.buf;
103
+ }
104
+
105
+ reset(): void {
106
+ this.buf = new Uint8Array(this.sizer.len);
107
+ this.view = new DataView(this.buf.buffer);
108
+ this.ptr = 0;
109
+ this.varlenidx = 0;
110
+ }
111
+
112
+ private variant32(val: number): void {
113
+ while (val > 0x7f) {
114
+ this.buf[this.ptr++] = (val & 0x7f) | 0x80;
115
+ val = val >>> 7;
116
+ }
117
+ this.buf[this.ptr++] = val;
118
+ }
119
+
120
+ private variant64(val: bigint): void {
121
+ val = BigInt.asUintN(64, val);
122
+ while (val > BigInt(0x7f)) {
123
+ this.buf[this.ptr++] = Number((val & BigInt(0x7f)) | BigInt(0x80));
124
+ val = val >> BigInt(0x07);
125
+ }
126
+ this.buf[this.ptr++] = Number(val);
127
+ }
128
+
129
+ private varlen(): number {
130
+ return this.varlenidx >= this.sizer.varlen.length
131
+ ? 0
132
+ : this.sizer.varlen[this.varlenidx++]!;
133
+ }
134
+ }
135
+ const utf8 = new Singleton(() => new TextEncoder());
@@ -1,46 +1,46 @@
1
- export const _accessExpressionAsString = (str: string): string =>
2
- variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
3
-
4
- const variable = (str: string): boolean =>
5
- reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
6
-
7
- const reserved = (str: string): boolean => RESERVED.has(str);
8
-
9
- const RESERVED: Set<string> = new Set([
10
- "break",
11
- "case",
12
- "catch",
13
- "class",
14
- "const",
15
- "continue",
16
- "debugger",
17
- "default",
18
- "delete",
19
- "do",
20
- "else",
21
- "enum",
22
- "export",
23
- "extends",
24
- "false",
25
- "finally",
26
- "for",
27
- "function",
28
- "if",
29
- "import",
30
- "in",
31
- "instanceof",
32
- "new",
33
- "null",
34
- "return",
35
- "super",
36
- "switch",
37
- "this",
38
- "throw",
39
- "true",
40
- "try",
41
- "typeof",
42
- "var",
43
- "void",
44
- "while",
45
- "with",
46
- ]);
1
+ export const _accessExpressionAsString = (str: string): string =>
2
+ variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
3
+
4
+ const variable = (str: string): boolean =>
5
+ reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
6
+
7
+ const reserved = (str: string): boolean => RESERVED.has(str);
8
+
9
+ const RESERVED: Set<string> = new Set([
10
+ "break",
11
+ "case",
12
+ "catch",
13
+ "class",
14
+ "const",
15
+ "continue",
16
+ "debugger",
17
+ "default",
18
+ "delete",
19
+ "do",
20
+ "else",
21
+ "enum",
22
+ "export",
23
+ "extends",
24
+ "false",
25
+ "finally",
26
+ "for",
27
+ "function",
28
+ "if",
29
+ "import",
30
+ "in",
31
+ "instanceof",
32
+ "new",
33
+ "null",
34
+ "return",
35
+ "super",
36
+ "switch",
37
+ "this",
38
+ "throw",
39
+ "true",
40
+ "try",
41
+ "typeof",
42
+ "var",
43
+ "void",
44
+ "while",
45
+ "with",
46
+ ]);
@@ -1,13 +1,13 @@
1
- import { TypeGuardError } from "../TypeGuardError";
2
-
3
- export const _assertGuard = (
4
- exceptionable: boolean,
5
- props: TypeGuardError.IProps,
6
- factory?: (props: TypeGuardError.IProps) => Error,
7
- ): false => {
8
- if (exceptionable === true) {
9
- if (factory) throw factory(props);
10
- else throw new TypeGuardError(props);
11
- }
12
- return false;
13
- };
1
+ import { TypeGuardError } from "../TypeGuardError";
2
+
3
+ export const _assertGuard = (
4
+ exceptionable: boolean,
5
+ props: TypeGuardError.IProps,
6
+ factory?: (props: TypeGuardError.IProps) => Error,
7
+ ): false => {
8
+ if (exceptionable === true) {
9
+ if (factory) throw factory(props);
10
+ else throw new TypeGuardError(props);
11
+ }
12
+ return false;
13
+ };
@@ -1,7 +1,7 @@
1
- import { ILlmSchema } from "@typia/interface";
2
- import { LlmJson } from "@typia/utils";
3
-
4
- export const _coerceLlmArguments = <T>(
5
- value: unknown,
6
- parameters: ILlmSchema.IParameters,
7
- ): T => LlmJson.coerce(value, parameters);
1
+ import { ILlmSchema } from "@typia/interface";
2
+ import { LlmJson } from "@typia/utils";
3
+
4
+ export const _coerceLlmArguments = <T>(
5
+ value: unknown,
6
+ parameters: ILlmSchema.IParameters,
7
+ ): T => LlmJson.coerce(value, parameters);