Skip to content

Commit 451cc59

Browse files
authored
Merge branch 'v5.3' into fix-typia-home-link
2 parents 2fd3e9f + ab39b05 commit 451cc59

File tree

17,639 files changed

+1890715
-1745765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

17,639 files changed

+1890715
-1745765
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"editor.tabSize": 4,
2+
"editor.tabSize": 2,
33
"[typescript]": {
44
"editor.defaultFormatter": "esbenp.prettier-vscode",
55
"editor.formatOnSave": true,
Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,71 @@
11
import fs from "fs";
22

33
export namespace BenchmarkProgrammer {
4-
export interface ICategory {
5-
name: string;
6-
libraries: ILibrary[];
7-
features: string[];
8-
}
9-
export interface ILibrary {
10-
name: string;
11-
body: (input: string) => string;
12-
}
4+
export interface ICategory {
5+
name: string;
6+
libraries: ILibrary[];
7+
features: string[];
8+
}
9+
export interface ILibrary {
10+
name: string;
11+
body: (input: string) => string;
12+
}
1313

14-
export async function generate(
15-
category: ICategory,
16-
filter: (p: { library: string; feature: string }) => boolean = (p) =>
17-
(p.library === "class-transformer" ||
18-
p.library === "class-validator") &&
19-
p.feature === "UltimateUnion",
20-
): Promise<void> {
21-
for (const library of category.libraries) {
22-
const location: string = [
23-
__dirname,
24-
"..",
25-
"programs",
26-
emend(category.name),
27-
emend(library.name),
28-
].join("/");
29-
try {
30-
await fs.promises.mkdir(location, { recursive: true });
31-
} catch {}
32-
for (const file of await fs.promises.readdir(location))
33-
if (!file.includes("create"))
34-
await fs.promises.rm(`${location}/${file}`);
14+
export async function generate(
15+
category: ICategory,
16+
filter: (p: { library: string; feature: string }) => boolean = (p) =>
17+
(p.library === "class-transformer" || p.library === "class-validator") &&
18+
p.feature === "UltimateUnion",
19+
): Promise<void> {
20+
for (const library of category.libraries) {
21+
const location: string = [
22+
__dirname,
23+
"..",
24+
"programs",
25+
emend(category.name),
26+
emend(library.name),
27+
].join("/");
28+
try {
29+
await fs.promises.mkdir(location, { recursive: true });
30+
} catch {}
31+
for (const file of await fs.promises.readdir(location))
32+
if (!file.includes("create"))
33+
await fs.promises.rm(`${location}/${file}`);
3534

36-
for (const feature of category.features) {
37-
if (
38-
filter({
39-
feature,
40-
library: library.name,
41-
})
42-
)
43-
continue;
35+
for (const feature of category.features) {
36+
if (
37+
filter({
38+
feature,
39+
library: library.name,
40+
})
41+
)
42+
continue;
4443

45-
const file: string = [
46-
"benchmark",
47-
emend(category.name.split("/")[0]),
48-
emend(library.name),
49-
feature,
50-
].join("-");
44+
const file: string = [
45+
"benchmark",
46+
emend(category.name.split("/")[0]),
47+
emend(library.name),
48+
feature,
49+
].join("-");
5150

52-
await fs.promises.writeFile(
53-
`${location}/${file}.ts`,
54-
library.body(feature),
55-
"utf8",
56-
);
57-
}
58-
}
51+
await fs.promises.writeFile(
52+
`${location}/${file}.ts`,
53+
library.body(feature),
54+
"utf8",
55+
);
56+
}
5957
}
58+
}
6059

61-
export const emend = (name: string) =>
62-
name
63-
.replace("(", "")
64-
.replaceAll(")", "")
65-
.replaceAll(" ", "-")
66-
.toLowerCase();
67-
export const pascal = (name: string) =>
68-
name
69-
.split("-")
70-
.map((str) => str[0].toUpperCase() + str.slice(1))
71-
.join("");
60+
export const emend = (name: string) =>
61+
name
62+
.replace("(", "")
63+
.replaceAll(")", "")
64+
.replaceAll(" ", "-")
65+
.toLowerCase();
66+
export const pascal = (name: string) =>
67+
name
68+
.split("-")
69+
.map((str) => str[0].toUpperCase() + str.slice(1))
70+
.join("");
7271
}

benchmark/generate/assert-error.ts

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
11
import { BenchmarkProgrammer } from "./BenchmarkProgrammer";
22

33
const FEATURES: string[] = [
4-
"ObjectSimple",
5-
"ObjectHierarchical",
6-
"ObjectRecursive",
7-
"ObjectUnionExplicit",
8-
"ObjectUnionImplicit",
9-
"ArrayRecursive",
10-
"ArrayRecursiveUnionExplicit",
11-
"ArrayRecursiveUnionImplicit",
12-
"UltimateUnion",
4+
"ObjectSimple",
5+
"ObjectHierarchical",
6+
"ObjectRecursive",
7+
"ObjectUnionExplicit",
8+
"ObjectUnionImplicit",
9+
"ArrayRecursive",
10+
"ArrayRecursiveUnionExplicit",
11+
"ArrayRecursiveUnionImplicit",
12+
"UltimateUnion",
1313
];
1414

1515
const LIBRARIES = (category: string): BenchmarkProgrammer.ILibrary[] => [
16-
{
17-
name: "typia",
18-
body: (type) => {
19-
const program = `create${BenchmarkProgrammer.pascal(
20-
category,
21-
)}BenchmarkProgram`;
22-
return [
23-
`import typia from "typia";`,
24-
``,
25-
`import { ${type} } from "../../../../test/structures/${type}";`,
26-
`import { ${program} } from "../${program}";`,
27-
``,
28-
`${program}(`,
29-
` typia.create${BenchmarkProgrammer.pascal(category).replace(
30-
"Error",
31-
"",
32-
)}<${BenchmarkProgrammer.pascal(type)}[]>()`,
33-
`);`,
34-
].join("\n");
35-
},
16+
{
17+
name: "typia",
18+
body: (type) => {
19+
const program = `create${BenchmarkProgrammer.pascal(
20+
category,
21+
)}BenchmarkProgram`;
22+
return [
23+
`import typia from "typia";`,
24+
``,
25+
`import { ${type} } from "../../../../test/structures/${type}";`,
26+
`import { ${program} } from "../${program}";`,
27+
``,
28+
`${program}(`,
29+
` typia.create${BenchmarkProgrammer.pascal(category).replace(
30+
"Error",
31+
"",
32+
)}<${BenchmarkProgrammer.pascal(type)}[]>()`,
33+
`);`,
34+
].join("\n");
3635
},
37-
{
38-
name: "typebox",
39-
body: (type) => {
40-
const schema: string = `Typebox${type}`;
41-
const program: string = `create${BenchmarkProgrammer.pascal(
42-
category,
43-
)}TypeboxBenchmarkProgram`;
36+
},
37+
{
38+
name: "typebox",
39+
body: (type) => {
40+
const schema: string = `Typebox${type}`;
41+
const program: string = `create${BenchmarkProgrammer.pascal(
42+
category,
43+
)}TypeboxBenchmarkProgram`;
4444

45-
return [
46-
`import { __${schema} } from "../../../structures/typebox/${schema}";`,
47-
``,
48-
`import { ${program} } from "./${program}";`,
49-
``,
50-
`${program}(__${schema});`,
51-
].join("\n");
52-
},
45+
return [
46+
`import { __${schema} } from "../../../structures/typebox/${schema}";`,
47+
``,
48+
`import { ${program} } from "./${program}";`,
49+
``,
50+
`${program}(__${schema});`,
51+
].join("\n");
5352
},
54-
...["io-ts", "zod", "class-validator"].map((name) => ({
55-
name,
56-
body: (type: string) => {
57-
const schema: string = `${BenchmarkProgrammer.pascal(name)}${type}`;
58-
const program: string = `create${BenchmarkProgrammer.pascal(
59-
category,
60-
)}${BenchmarkProgrammer.pascal(name)}BenchmarkProgram`;
53+
},
54+
...["io-ts", "zod", "class-validator"].map((name) => ({
55+
name,
56+
body: (type: string) => {
57+
const schema: string = `${BenchmarkProgrammer.pascal(name)}${type}`;
58+
const program: string = `create${BenchmarkProgrammer.pascal(
59+
category,
60+
)}${BenchmarkProgrammer.pascal(name)}BenchmarkProgram`;
6161

62-
return [
63-
`import { ${schema} } from "../../../structures/${name}/${schema}";`,
64-
``,
65-
`import { ${program} } from "./${program}";`,
66-
``,
67-
`${program}(${schema});`,
68-
].join("\n");
69-
},
70-
})),
62+
return [
63+
`import { ${schema} } from "../../../structures/${name}/${schema}";`,
64+
``,
65+
`import { ${program} } from "./${program}";`,
66+
``,
67+
`${program}(${schema});`,
68+
].join("\n");
69+
},
70+
})),
7171
];
7272

7373
async function main(): Promise<void> {
74-
await BenchmarkProgrammer.generate({
75-
name: "assert-error",
76-
libraries: LIBRARIES("assert-error"),
77-
features: FEATURES,
78-
});
74+
await BenchmarkProgrammer.generate({
75+
name: "assert-error",
76+
libraries: LIBRARIES("assert-error"),
77+
features: FEATURES,
78+
});
7979
}
8080

8181
main().catch((exp) => {
82-
console.error(exp);
83-
process.exit(-1);
82+
console.error(exp);
83+
process.exit(-1);
8484
});

0 commit comments

Comments
 (0)