UNPKG

@yoroi/common

Version:
18 lines (17 loc) 580 B
"use strict"; import z from 'zod'; export const cacheRecordSchemaMaker = recordSchema => { return z.object({ record: recordSchema, expires: z.number().nonnegative(), hash: z.string() // Zod is not infering the type correctly when using interface }); }; export const isCacheRecord = (recordSchema, data) => { return cacheRecordSchemaMaker(recordSchema).safeParse(data).success; }; export const parseCacheRecord = (recordSchema, data) => { return isCacheRecord(recordSchema, data) ? data : undefined; }; //# sourceMappingURL=cache-record-schema-maker.js.map