xsschema 0.1.0-beta.2 → 0.1.0-beta.4
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/dist/index.js +18 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
const memoize = (fn) => {
|
|
2
|
+
let cache;
|
|
3
|
+
return async () => {
|
|
4
|
+
if (cache === undefined)
|
|
5
|
+
cache = await fn();
|
|
6
|
+
return cache;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
const importValibotToJsonSchema = memoize(async () => {
|
|
10
|
+
const { toJsonSchema: toJsonSchema2 } = await import('./valibot-wA2mWK4s.js');
|
|
11
|
+
return toJsonSchema2;
|
|
12
|
+
});
|
|
13
|
+
const importZodToJsonSchema = memoize(async () => {
|
|
14
|
+
const { toJsonSchema: toJsonSchema2 } = await import('./zod-Cz57Gws5.js');
|
|
15
|
+
return toJsonSchema2;
|
|
16
|
+
});
|
|
1
17
|
const toJsonSchema = async (schema) => {
|
|
2
18
|
switch (schema["~standard"].vendor) {
|
|
3
19
|
case "valibot":
|
|
4
|
-
return (await
|
|
20
|
+
return (await importValibotToJsonSchema())(schema);
|
|
5
21
|
case "zod":
|
|
6
|
-
return (await
|
|
22
|
+
return (await importZodToJsonSchema())(schema);
|
|
7
23
|
default:
|
|
8
24
|
throw new Error(`xsschema: Unsupported schema vendor ${schema["~standard"].vendor}`);
|
|
9
25
|
}
|