@iyio/common
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -21,2 +21,2 @@ import { ZodEnum, ZodError, ZodSchema, ZodTypeAny } from "zod"; | ||
} | undefined; | ||
export declare const zodTypeToJsonScheme: (scheme: ZodTypeAny, maxDepth?: number) => JsonScheme | undefined; | ||
export declare const zodTypeToJsonScheme: (scheme: ZodTypeAny, maxDepth?: number, cache?: boolean) => JsonScheme | undefined; |
@@ -145,5 +145,14 @@ import { ZodArray, ZodBoolean, ZodEnum, ZodLazy, ZodLiteral, ZodNull, ZodNumber, ZodObject, ZodOptional, ZodString, ZodUndefined, ZodUnion } from "zod"; | ||
}; | ||
export const zodTypeToJsonScheme = (scheme, maxDepth = 10) => { | ||
const cacheKey = Symbol('zodHelperCacheKey'); | ||
export const zodTypeToJsonScheme = (scheme, maxDepth = 10, cache = true) => { | ||
var _a; | ||
return (_a = _zodTypeToJsonScheme(scheme, maxDepth)) === null || _a === void 0 ? void 0 : _a.jsonType; | ||
const cached = cache ? scheme[cacheKey] : undefined; | ||
if (cached) { | ||
return cached; | ||
} | ||
const v = (_a = _zodTypeToJsonScheme(scheme, maxDepth)) === null || _a === void 0 ? void 0 : _a.jsonType; | ||
if (cache) { | ||
scheme[cacheKey] = v; | ||
} | ||
return v; | ||
}; | ||
@@ -150,0 +159,0 @@ const _zodTypeToJsonScheme = (type, depth) => { |
{ | ||
"name": "@iyio/common", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -21,2 +21,2 @@ import { ZodEnum, ZodError, ZodSchema, ZodTypeAny } from "zod"; | ||
} | undefined; | ||
export declare const zodTypeToJsonScheme: (scheme: ZodTypeAny, maxDepth?: number) => JsonScheme | undefined; | ||
export declare const zodTypeToJsonScheme: (scheme: ZodTypeAny, maxDepth?: number, cache?: boolean) => JsonScheme | undefined; |
@@ -153,5 +153,14 @@ "use strict"; | ||
exports.zodCoerceNullDbValuesInObject = zodCoerceNullDbValuesInObject; | ||
const zodTypeToJsonScheme = (scheme, maxDepth = 10) => { | ||
const cacheKey = Symbol('zodHelperCacheKey'); | ||
const zodTypeToJsonScheme = (scheme, maxDepth = 10, cache = true) => { | ||
var _a; | ||
return (_a = _zodTypeToJsonScheme(scheme, maxDepth)) === null || _a === void 0 ? void 0 : _a.jsonType; | ||
const cached = cache ? scheme[cacheKey] : undefined; | ||
if (cached) { | ||
return cached; | ||
} | ||
const v = (_a = _zodTypeToJsonScheme(scheme, maxDepth)) === null || _a === void 0 ? void 0 : _a.jsonType; | ||
if (cache) { | ||
scheme[cacheKey] = v; | ||
} | ||
return v; | ||
}; | ||
@@ -158,0 +167,0 @@ exports.zodTypeToJsonScheme = zodTypeToJsonScheme; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2136319
34753
1