mirror of
https://github.com/JonasunderscoreJones/api.jonasjones.dev.git
synced 2025-10-23 20:19:19 +02:00
Initial commit (by create-cloudflare CLI)
This commit is contained in:
commit
58a42872a0
1745 changed files with 741893 additions and 0 deletions
5
node_modules/zod/lib/benchmarks/discriminatedUnion.d.ts
generated
vendored
Normal file
5
node_modules/zod/lib/benchmarks/discriminatedUnion.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Benchmark from "benchmark";
|
||||
declare const _default: {
|
||||
suites: Benchmark.Suite[];
|
||||
};
|
||||
export default _default;
|
79
node_modules/zod/lib/benchmarks/discriminatedUnion.js
generated
vendored
Normal file
79
node_modules/zod/lib/benchmarks/discriminatedUnion.js
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const benchmark_1 = __importDefault(require("benchmark"));
|
||||
const index_1 = require("../index");
|
||||
const doubleSuite = new benchmark_1.default.Suite("z.discriminatedUnion: double");
|
||||
const manySuite = new benchmark_1.default.Suite("z.discriminatedUnion: many");
|
||||
const aSchema = index_1.z.object({
|
||||
type: index_1.z.literal("a"),
|
||||
});
|
||||
const objA = {
|
||||
type: "a",
|
||||
};
|
||||
const bSchema = index_1.z.object({
|
||||
type: index_1.z.literal("b"),
|
||||
});
|
||||
const objB = {
|
||||
type: "b",
|
||||
};
|
||||
const cSchema = index_1.z.object({
|
||||
type: index_1.z.literal("c"),
|
||||
});
|
||||
const objC = {
|
||||
type: "c",
|
||||
};
|
||||
const dSchema = index_1.z.object({
|
||||
type: index_1.z.literal("d"),
|
||||
});
|
||||
const double = index_1.z.discriminatedUnion("type", [aSchema, bSchema]);
|
||||
const many = index_1.z.discriminatedUnion("type", [aSchema, bSchema, cSchema, dSchema]);
|
||||
doubleSuite
|
||||
.add("valid: a", () => {
|
||||
double.parse(objA);
|
||||
})
|
||||
.add("valid: b", () => {
|
||||
double.parse(objB);
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
double.parse(null);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.add("invalid: wrong shape", () => {
|
||||
try {
|
||||
double.parse(objC);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${doubleSuite.name}: ${e.target}`);
|
||||
});
|
||||
manySuite
|
||||
.add("valid: a", () => {
|
||||
many.parse(objA);
|
||||
})
|
||||
.add("valid: c", () => {
|
||||
many.parse(objC);
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
many.parse(null);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.add("invalid: wrong shape", () => {
|
||||
try {
|
||||
many.parse({ type: "unknown" });
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${manySuite.name}: ${e.target}`);
|
||||
});
|
||||
exports.default = {
|
||||
suites: [doubleSuite, manySuite],
|
||||
};
|
1
node_modules/zod/lib/benchmarks/index.d.ts
generated
vendored
Normal file
1
node_modules/zod/lib/benchmarks/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export {};
|
46
node_modules/zod/lib/benchmarks/index.js
generated
vendored
Normal file
46
node_modules/zod/lib/benchmarks/index.js
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const discriminatedUnion_1 = __importDefault(require("./discriminatedUnion"));
|
||||
const object_1 = __importDefault(require("./object"));
|
||||
const primitives_1 = __importDefault(require("./primitives"));
|
||||
const realworld_1 = __importDefault(require("./realworld"));
|
||||
const string_1 = __importDefault(require("./string"));
|
||||
const union_1 = __importDefault(require("./union"));
|
||||
const argv = process.argv.slice(2);
|
||||
let suites = [];
|
||||
if (!argv.length) {
|
||||
suites = [
|
||||
...realworld_1.default.suites,
|
||||
...primitives_1.default.suites,
|
||||
...string_1.default.suites,
|
||||
...object_1.default.suites,
|
||||
...union_1.default.suites,
|
||||
...discriminatedUnion_1.default.suites,
|
||||
];
|
||||
}
|
||||
else {
|
||||
if (argv.includes("--realworld")) {
|
||||
suites.push(...realworld_1.default.suites);
|
||||
}
|
||||
if (argv.includes("--primitives")) {
|
||||
suites.push(...primitives_1.default.suites);
|
||||
}
|
||||
if (argv.includes("--string")) {
|
||||
suites.push(...string_1.default.suites);
|
||||
}
|
||||
if (argv.includes("--object")) {
|
||||
suites.push(...object_1.default.suites);
|
||||
}
|
||||
if (argv.includes("--union")) {
|
||||
suites.push(...union_1.default.suites);
|
||||
}
|
||||
if (argv.includes("--discriminatedUnion")) {
|
||||
suites.push(...discriminatedUnion_1.default.suites);
|
||||
}
|
||||
}
|
||||
for (const suite of suites) {
|
||||
suite.run();
|
||||
}
|
5
node_modules/zod/lib/benchmarks/object.d.ts
generated
vendored
Normal file
5
node_modules/zod/lib/benchmarks/object.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Benchmark from "benchmark";
|
||||
declare const _default: {
|
||||
suites: Benchmark.Suite[];
|
||||
};
|
||||
export default _default;
|
70
node_modules/zod/lib/benchmarks/object.js
generated
vendored
Normal file
70
node_modules/zod/lib/benchmarks/object.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const benchmark_1 = __importDefault(require("benchmark"));
|
||||
const index_1 = require("../index");
|
||||
const emptySuite = new benchmark_1.default.Suite("z.object: empty");
|
||||
const shortSuite = new benchmark_1.default.Suite("z.object: short");
|
||||
const longSuite = new benchmark_1.default.Suite("z.object: long");
|
||||
const empty = index_1.z.object({});
|
||||
const short = index_1.z.object({
|
||||
string: index_1.z.string(),
|
||||
});
|
||||
const long = index_1.z.object({
|
||||
string: index_1.z.string(),
|
||||
number: index_1.z.number(),
|
||||
boolean: index_1.z.boolean(),
|
||||
});
|
||||
emptySuite
|
||||
.add("valid", () => {
|
||||
empty.parse({});
|
||||
})
|
||||
.add("valid: extra keys", () => {
|
||||
empty.parse({ string: "string" });
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
empty.parse(null);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${emptySuite.name}: ${e.target}`);
|
||||
});
|
||||
shortSuite
|
||||
.add("valid", () => {
|
||||
short.parse({ string: "string" });
|
||||
})
|
||||
.add("valid: extra keys", () => {
|
||||
short.parse({ string: "string", number: 42 });
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
short.parse(null);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${shortSuite.name}: ${e.target}`);
|
||||
});
|
||||
longSuite
|
||||
.add("valid", () => {
|
||||
long.parse({ string: "string", number: 42, boolean: true });
|
||||
})
|
||||
.add("valid: extra keys", () => {
|
||||
long.parse({ string: "string", number: 42, boolean: true, list: [] });
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
long.parse(null);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${longSuite.name}: ${e.target}`);
|
||||
});
|
||||
exports.default = {
|
||||
suites: [emptySuite, shortSuite, longSuite],
|
||||
};
|
5
node_modules/zod/lib/benchmarks/primitives.d.ts
generated
vendored
Normal file
5
node_modules/zod/lib/benchmarks/primitives.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Benchmark from "benchmark";
|
||||
declare const _default: {
|
||||
suites: Benchmark.Suite[];
|
||||
};
|
||||
export default _default;
|
136
node_modules/zod/lib/benchmarks/primitives.js
generated
vendored
Normal file
136
node_modules/zod/lib/benchmarks/primitives.js
generated
vendored
Normal file
|
@ -0,0 +1,136 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const benchmark_1 = __importDefault(require("benchmark"));
|
||||
const Mocker_1 = require("../__tests__/Mocker");
|
||||
const index_1 = require("../index");
|
||||
const val = new Mocker_1.Mocker();
|
||||
const enumSuite = new benchmark_1.default.Suite("z.enum");
|
||||
const enumSchema = index_1.z.enum(["a", "b", "c"]);
|
||||
enumSuite
|
||||
.add("valid", () => {
|
||||
enumSchema.parse("a");
|
||||
})
|
||||
.add("invalid", () => {
|
||||
try {
|
||||
enumSchema.parse("x");
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`z.enum: ${e.target}`);
|
||||
});
|
||||
const undefinedSuite = new benchmark_1.default.Suite("z.undefined");
|
||||
const undefinedSchema = index_1.z.undefined();
|
||||
undefinedSuite
|
||||
.add("valid", () => {
|
||||
undefinedSchema.parse(undefined);
|
||||
})
|
||||
.add("invalid", () => {
|
||||
try {
|
||||
undefinedSchema.parse(1);
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`z.undefined: ${e.target}`);
|
||||
});
|
||||
const literalSuite = new benchmark_1.default.Suite("z.literal");
|
||||
const short = "short";
|
||||
const bad = "bad";
|
||||
const literalSchema = index_1.z.literal("short");
|
||||
literalSuite
|
||||
.add("valid", () => {
|
||||
literalSchema.parse(short);
|
||||
})
|
||||
.add("invalid", () => {
|
||||
try {
|
||||
literalSchema.parse(bad);
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`z.literal: ${e.target}`);
|
||||
});
|
||||
const numberSuite = new benchmark_1.default.Suite("z.number");
|
||||
const numberSchema = index_1.z.number().int();
|
||||
numberSuite
|
||||
.add("valid", () => {
|
||||
numberSchema.parse(1);
|
||||
})
|
||||
.add("invalid type", () => {
|
||||
try {
|
||||
numberSchema.parse("bad");
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.add("invalid number", () => {
|
||||
try {
|
||||
numberSchema.parse(0.5);
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`z.number: ${e.target}`);
|
||||
});
|
||||
const dateSuite = new benchmark_1.default.Suite("z.date");
|
||||
const plainDate = index_1.z.date();
|
||||
const minMaxDate = index_1.z
|
||||
.date()
|
||||
.min(new Date("2021-01-01"))
|
||||
.max(new Date("2030-01-01"));
|
||||
dateSuite
|
||||
.add("valid", () => {
|
||||
plainDate.parse(new Date());
|
||||
})
|
||||
.add("invalid", () => {
|
||||
try {
|
||||
plainDate.parse(1);
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.add("valid min and max", () => {
|
||||
minMaxDate.parse(new Date("2023-01-01"));
|
||||
})
|
||||
.add("invalid min", () => {
|
||||
try {
|
||||
minMaxDate.parse(new Date("2019-01-01"));
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.add("invalid max", () => {
|
||||
try {
|
||||
minMaxDate.parse(new Date("2031-01-01"));
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`z.date: ${e.target}`);
|
||||
});
|
||||
const symbolSuite = new benchmark_1.default.Suite("z.symbol");
|
||||
const symbolSchema = index_1.z.symbol();
|
||||
symbolSuite
|
||||
.add("valid", () => {
|
||||
symbolSchema.parse(val.symbol);
|
||||
})
|
||||
.add("invalid", () => {
|
||||
try {
|
||||
symbolSchema.parse(1);
|
||||
}
|
||||
catch (e) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`z.symbol: ${e.target}`);
|
||||
});
|
||||
exports.default = {
|
||||
suites: [
|
||||
enumSuite,
|
||||
undefinedSuite,
|
||||
literalSuite,
|
||||
numberSuite,
|
||||
dateSuite,
|
||||
symbolSuite,
|
||||
],
|
||||
};
|
5
node_modules/zod/lib/benchmarks/realworld.d.ts
generated
vendored
Normal file
5
node_modules/zod/lib/benchmarks/realworld.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Benchmark from "benchmark";
|
||||
declare const _default: {
|
||||
suites: Benchmark.Suite[];
|
||||
};
|
||||
export default _default;
|
56
node_modules/zod/lib/benchmarks/realworld.js
generated
vendored
Normal file
56
node_modules/zod/lib/benchmarks/realworld.js
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const benchmark_1 = __importDefault(require("benchmark"));
|
||||
const index_1 = require("../index");
|
||||
const shortSuite = new benchmark_1.default.Suite("realworld");
|
||||
const People = index_1.z.array(index_1.z.object({
|
||||
type: index_1.z.literal("person"),
|
||||
hair: index_1.z.enum(["blue", "brown"]),
|
||||
active: index_1.z.boolean(),
|
||||
name: index_1.z.string(),
|
||||
age: index_1.z.number().int(),
|
||||
hobbies: index_1.z.array(index_1.z.string()),
|
||||
address: index_1.z.object({
|
||||
street: index_1.z.string(),
|
||||
zip: index_1.z.string(),
|
||||
country: index_1.z.string(),
|
||||
}),
|
||||
}));
|
||||
let i = 0;
|
||||
function num() {
|
||||
return ++i;
|
||||
}
|
||||
function str() {
|
||||
return (++i % 100).toString(16);
|
||||
}
|
||||
function array(fn) {
|
||||
return Array.from({ length: ++i % 10 }, () => fn());
|
||||
}
|
||||
const people = Array.from({ length: 100 }, () => {
|
||||
return {
|
||||
type: "person",
|
||||
hair: i % 2 ? "blue" : "brown",
|
||||
active: !!(i % 2),
|
||||
name: str(),
|
||||
age: num(),
|
||||
hobbies: array(str),
|
||||
address: {
|
||||
street: str(),
|
||||
zip: str(),
|
||||
country: str(),
|
||||
},
|
||||
};
|
||||
});
|
||||
shortSuite
|
||||
.add("valid", () => {
|
||||
People.parse(people);
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${shortSuite.name}: ${e.target}`);
|
||||
});
|
||||
exports.default = {
|
||||
suites: [shortSuite],
|
||||
};
|
5
node_modules/zod/lib/benchmarks/string.d.ts
generated
vendored
Normal file
5
node_modules/zod/lib/benchmarks/string.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Benchmark from "benchmark";
|
||||
declare const _default: {
|
||||
suites: Benchmark.Suite[];
|
||||
};
|
||||
export default _default;
|
55
node_modules/zod/lib/benchmarks/string.js
generated
vendored
Normal file
55
node_modules/zod/lib/benchmarks/string.js
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const benchmark_1 = __importDefault(require("benchmark"));
|
||||
const index_1 = require("../index");
|
||||
const SUITE_NAME = "z.string";
|
||||
const suite = new benchmark_1.default.Suite(SUITE_NAME);
|
||||
const empty = "";
|
||||
const short = "short";
|
||||
const long = "long".repeat(256);
|
||||
const manual = (str) => {
|
||||
if (typeof str !== "string") {
|
||||
throw new Error("Not a string");
|
||||
}
|
||||
return str;
|
||||
};
|
||||
const stringSchema = index_1.z.string();
|
||||
const optionalStringSchema = index_1.z.string().optional();
|
||||
const optionalNullableStringSchema = index_1.z.string().optional().nullable();
|
||||
suite
|
||||
.add("empty string", () => {
|
||||
stringSchema.parse(empty);
|
||||
})
|
||||
.add("short string", () => {
|
||||
stringSchema.parse(short);
|
||||
})
|
||||
.add("long string", () => {
|
||||
stringSchema.parse(long);
|
||||
})
|
||||
.add("optional string", () => {
|
||||
optionalStringSchema.parse(long);
|
||||
})
|
||||
.add("nullable string", () => {
|
||||
optionalNullableStringSchema.parse(long);
|
||||
})
|
||||
.add("nullable (null) string", () => {
|
||||
optionalNullableStringSchema.parse(null);
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
stringSchema.parse(null);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.add("manual parser: long", () => {
|
||||
manual(long);
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${SUITE_NAME}: ${e.target}`);
|
||||
});
|
||||
exports.default = {
|
||||
suites: [suite],
|
||||
};
|
5
node_modules/zod/lib/benchmarks/union.d.ts
generated
vendored
Normal file
5
node_modules/zod/lib/benchmarks/union.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Benchmark from "benchmark";
|
||||
declare const _default: {
|
||||
suites: Benchmark.Suite[];
|
||||
};
|
||||
export default _default;
|
79
node_modules/zod/lib/benchmarks/union.js
generated
vendored
Normal file
79
node_modules/zod/lib/benchmarks/union.js
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const benchmark_1 = __importDefault(require("benchmark"));
|
||||
const index_1 = require("../index");
|
||||
const doubleSuite = new benchmark_1.default.Suite("z.union: double");
|
||||
const manySuite = new benchmark_1.default.Suite("z.union: many");
|
||||
const aSchema = index_1.z.object({
|
||||
type: index_1.z.literal("a"),
|
||||
});
|
||||
const objA = {
|
||||
type: "a",
|
||||
};
|
||||
const bSchema = index_1.z.object({
|
||||
type: index_1.z.literal("b"),
|
||||
});
|
||||
const objB = {
|
||||
type: "b",
|
||||
};
|
||||
const cSchema = index_1.z.object({
|
||||
type: index_1.z.literal("c"),
|
||||
});
|
||||
const objC = {
|
||||
type: "c",
|
||||
};
|
||||
const dSchema = index_1.z.object({
|
||||
type: index_1.z.literal("d"),
|
||||
});
|
||||
const double = index_1.z.union([aSchema, bSchema]);
|
||||
const many = index_1.z.union([aSchema, bSchema, cSchema, dSchema]);
|
||||
doubleSuite
|
||||
.add("valid: a", () => {
|
||||
double.parse(objA);
|
||||
})
|
||||
.add("valid: b", () => {
|
||||
double.parse(objB);
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
double.parse(null);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.add("invalid: wrong shape", () => {
|
||||
try {
|
||||
double.parse(objC);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${doubleSuite.name}: ${e.target}`);
|
||||
});
|
||||
manySuite
|
||||
.add("valid: a", () => {
|
||||
many.parse(objA);
|
||||
})
|
||||
.add("valid: c", () => {
|
||||
many.parse(objC);
|
||||
})
|
||||
.add("invalid: null", () => {
|
||||
try {
|
||||
many.parse(null);
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.add("invalid: wrong shape", () => {
|
||||
try {
|
||||
many.parse({ type: "unknown" });
|
||||
}
|
||||
catch (err) { }
|
||||
})
|
||||
.on("cycle", (e) => {
|
||||
console.log(`${manySuite.name}: ${e.target}`);
|
||||
});
|
||||
exports.default = {
|
||||
suites: [doubleSuite, manySuite],
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue