typia 5.0.0-dev.20230822 → 5.0.0-dev.20230823-2
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.
- package/README.md +1 -1
- package/lib/Primitive.d.ts +14 -12
- package/lib/Resolved.d.ts +46 -0
- package/lib/{schemas/metadata/IMetadataResolved.js → Resolved.js} +1 -1
- package/lib/Resolved.js.map +1 -0
- package/lib/factories/MetadataFactory.d.ts +1 -1
- package/lib/factories/MetadataTagFactory.js +6 -6
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/factories/ProtobufFactory.js +2 -2
- package/lib/factories/ProtobufFactory.js.map +1 -1
- package/lib/factories/internal/metadata/explore_metadata.js +3 -3
- package/lib/factories/internal/metadata/explore_metadata.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_collection.js +6 -6
- package/lib/factories/internal/metadata/iterate_metadata_collection.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_native.js +2 -10
- package/lib/factories/internal/metadata/iterate_metadata_native.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_resolve.js +6 -6
- package/lib/factories/internal/metadata/iterate_metadata_resolve.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_sort.js +2 -2
- package/lib/factories/internal/metadata/iterate_metadata_sort.js.map +1 -1
- package/lib/functional/$ProtobufWriter.js.map +1 -1
- package/lib/json.d.ts +15 -15
- package/lib/misc.d.ts +42 -42
- package/lib/module.d.ts +18 -17
- package/lib/module.js +1 -0
- package/lib/module.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +1 -1
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.js +1 -1
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.js +2 -2
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +307 -132
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +1 -1
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/FunctionImporeter.d.ts +2 -0
- package/lib/programmers/helpers/FunctionImporeter.js +2 -1
- package/lib/programmers/helpers/FunctionImporeter.js.map +1 -1
- package/lib/programmers/helpers/StringifyPredicator.js +1 -2
- package/lib/programmers/helpers/StringifyPredicator.js.map +1 -1
- package/lib/programmers/helpers/disable_function_importer_declare.js +1 -0
- package/lib/programmers/helpers/disable_function_importer_declare.js.map +1 -1
- package/lib/programmers/internal/application_resolved.d.ts +2 -2
- package/lib/programmers/internal/application_resolved.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +2 -2
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js +4 -4
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscAssertCloneProgrammer.js +1 -1
- package/lib/programmers/misc/MiscAssertCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +114 -33
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscIsCloneProgrammer.js +1 -1
- package/lib/programmers/misc/MiscIsCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +2 -2
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscValidateCloneProgrammer.js +1 -1
- package/lib/programmers/misc/MiscValidateCloneProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js +3 -3
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +15 -10
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +8 -6
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufIsDecodeProgrammer.js +2 -2
- package/lib/programmers/protobuf/ProtobufIsDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufValidateDecodeProgrammer.js +1 -1
- package/lib/programmers/protobuf/ProtobufValidateDecodeProgrammer.js.map +1 -1
- package/lib/protobuf.d.ts +631 -10
- package/lib/protobuf.js +13 -13
- package/lib/protobuf.js.map +1 -1
- package/lib/schemas/metadata/IMetadata.d.ts +2 -2
- package/lib/schemas/metadata/{IMetadataResolved.d.ts → IMetadataEscaped.d.ts} +1 -1
- package/lib/schemas/metadata/IMetadataEscaped.js +3 -0
- package/lib/schemas/metadata/IMetadataEscaped.js.map +1 -0
- package/lib/schemas/metadata/Metadata.d.ts +2 -2
- package/lib/schemas/metadata/Metadata.js +15 -15
- package/lib/schemas/metadata/Metadata.js.map +1 -1
- package/lib/schemas/metadata/{MetadataResolved.d.ts → MetadataEscaped.d.ts} +3 -3
- package/lib/schemas/metadata/{MetadataResolved.js → MetadataEscaped.js} +11 -11
- package/lib/schemas/metadata/MetadataEscaped.js.map +1 -0
- package/lib/transformers/features/json/JsonApplicationTransformer.js +1 -1
- package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/misc/MetadataTransformer.js +1 -1
- package/lib/transformers/features/misc/MetadataTransformer.js.map +1 -1
- package/lib/utils/RandomGenerator.js +3 -2
- package/lib/utils/RandomGenerator.js.map +1 -1
- package/package.json +2 -1
- package/src/Primitive.ts +19 -15
- package/src/Resolved.ts +116 -0
- package/src/factories/MetadataFactory.ts +1 -1
- package/src/factories/MetadataTagFactory.ts +6 -6
- package/src/factories/ProtobufFactory.ts +2 -2
- package/src/factories/internal/metadata/explore_metadata.ts +3 -3
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +6 -6
- package/src/factories/internal/metadata/iterate_metadata_native.ts +0 -9
- package/src/factories/internal/metadata/iterate_metadata_resolve.ts +6 -6
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +2 -2
- package/src/functional/$ProtobufWriter.ts +1 -2
- package/src/json.ts +15 -15
- package/src/misc.ts +42 -42
- package/src/module.ts +18 -17
- package/src/programmers/AssertProgrammer.ts +3 -1
- package/src/programmers/CheckerProgrammer.ts +1 -1
- package/src/programmers/IsProgrammer.ts +4 -2
- package/src/programmers/RandomProgrammer.ts +322 -26
- package/src/programmers/ValidateProgrammer.ts +3 -1
- package/src/programmers/helpers/FunctionImporeter.ts +2 -0
- package/src/programmers/helpers/StringifyPredicator.ts +1 -2
- package/src/programmers/helpers/disable_function_importer_declare.ts +6 -1
- package/src/programmers/internal/application_resolved.ts +2 -2
- package/src/programmers/internal/application_schema.ts +2 -2
- package/src/programmers/json/JsonStringifyProgrammer.ts +6 -4
- package/src/programmers/misc/MiscAssertCloneProgrammer.ts +1 -1
- package/src/programmers/misc/MiscCloneProgrammer.ts +229 -41
- package/src/programmers/misc/MiscIsCloneProgrammer.ts +1 -1
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +1 -1
- package/src/programmers/misc/MiscPruneProgrammer.ts +4 -2
- package/src/programmers/misc/MiscValidateCloneProgrammer.ts +1 -1
- package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +18 -9
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +45 -25
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +15 -13
- package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +12 -2
- package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +2 -2
- package/src/protobuf.ts +663 -31
- package/src/schemas/metadata/IMetadata.ts +2 -2
- package/src/schemas/metadata/{IMetadataResolved.ts → IMetadataEscaped.ts} +1 -1
- package/src/schemas/metadata/Metadata.ts +17 -20
- package/src/schemas/metadata/{MetadataResolved.ts → MetadataEscaped.ts} +9 -9
- package/src/transformers/features/json/JsonApplicationTransformer.ts +1 -1
- package/src/transformers/features/misc/MetadataTransformer.ts +1 -1
- package/src/utils/RandomGenerator.ts +4 -2
- package/lib/schemas/metadata/IMetadataResolved.js.map +0 -1
- package/lib/schemas/metadata/MetadataResolved.js.map +0 -1
package/src/Resolved.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolved type erased every methods.
|
|
3
|
+
*
|
|
4
|
+
* `Resolved` is a type of TMP (Type Meta Programming) type which converts
|
|
5
|
+
* its argument as a resolved type that erased every method properties.
|
|
6
|
+
*
|
|
7
|
+
* If the target argument is a built-in class which returns its origin primitive type
|
|
8
|
+
* through the `valueOf()` method like the `String` or `Number`, its return type would
|
|
9
|
+
* be the `string` or `number`. Otherwise, the built-in class does not have the
|
|
10
|
+
* `valueOf()` method, the return type would be same with the target argument.
|
|
11
|
+
*
|
|
12
|
+
* Otherwise, the target argument is a type of custom class, all of its custom methods
|
|
13
|
+
* would be erased and its prototype would be changed to the primitive `object`.
|
|
14
|
+
* Therefore, return type of the TMP type finally be the resolved object.
|
|
15
|
+
*
|
|
16
|
+
* Before | After
|
|
17
|
+
* ------------------------|----------------------------------------
|
|
18
|
+
* `Boolean` | `boolean`
|
|
19
|
+
* `Number` | `number`
|
|
20
|
+
* `BigInt` | `bigint`
|
|
21
|
+
* `String` | `string`
|
|
22
|
+
* `Class` | `interface`
|
|
23
|
+
* Native Claas or Others | No change
|
|
24
|
+
*
|
|
25
|
+
* @template Instance Target argument type.
|
|
26
|
+
* @author Jenogho Nam - https://github.com/samchon
|
|
27
|
+
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
28
|
+
*/
|
|
29
|
+
export type Resolved<T> = Equal<T, ResolvedMain<T>> extends true
|
|
30
|
+
? T
|
|
31
|
+
: ResolvedMain<T>;
|
|
32
|
+
|
|
33
|
+
type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
|
|
34
|
+
|
|
35
|
+
type ResolvedMain<Instance> = Instance extends [never]
|
|
36
|
+
? never // (special trick for jsonable | null) type
|
|
37
|
+
: ValueOf<Instance> extends boolean | number | bigint | string
|
|
38
|
+
? ValueOf<Instance>
|
|
39
|
+
: Instance extends Function
|
|
40
|
+
? never
|
|
41
|
+
: Instance extends object
|
|
42
|
+
? ResolvedObject<Instance>
|
|
43
|
+
: ValueOf<Instance>;
|
|
44
|
+
|
|
45
|
+
type ResolvedObject<Instance extends object> = Instance extends Array<infer T>
|
|
46
|
+
? IsTuple<Instance> extends true
|
|
47
|
+
? ResolvedTuple<Instance>
|
|
48
|
+
: ResolvedMain<T>[]
|
|
49
|
+
: Instance extends Set<infer U>
|
|
50
|
+
? Set<ResolvedMain<U>>
|
|
51
|
+
: Instance extends Map<infer K, infer V>
|
|
52
|
+
? Map<ResolvedMain<K>, ResolvedMain<V>>
|
|
53
|
+
: Instance extends WeakSet<any> | WeakMap<any, any>
|
|
54
|
+
? never
|
|
55
|
+
: Instance extends
|
|
56
|
+
| Date
|
|
57
|
+
| Uint8Array
|
|
58
|
+
| Uint8ClampedArray
|
|
59
|
+
| Uint16Array
|
|
60
|
+
| Uint32Array
|
|
61
|
+
| BigUint64Array
|
|
62
|
+
| Int8Array
|
|
63
|
+
| Int16Array
|
|
64
|
+
| Int32Array
|
|
65
|
+
| BigInt64Array
|
|
66
|
+
| Float32Array
|
|
67
|
+
| Float64Array
|
|
68
|
+
| ArrayBuffer
|
|
69
|
+
| SharedArrayBuffer
|
|
70
|
+
| DataView
|
|
71
|
+
? Instance
|
|
72
|
+
: {
|
|
73
|
+
[P in keyof Instance]: ResolvedMain<Instance[P]>;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
type ResolvedTuple<T extends readonly any[]> = T extends []
|
|
77
|
+
? []
|
|
78
|
+
: T extends [infer F]
|
|
79
|
+
? [ResolvedMain<F>]
|
|
80
|
+
: T extends [infer F, ...infer Rest extends readonly any[]]
|
|
81
|
+
? [ResolvedMain<F>, ...ResolvedTuple<Rest>]
|
|
82
|
+
: T extends [(infer F)?]
|
|
83
|
+
? [ResolvedMain<F>?]
|
|
84
|
+
: T extends [(infer F)?, ...infer Rest extends readonly any[]]
|
|
85
|
+
? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]
|
|
86
|
+
: [];
|
|
87
|
+
|
|
88
|
+
type ValueOf<Instance> = IsValueOf<Instance, Boolean> extends true
|
|
89
|
+
? boolean
|
|
90
|
+
: IsValueOf<Instance, Number> extends true
|
|
91
|
+
? number
|
|
92
|
+
: IsValueOf<Instance, String> extends true
|
|
93
|
+
? string
|
|
94
|
+
: Instance;
|
|
95
|
+
|
|
96
|
+
type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
|
|
97
|
+
never,
|
|
98
|
+
]
|
|
99
|
+
? false
|
|
100
|
+
: T extends readonly any[]
|
|
101
|
+
? number extends T["length"]
|
|
102
|
+
? false
|
|
103
|
+
: true
|
|
104
|
+
: false;
|
|
105
|
+
|
|
106
|
+
type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
|
|
107
|
+
? Object extends IValueOf<infer Primitive>
|
|
108
|
+
? Instance extends Primitive
|
|
109
|
+
? false
|
|
110
|
+
: true // not Primitive, but Object
|
|
111
|
+
: false // cannot be
|
|
112
|
+
: false;
|
|
113
|
+
|
|
114
|
+
interface IValueOf<T> {
|
|
115
|
+
valueOf(): T;
|
|
116
|
+
}
|
|
@@ -318,8 +318,8 @@ const has_atomic =
|
|
|
318
318
|
metadata.aliases.some((alias) =>
|
|
319
319
|
has_atomic(type)(visited)(alias.value),
|
|
320
320
|
) ||
|
|
321
|
-
(metadata.
|
|
322
|
-
has_atomic(type)(visited)(metadata.
|
|
321
|
+
(metadata.escaped !== null &&
|
|
322
|
+
has_atomic(type)(visited)(metadata.escaped.returns))
|
|
323
323
|
);
|
|
324
324
|
};
|
|
325
325
|
|
|
@@ -341,8 +341,8 @@ const has_native =
|
|
|
341
341
|
metadata.aliases.some((alias) =>
|
|
342
342
|
has_native(type)(visited)(alias.value),
|
|
343
343
|
) ||
|
|
344
|
-
(metadata.
|
|
345
|
-
has_native(type)(visited)(metadata.
|
|
344
|
+
(metadata.escaped !== null &&
|
|
345
|
+
has_native(type)(visited)(metadata.escaped.returns))
|
|
346
346
|
);
|
|
347
347
|
};
|
|
348
348
|
|
|
@@ -358,7 +358,7 @@ const has_array =
|
|
|
358
358
|
) ||
|
|
359
359
|
metadata.maps.some((map) => has_array(visited)(map.value)) ||
|
|
360
360
|
metadata.aliases.some((alias) => has_array(visited)(alias.value)) ||
|
|
361
|
-
(metadata.
|
|
362
|
-
has_array(visited)(metadata.
|
|
361
|
+
(metadata.escaped !== null &&
|
|
362
|
+
has_array(visited)(metadata.escaped.returns))
|
|
363
363
|
);
|
|
364
364
|
};
|
|
@@ -18,7 +18,7 @@ export namespace ProtobufFactory {
|
|
|
18
18
|
(type: ts.Type) => {
|
|
19
19
|
// COMPOSE METADATA WITH INDIVIDUAL VALIDATIONS
|
|
20
20
|
const top: Metadata = MetadataFactory.analyze(checker)({
|
|
21
|
-
|
|
21
|
+
escape: false,
|
|
22
22
|
constant: true,
|
|
23
23
|
absorb: true,
|
|
24
24
|
validate: validate(method),
|
|
@@ -231,7 +231,7 @@ export namespace ProtobufFactory {
|
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
const prefix = (method: string) => `Error on
|
|
234
|
+
const prefix = (method: string) => `Error on ${method}():`;
|
|
235
235
|
|
|
236
236
|
const notSupportedError = (p: { method: string }) => (title: string) =>
|
|
237
237
|
new Error(
|
|
@@ -30,9 +30,9 @@ export const explore_metadata =
|
|
|
30
30
|
aliased,
|
|
31
31
|
);
|
|
32
32
|
emend_metadata_atomics(meta);
|
|
33
|
-
if (meta.
|
|
34
|
-
emend_metadata_atomics(meta.
|
|
35
|
-
emend_metadata_atomics(meta.
|
|
33
|
+
if (meta.escaped) {
|
|
34
|
+
emend_metadata_atomics(meta.escaped.original);
|
|
35
|
+
emend_metadata_atomics(meta.escaped.returns);
|
|
36
36
|
}
|
|
37
37
|
return meta;
|
|
38
38
|
};
|
|
@@ -58,8 +58,8 @@ const isArrayRecursive =
|
|
|
58
58
|
) ||
|
|
59
59
|
meta.maps.some((m) => isArrayRecursive(visited)(array)(m.value)) ||
|
|
60
60
|
meta.sets.some((s) => isArrayRecursive(visited)(array)(s)) ||
|
|
61
|
-
(meta.
|
|
62
|
-
isArrayRecursive(visited)(array)(meta.
|
|
61
|
+
(meta.escaped !== null &&
|
|
62
|
+
isArrayRecursive(visited)(array)(meta.escaped.returns)) ||
|
|
63
63
|
(meta.rest !== null && isArrayRecursive(visited)(array)(meta.rest))
|
|
64
64
|
);
|
|
65
65
|
};
|
|
@@ -86,8 +86,8 @@ const isTupleRecursive =
|
|
|
86
86
|
meta.aliases.some((alias) =>
|
|
87
87
|
isTupleRecursive(visited)(tuple)(alias.value),
|
|
88
88
|
) ||
|
|
89
|
-
(meta.
|
|
90
|
-
isTupleRecursive(visited)(tuple)(meta.
|
|
89
|
+
(meta.escaped !== null &&
|
|
90
|
+
isTupleRecursive(visited)(tuple)(meta.escaped.returns)) ||
|
|
91
91
|
(meta.rest !== null && isTupleRecursive(visited)(tuple)(meta.rest))
|
|
92
92
|
);
|
|
93
93
|
};
|
|
@@ -126,8 +126,8 @@ const isObjectRecursive =
|
|
|
126
126
|
isObjectRecursive(visited)(obj)(map.value),
|
|
127
127
|
) ||
|
|
128
128
|
meta.sets.some((value) => isObjectRecursive(visited)(obj)(value)) ||
|
|
129
|
-
(meta.
|
|
130
|
-
isObjectRecursive(visited)(obj)(meta.
|
|
129
|
+
(meta.escaped !== null &&
|
|
130
|
+
isObjectRecursive(visited)(obj)(meta.escaped.returns)) ||
|
|
131
131
|
(meta.rest !== null && isObjectRecursive(visited)(obj)(meta.rest))
|
|
132
132
|
);
|
|
133
133
|
};
|
|
@@ -21,12 +21,6 @@ export const iterate_metadata_native =
|
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const complicate = COMPLICATES.get(name);
|
|
25
|
-
if (complicate && validator(complicate)) {
|
|
26
|
-
ArrayUtil.set(meta.natives, complicate.name ?? name, (str) => str);
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
24
|
for (const generic of GENERICS)
|
|
31
25
|
if (
|
|
32
26
|
name.substring(0, generic.name.length) === generic.name &&
|
|
@@ -190,9 +184,6 @@ const SIMPLES: Map<string, IClassInfo> = new Map([
|
|
|
190
184
|
},
|
|
191
185
|
],
|
|
192
186
|
]);
|
|
193
|
-
const COMPLICATES: Map<string, IClassInfo> = new Map([
|
|
194
|
-
[`'buffer'.global.Buffer`, getBinaryProps("Buffer")],
|
|
195
|
-
]);
|
|
196
187
|
const GENERICS: Array<IClassInfo & { name: string }> = [
|
|
197
188
|
"WeakMap",
|
|
198
189
|
"WeakSet",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
|
|
3
3
|
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import {
|
|
4
|
+
import { MetadataEscaped } from "../../../schemas/metadata/MetadataEscaped";
|
|
5
5
|
|
|
6
6
|
import { Writable } from "../../../typings/Writable";
|
|
7
7
|
|
|
@@ -22,25 +22,25 @@ export const iterate_metadata_resolve =
|
|
|
22
22
|
resolved: boolean,
|
|
23
23
|
aliased: boolean,
|
|
24
24
|
): boolean => {
|
|
25
|
-
if (options.
|
|
25
|
+
if (options.escape === false || resolved === true) return false;
|
|
26
26
|
|
|
27
27
|
const escaped: ts.Type | null = TypeFactory.resolve(checker)(type);
|
|
28
28
|
if (escaped === null) return false;
|
|
29
29
|
|
|
30
|
-
if (meta.
|
|
31
|
-
Writable(meta).
|
|
30
|
+
if (meta.escaped === null) {
|
|
31
|
+
Writable(meta).escaped = MetadataEscaped.create({
|
|
32
32
|
original: Metadata.initialize(),
|
|
33
33
|
returns: Metadata.initialize(),
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
iterate_metadata(checker)(options)(collection)(
|
|
37
|
-
meta.
|
|
37
|
+
meta.escaped!.original,
|
|
38
38
|
type,
|
|
39
39
|
true,
|
|
40
40
|
aliased,
|
|
41
41
|
);
|
|
42
42
|
iterate_metadata(checker)(options)(collection)(
|
|
43
|
-
meta.
|
|
43
|
+
meta.escaped!.returns,
|
|
44
44
|
escaped,
|
|
45
45
|
true,
|
|
46
46
|
aliased,
|
|
@@ -27,8 +27,8 @@ const iterate =
|
|
|
27
27
|
// ITERATE CHILDREN
|
|
28
28
|
for (const map of meta.maps) iterate(visited)(collection)(map.value);
|
|
29
29
|
for (const set of meta.sets) iterate(visited)(collection)(set);
|
|
30
|
-
if (meta.
|
|
31
|
-
iterate(visited)(collection)(meta.
|
|
30
|
+
if (meta.escaped !== null)
|
|
31
|
+
iterate(visited)(collection)(meta.escaped.returns);
|
|
32
32
|
if (meta.rest !== null) iterate(visited)(collection)(meta.rest);
|
|
33
33
|
|
|
34
34
|
// SORT OBJECTS
|
|
@@ -130,8 +130,7 @@ export class $ProtobufWriter implements IProtobufWriter {
|
|
|
130
130
|
val = BigInt.asUintN(64, val);
|
|
131
131
|
while (val > NX7F) {
|
|
132
132
|
this.buf[this.ptr++] = Number((val & NX7F) | NX80);
|
|
133
|
-
val = val >> ND07;
|
|
134
|
-
// (val / (128n) % 2n === 1n)
|
|
133
|
+
val = val >> ND07;
|
|
135
134
|
}
|
|
136
135
|
this.buf[this.ptr++] = Number(val);
|
|
137
136
|
}
|
package/src/json.ts
CHANGED
|
@@ -340,7 +340,7 @@ export function isStringify<T>(input: T): string | null;
|
|
|
340
340
|
* `typia.json.isStringify()` is a combination function of {@link is} and
|
|
341
341
|
* {@link stringify}. Therefore, it converts an input value to JSON
|
|
342
342
|
* (JavaScript Object Notation) string, with type checking.
|
|
343
|
-
*
|
|
343
|
+
*
|
|
344
344
|
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
345
345
|
* `null` value. Otherwise, there's no problem on the `input` value, JSON string
|
|
346
346
|
* would be returned.
|
|
@@ -430,8 +430,8 @@ Object.assign(validateStringify, Namespace.json.stringify("validateStringify"));
|
|
|
430
430
|
/**
|
|
431
431
|
* Creates a reusable {@link isParse} function.
|
|
432
432
|
*
|
|
433
|
-
* @danger You
|
|
434
|
-
* @
|
|
433
|
+
* @danger You must configure the generic argument `T`
|
|
434
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
435
435
|
* @throws compile error
|
|
436
436
|
*
|
|
437
437
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -459,8 +459,8 @@ Object.assign(createIsParse, isParse);
|
|
|
459
459
|
/**
|
|
460
460
|
* Creates a reusable {@link assertParse} function.
|
|
461
461
|
*
|
|
462
|
-
* @danger You
|
|
463
|
-
* @
|
|
462
|
+
* @danger You must configure the generic argument `T`
|
|
463
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
464
464
|
* @throws compile error
|
|
465
465
|
*
|
|
466
466
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -488,8 +488,8 @@ Object.assign(createAssertParse, assertParse);
|
|
|
488
488
|
/**
|
|
489
489
|
* Creates a reusable {@link validateParse} function.
|
|
490
490
|
*
|
|
491
|
-
* @danger You
|
|
492
|
-
* @
|
|
491
|
+
* @danger You must configure the generic argument `T`
|
|
492
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
493
493
|
* @throws compile error
|
|
494
494
|
*
|
|
495
495
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -521,8 +521,8 @@ Object.assign(createValidateParse, validateParse);
|
|
|
521
521
|
/**
|
|
522
522
|
* Creates a reusable {@link stringify} function.
|
|
523
523
|
*
|
|
524
|
-
* @danger You
|
|
525
|
-
* @
|
|
524
|
+
* @danger You must configure the generic argument `T`
|
|
525
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
526
526
|
* @throws compile error
|
|
527
527
|
*
|
|
528
528
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -550,8 +550,8 @@ Object.assign(createStringify, stringify);
|
|
|
550
550
|
/**
|
|
551
551
|
* Creates a reusable {@link assertStringify} function.
|
|
552
552
|
*
|
|
553
|
-
* @danger You
|
|
554
|
-
* @
|
|
553
|
+
* @danger You must configure the generic argument `T`
|
|
554
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
555
555
|
* @throws compile error
|
|
556
556
|
*
|
|
557
557
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -579,8 +579,8 @@ Object.assign(createAssertStringify, assertStringify);
|
|
|
579
579
|
/**
|
|
580
580
|
* Creates a reusable {@link isStringify} function.
|
|
581
581
|
*
|
|
582
|
-
* @danger You
|
|
583
|
-
* @
|
|
582
|
+
* @danger You must configure the generic argument `T`
|
|
583
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
584
584
|
* @throws compile error
|
|
585
585
|
*
|
|
586
586
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -608,8 +608,8 @@ Object.assign(createIsStringify, isStringify);
|
|
|
608
608
|
/**
|
|
609
609
|
* Creates a reusable {@link validateStringify} function.
|
|
610
610
|
*
|
|
611
|
-
* @danger You
|
|
612
|
-
* @
|
|
611
|
+
* @danger You must configure the generic argument `T`
|
|
612
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
613
613
|
* @throws compile error
|
|
614
614
|
*
|
|
615
615
|
* @author Jeongho Nam - https://github.com/samchon
|
package/src/misc.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { Namespace } from "./functional/Namespace";
|
|
|
12
12
|
import { Atomic } from "./typings/Atomic";
|
|
13
13
|
|
|
14
14
|
import { IValidation } from "./IValidation";
|
|
15
|
-
import {
|
|
15
|
+
import { Resolved } from "./Resolved";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* > You must configure the generic argument `T`.
|
|
@@ -62,8 +62,8 @@ export function literals(): never {
|
|
|
62
62
|
* Clone a data.
|
|
63
63
|
*
|
|
64
64
|
* Clones an instance following type `T`. If the target *input* value or its member
|
|
65
|
-
* variable contains a class instance
|
|
66
|
-
*
|
|
65
|
+
* variable contains a class instance having methods, those methods would not be
|
|
66
|
+
* cloned.
|
|
67
67
|
*
|
|
68
68
|
* For reference, this `typia.misc.clone()` function does not validate the input value
|
|
69
69
|
* type. It just believes that the input value is following the type `T`. Therefore,
|
|
@@ -76,7 +76,7 @@ export function literals(): never {
|
|
|
76
76
|
*
|
|
77
77
|
* @author Jeongho Nam - https://github.com/samchon
|
|
78
78
|
*/
|
|
79
|
-
export function clone<T>(input: T):
|
|
79
|
+
export function clone<T>(input: T): Resolved<T>;
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* @internal
|
|
@@ -90,8 +90,8 @@ Object.assign(clone, Namespace.misc.clone("clone"));
|
|
|
90
90
|
* Clone a data with type assertion.
|
|
91
91
|
*
|
|
92
92
|
* Clones an instance following type `T`, with type assertion. If the target `input`
|
|
93
|
-
* value or its member variable contains a class instance
|
|
94
|
-
*
|
|
93
|
+
* value or its member variable contains a class instance having methods, those
|
|
94
|
+
* methods would not be cloned.
|
|
95
95
|
*
|
|
96
96
|
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
97
97
|
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
|
|
@@ -103,14 +103,14 @@ Object.assign(clone, Namespace.misc.clone("clone"));
|
|
|
103
103
|
*
|
|
104
104
|
* @author Jeongho Nam - https://github.com/samchon
|
|
105
105
|
*/
|
|
106
|
-
export function assertClone<T>(input: T):
|
|
106
|
+
export function assertClone<T>(input: T): Resolved<T>;
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Clone a data with type assertion.
|
|
110
110
|
*
|
|
111
111
|
* Clones an instance following type `T`, with type assertion. If the target `input`
|
|
112
|
-
* value or its member variable contains a class instance
|
|
113
|
-
*
|
|
112
|
+
* value or its member variable contains a class instance having methods, those
|
|
113
|
+
* methods would not be cloned.
|
|
114
114
|
*
|
|
115
115
|
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
116
116
|
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
|
|
@@ -122,7 +122,7 @@ export function assertClone<T>(input: T): Primitive<T>;
|
|
|
122
122
|
*
|
|
123
123
|
* @author Jeongho Nam - https://github.com/samchon
|
|
124
124
|
*/
|
|
125
|
-
export function assertClone<T>(input: unknown):
|
|
125
|
+
export function assertClone<T>(input: unknown): Resolved<T>;
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* @internal
|
|
@@ -137,8 +137,8 @@ Object.assign(assertClone, Namespace.misc.clone("assertClone"));
|
|
|
137
137
|
* Clone a data with type checking.
|
|
138
138
|
*
|
|
139
139
|
* Clones an instance following type `T`, with type checking. If the target `input`
|
|
140
|
-
* value or its member variable contains a class instance
|
|
141
|
-
*
|
|
140
|
+
* value or its member variable contains a class instance having methods, those
|
|
141
|
+
* methods would not be cloned.
|
|
142
142
|
*
|
|
143
143
|
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
144
144
|
* `null` value instead. Otherwise, there's no problem on the `input` value, cloned
|
|
@@ -150,14 +150,14 @@ Object.assign(assertClone, Namespace.misc.clone("assertClone"));
|
|
|
150
150
|
*
|
|
151
151
|
* @author Jeongho Nam - https://github.com/samchon
|
|
152
152
|
*/
|
|
153
|
-
export function isClone<T>(input: T):
|
|
153
|
+
export function isClone<T>(input: T): Resolved<T> | null;
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
* Clone a data with type checking.
|
|
157
157
|
*
|
|
158
158
|
* Clones an instance following type `T`, with type checking. If the target `input`
|
|
159
|
-
* value or its member variable contains a class instance
|
|
160
|
-
*
|
|
159
|
+
* value or its member variable contains a class instance having methods, those
|
|
160
|
+
* methods would not be cloned.
|
|
161
161
|
*
|
|
162
162
|
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
163
163
|
* `null` value instead. Otherwise, there's no problem on the `input` value, cloned
|
|
@@ -169,7 +169,7 @@ export function isClone<T>(input: T): Primitive<T> | null;
|
|
|
169
169
|
*
|
|
170
170
|
* @author Jeongho Nam - https://github.com/samchon
|
|
171
171
|
*/
|
|
172
|
-
export function isClone<T>(input: unknown):
|
|
172
|
+
export function isClone<T>(input: unknown): Resolved<T> | null;
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* @internal
|
|
@@ -184,8 +184,8 @@ Object.assign(isClone, Namespace.misc.clone("isClone"));
|
|
|
184
184
|
* Clone a data with detailed type validation.
|
|
185
185
|
*
|
|
186
186
|
* Clones an instance following type `T`, with detailed type validation. If the target
|
|
187
|
-
* `input` value or its member variable contains a class instance
|
|
188
|
-
*
|
|
187
|
+
* `input` value or its member variable contains a class instance having methods,
|
|
188
|
+
* those methods would not be cloned.
|
|
189
189
|
*
|
|
190
190
|
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
191
191
|
* {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
|
|
@@ -196,14 +196,14 @@ Object.assign(isClone, Namespace.misc.clone("isClone"));
|
|
|
196
196
|
* @param input A value to be cloned
|
|
197
197
|
* @returns Validation result with cloned value
|
|
198
198
|
*/
|
|
199
|
-
export function validateClone<T>(input: T): IValidation<
|
|
199
|
+
export function validateClone<T>(input: T): IValidation<Resolved<T>>;
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* Clone a data with detailed type validation.
|
|
203
203
|
*
|
|
204
204
|
* Clones an instance following type `T`, with detailed type validation. If the target
|
|
205
|
-
* `input` value or its member variable contains a class instance
|
|
206
|
-
*
|
|
205
|
+
* `input` value or its member variable contains a class instance having methods,
|
|
206
|
+
* those methods would not be cloned.
|
|
207
207
|
*
|
|
208
208
|
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
209
209
|
* {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
|
|
@@ -214,7 +214,7 @@ export function validateClone<T>(input: T): IValidation<Primitive<T>>;
|
|
|
214
214
|
* @param input A value to be cloned
|
|
215
215
|
* @returns Validation result with cloned value
|
|
216
216
|
*/
|
|
217
|
-
export function validateClone<T>(input: unknown): IValidation<
|
|
217
|
+
export function validateClone<T>(input: unknown): IValidation<Resolved<T>>;
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
220
|
* @internal
|
|
@@ -406,8 +406,8 @@ Object.assign(validatePrune, Namespace.validate());
|
|
|
406
406
|
/**
|
|
407
407
|
* Creates a reusable {@link clone} function.
|
|
408
408
|
*
|
|
409
|
-
* @danger You
|
|
410
|
-
* @
|
|
409
|
+
* @danger You must configure the generic argument `T`
|
|
410
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
411
411
|
* @throws compile error
|
|
412
412
|
*
|
|
413
413
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -422,7 +422,7 @@ export function createClone(): never;
|
|
|
422
422
|
*
|
|
423
423
|
* @author Jeongho Nam - https://github.com/samchon
|
|
424
424
|
*/
|
|
425
|
-
export function createClone<T>(): (input: T) =>
|
|
425
|
+
export function createClone<T>(): (input: T) => Resolved<T>;
|
|
426
426
|
|
|
427
427
|
/**
|
|
428
428
|
* @internal
|
|
@@ -435,8 +435,8 @@ Object.assign(createClone, clone);
|
|
|
435
435
|
/**
|
|
436
436
|
* Creates a reusable {@link assertClone} function.
|
|
437
437
|
*
|
|
438
|
-
* @danger You
|
|
439
|
-
* @
|
|
438
|
+
* @danger You must configure the generic argument `T`
|
|
439
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
440
440
|
* @throws compile error
|
|
441
441
|
*
|
|
442
442
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -451,7 +451,7 @@ export function createAssertClone(): never;
|
|
|
451
451
|
*
|
|
452
452
|
* @author Jeongho Nam - https://github.com/samchon
|
|
453
453
|
*/
|
|
454
|
-
export function createAssertClone<T>(): (input: unknown) =>
|
|
454
|
+
export function createAssertClone<T>(): (input: unknown) => Resolved<T>;
|
|
455
455
|
|
|
456
456
|
/**
|
|
457
457
|
* @internal
|
|
@@ -464,8 +464,8 @@ Object.assign(createAssertClone, assertClone);
|
|
|
464
464
|
/**
|
|
465
465
|
* Creates a reusable {@link isClone} function.
|
|
466
466
|
*
|
|
467
|
-
* @danger You
|
|
468
|
-
* @
|
|
467
|
+
* @danger You must configure the generic argument `T`
|
|
468
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
469
469
|
* @throws compile error
|
|
470
470
|
*
|
|
471
471
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -480,7 +480,7 @@ export function createIsClone(): never;
|
|
|
480
480
|
*
|
|
481
481
|
* @author Jeongho Nam - https://github.com/samchon
|
|
482
482
|
*/
|
|
483
|
-
export function createIsClone<T>(): (input: unknown) =>
|
|
483
|
+
export function createIsClone<T>(): (input: unknown) => Resolved<T> | null;
|
|
484
484
|
|
|
485
485
|
/**
|
|
486
486
|
* @internal
|
|
@@ -493,8 +493,8 @@ Object.assign(createIsClone, isClone);
|
|
|
493
493
|
/**
|
|
494
494
|
* Creates a reusable {@link validateClone} function.
|
|
495
495
|
*
|
|
496
|
-
* @danger You
|
|
497
|
-
* @
|
|
496
|
+
* @danger You must configure the generic argument `T`
|
|
497
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
498
498
|
* @throws compile error
|
|
499
499
|
*
|
|
500
500
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -511,7 +511,7 @@ export function createValidateClone(): never;
|
|
|
511
511
|
*/
|
|
512
512
|
export function createValidateClone<T>(): (
|
|
513
513
|
input: unknown,
|
|
514
|
-
) => IValidation<
|
|
514
|
+
) => IValidation<Resolved<T>>;
|
|
515
515
|
|
|
516
516
|
/**
|
|
517
517
|
* @internal
|
|
@@ -524,8 +524,8 @@ Object.assign(createValidateClone, validateClone);
|
|
|
524
524
|
/**
|
|
525
525
|
* Creates a reusable {@link prune} function.
|
|
526
526
|
*
|
|
527
|
-
* @danger You
|
|
528
|
-
* @
|
|
527
|
+
* @danger You must configure the generic argument `T`
|
|
528
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
529
529
|
* @throws compile error
|
|
530
530
|
*
|
|
531
531
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -553,8 +553,8 @@ Object.assign(createPrune, prune);
|
|
|
553
553
|
/**
|
|
554
554
|
* Creates a reusable {@link assertPrune} function.
|
|
555
555
|
*
|
|
556
|
-
* @danger You
|
|
557
|
-
* @
|
|
556
|
+
* @danger You must configure the generic argument `T`
|
|
557
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
558
558
|
* @throws compile error
|
|
559
559
|
*
|
|
560
560
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -582,8 +582,8 @@ Object.assign(createAssertPrune, assertPrune);
|
|
|
582
582
|
/**
|
|
583
583
|
* Creates a reusable {@link isPrune} function.
|
|
584
584
|
*
|
|
585
|
-
* @danger You
|
|
586
|
-
* @
|
|
585
|
+
* @danger You must configure the generic argument `T`
|
|
586
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
587
587
|
* @throws compile error
|
|
588
588
|
*
|
|
589
589
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -611,8 +611,8 @@ Object.assign(createIsPrune, isPrune);
|
|
|
611
611
|
/**
|
|
612
612
|
* Creates a reusable {@link validatePrune} function.
|
|
613
613
|
*
|
|
614
|
-
* @danger You
|
|
615
|
-
* @
|
|
614
|
+
* @danger You must configure the generic argument `T`
|
|
615
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
616
616
|
* @throws compile error
|
|
617
617
|
*
|
|
618
618
|
* @author Jeongho Nam - https://github.com/samchon
|