typia 3.5.5 → 3.5.7
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/lib/programmers/AssertProgrammer.js +11 -9
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +1 -1
- package/lib/programmers/CheckerProgrammer.js +15 -16
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/CloneProgrammer.js +16 -10
- package/lib/programmers/CloneProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +3 -3
- package/lib/programmers/FeatureProgrammer.js +47 -39
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.js +2 -2
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/PruneProgrammer.js +16 -10
- package/lib/programmers/PruneProgrammer.js.map +1 -1
- package/lib/programmers/StringifyProgrammer.js +17 -11
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +8 -8
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/FunctionImporeter.d.ts +4 -0
- package/lib/programmers/helpers/FunctionImporeter.js +12 -0
- package/lib/programmers/helpers/FunctionImporeter.js.map +1 -1
- package/lib/programmers/internal/feature_object_entries.d.ts +2 -1
- package/lib/programmers/internal/feature_object_entries.js +28 -23
- package/lib/programmers/internal/feature_object_entries.js.map +1 -1
- package/package.json +2 -2
- package/src/programmers/AssertProgrammer.ts +19 -30
- package/src/programmers/CheckerProgrammer.ts +42 -33
- package/src/programmers/CloneProgrammer.ts +30 -20
- package/src/programmers/FeatureProgrammer.ts +38 -28
- package/src/programmers/IsProgrammer.ts +4 -2
- package/src/programmers/PruneProgrammer.ts +30 -20
- package/src/programmers/StringifyProgrammer.ts +31 -21
- package/src/programmers/ValidateProgrammer.ts +9 -9
- package/src/programmers/helpers/FunctionImporeter.ts +15 -0
- package/src/programmers/internal/feature_object_entries.ts +6 -1
|
@@ -54,8 +54,12 @@ export namespace StringifyProgrammer {
|
|
|
54
54
|
|
|
55
55
|
return [
|
|
56
56
|
...importer.declare(modulo),
|
|
57
|
-
...isFunctors,
|
|
58
|
-
|
|
57
|
+
...isFunctors.filter((_, i) =>
|
|
58
|
+
importer.hasLocal(`$io${i}`),
|
|
59
|
+
),
|
|
60
|
+
...isUnioners.filter((_, i) =>
|
|
61
|
+
importer.hasLocal(`$iu${i}`),
|
|
62
|
+
),
|
|
59
63
|
];
|
|
60
64
|
},
|
|
61
65
|
);
|
|
@@ -374,13 +378,13 @@ export namespace StringifyProgrammer {
|
|
|
374
378
|
decoder: decode(project, importer),
|
|
375
379
|
trace: false,
|
|
376
380
|
path: false,
|
|
377
|
-
})(obj)(input);
|
|
381
|
+
})(importer)(obj)(input);
|
|
378
382
|
return StringifyJoiner.object(importer)(
|
|
379
383
|
input,
|
|
380
384
|
entries,
|
|
381
385
|
);
|
|
382
386
|
})()
|
|
383
|
-
: explore_objects(input, meta, {
|
|
387
|
+
: explore_objects(importer)(input, meta, {
|
|
384
388
|
...explore,
|
|
385
389
|
from: "object",
|
|
386
390
|
}),
|
|
@@ -430,12 +434,12 @@ export namespace StringifyProgrammer {
|
|
|
430
434
|
StringifyJoiner.array,
|
|
431
435
|
);
|
|
432
436
|
|
|
433
|
-
const decode_object = () =>
|
|
437
|
+
const decode_object = (importer: FunctionImporter) =>
|
|
434
438
|
FeatureProgrammer.decode_object({
|
|
435
439
|
trace: false,
|
|
436
440
|
path: false,
|
|
437
441
|
functors: FUNCTORS,
|
|
438
|
-
});
|
|
442
|
+
})(importer);
|
|
439
443
|
|
|
440
444
|
const decode_tuple =
|
|
441
445
|
(project: IProject, importer: FunctionImporter) =>
|
|
@@ -590,20 +594,26 @@ export namespace StringifyProgrammer {
|
|
|
590
594
|
create_throw_error(importer, input, expected),
|
|
591
595
|
});
|
|
592
596
|
|
|
593
|
-
const explore_objects =
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
597
|
+
const explore_objects =
|
|
598
|
+
(importer: FunctionImporter) =>
|
|
599
|
+
(
|
|
600
|
+
input: ts.Expression,
|
|
601
|
+
meta: Metadata,
|
|
602
|
+
explore: FeatureProgrammer.IExplore,
|
|
603
|
+
) => {
|
|
604
|
+
if (meta.objects.length === 1)
|
|
605
|
+
return decode_object(importer)(
|
|
606
|
+
input,
|
|
607
|
+
meta.objects[0]!,
|
|
608
|
+
explore,
|
|
609
|
+
);
|
|
600
610
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
611
|
+
return ts.factory.createCallExpression(
|
|
612
|
+
ts.factory.createIdentifier(`${UNIONERS}${meta.union_index!}`),
|
|
613
|
+
undefined,
|
|
614
|
+
[input],
|
|
615
|
+
);
|
|
616
|
+
};
|
|
607
617
|
|
|
608
618
|
/* -----------------------------------------------------------
|
|
609
619
|
RETURN SCRIPTS
|
|
@@ -731,10 +741,10 @@ export namespace StringifyProgrammer {
|
|
|
731
741
|
importer: FunctionImporter,
|
|
732
742
|
): FeatureProgrammer.IConfig.IObjector => ({
|
|
733
743
|
checker: IsProgrammer.decode(project, importer),
|
|
734
|
-
decoder: decode_object(),
|
|
744
|
+
decoder: decode_object(importer),
|
|
735
745
|
joiner: StringifyJoiner.object(importer),
|
|
736
746
|
unionizer: decode_union_object(IsProgrammer.decode_object(importer))(
|
|
737
|
-
decode_object(),
|
|
747
|
+
decode_object(importer),
|
|
738
748
|
)((exp) => exp)((value, expected) =>
|
|
739
749
|
create_throw_error(importer, value, expected),
|
|
740
750
|
),
|
|
@@ -95,8 +95,8 @@ const combine =
|
|
|
95
95
|
})(importer).combiner(explore);
|
|
96
96
|
|
|
97
97
|
const path: string = explore.postfix
|
|
98
|
-
? `
|
|
99
|
-
: "
|
|
98
|
+
? `_path + ${explore.postfix}`
|
|
99
|
+
: "_path";
|
|
100
100
|
return (logic) => (input, binaries, expected) =>
|
|
101
101
|
logic === "and"
|
|
102
102
|
? binaries
|
|
@@ -109,7 +109,7 @@ const combine =
|
|
|
109
109
|
explore.source === "top"
|
|
110
110
|
? ts.factory.createTrue()
|
|
111
111
|
: ts.factory.createIdentifier(
|
|
112
|
-
"
|
|
112
|
+
"_exceptionable",
|
|
113
113
|
),
|
|
114
114
|
)(
|
|
115
115
|
ts.factory.createIdentifier(path),
|
|
@@ -126,7 +126,7 @@ const combine =
|
|
|
126
126
|
create_report_call(
|
|
127
127
|
explore.source === "top"
|
|
128
128
|
? ts.factory.createTrue()
|
|
129
|
-
: ts.factory.createIdentifier("
|
|
129
|
+
: ts.factory.createIdentifier("_exceptionable"),
|
|
130
130
|
)(ts.factory.createIdentifier(path), expected, input),
|
|
131
131
|
);
|
|
132
132
|
};
|
|
@@ -141,7 +141,7 @@ const validate_object = (equals: boolean) => (importer: FunctionImporter) =>
|
|
|
141
141
|
superfluous: (value) =>
|
|
142
142
|
create_report_call()(
|
|
143
143
|
ts.factory.createAdd(
|
|
144
|
-
ts.factory.createIdentifier("
|
|
144
|
+
ts.factory.createIdentifier("_path"),
|
|
145
145
|
ts.factory.createCallExpression(
|
|
146
146
|
importer.use("join"),
|
|
147
147
|
undefined,
|
|
@@ -155,7 +155,7 @@ const validate_object = (equals: boolean) => (importer: FunctionImporter) =>
|
|
|
155
155
|
ts.factory.createLogicalOr(
|
|
156
156
|
ts.factory.createStrictEquality(
|
|
157
157
|
ts.factory.createFalse(),
|
|
158
|
-
ts.factory.createIdentifier("
|
|
158
|
+
ts.factory.createIdentifier("_exceptionable"),
|
|
159
159
|
),
|
|
160
160
|
expr,
|
|
161
161
|
),
|
|
@@ -177,10 +177,10 @@ const joiner =
|
|
|
177
177
|
create_report_call(
|
|
178
178
|
explore?.from === "top"
|
|
179
179
|
? ts.factory.createTrue()
|
|
180
|
-
: ts.factory.createIdentifier("
|
|
180
|
+
: ts.factory.createIdentifier("_exceptionable"),
|
|
181
181
|
)(
|
|
182
182
|
ts.factory.createIdentifier(
|
|
183
|
-
explore?.postfix ? `
|
|
183
|
+
explore?.postfix ? `_path + ${explore.postfix}` : "_path",
|
|
184
184
|
),
|
|
185
185
|
expected,
|
|
186
186
|
value,
|
|
@@ -222,7 +222,7 @@ const create_report_call =
|
|
|
222
222
|
ts.factory.createIdentifier("$report"),
|
|
223
223
|
undefined,
|
|
224
224
|
[
|
|
225
|
-
exceptionable
|
|
225
|
+
exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
|
|
226
226
|
ts.factory.createObjectLiteralExpression(
|
|
227
227
|
[
|
|
228
228
|
ts.factory.createPropertyAssignment("path", path),
|
|
@@ -5,6 +5,7 @@ import { StatementFactory } from "../../factories/StatementFactory";
|
|
|
5
5
|
|
|
6
6
|
export class FunctionImporter {
|
|
7
7
|
private readonly used_: Set<string> = new Set();
|
|
8
|
+
private readonly local_: Set<string> = new Set();
|
|
8
9
|
private sequence_: number = 0;
|
|
9
10
|
|
|
10
11
|
public empty(): boolean {
|
|
@@ -16,6 +17,15 @@ export class FunctionImporter {
|
|
|
16
17
|
return ts.factory.createIdentifier("$" + name);
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
public useLocal(name: string): string {
|
|
21
|
+
this.local_.add(name);
|
|
22
|
+
return name;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public hasLocal(name: string): boolean {
|
|
26
|
+
return this.local_.has(name);
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
public declare(modulo: ts.LeftHandSideExpression): ts.Statement[] {
|
|
20
30
|
return [...this.used_].map((name) =>
|
|
21
31
|
StatementFactory.constant(
|
|
@@ -28,4 +38,9 @@ export class FunctionImporter {
|
|
|
28
38
|
public increment(): number {
|
|
29
39
|
return ++this.sequence_;
|
|
30
40
|
}
|
|
41
|
+
|
|
42
|
+
public trace(): void {
|
|
43
|
+
console.log(...this.used_);
|
|
44
|
+
console.log(...this.local_);
|
|
45
|
+
}
|
|
31
46
|
}
|
|
@@ -7,6 +7,7 @@ import { MetadataObject } from "../../metadata/MetadataObject";
|
|
|
7
7
|
import { Escaper } from "../../utils/Escaper";
|
|
8
8
|
|
|
9
9
|
import { FeatureProgrammer } from "../FeatureProgrammer";
|
|
10
|
+
import { FunctionImporter } from "../helpers/FunctionImporeter";
|
|
10
11
|
|
|
11
12
|
export const feature_object_entries =
|
|
12
13
|
<Output extends ts.ConciseBody>(
|
|
@@ -15,6 +16,7 @@ export const feature_object_entries =
|
|
|
15
16
|
"decoder" | "path" | "trace"
|
|
16
17
|
>,
|
|
17
18
|
) =>
|
|
19
|
+
(importer: FunctionImporter) =>
|
|
18
20
|
(obj: MetadataObject) =>
|
|
19
21
|
(input: ts.Expression) =>
|
|
20
22
|
obj.properties.map((prop) => {
|
|
@@ -46,7 +48,10 @@ export const feature_object_entries =
|
|
|
46
48
|
postfix:
|
|
47
49
|
sole !== null
|
|
48
50
|
? IdentifierFactory.postfix(sole)
|
|
49
|
-
:
|
|
51
|
+
: (() => {
|
|
52
|
+
importer.use("join");
|
|
53
|
+
return `$join(key)`;
|
|
54
|
+
})(),
|
|
50
55
|
},
|
|
51
56
|
prop.tags,
|
|
52
57
|
),
|