Docs: Update benchmark results

This commit is contained in:
github-actions[bot]
2025-11-07 21:32:49 +00:00
parent f9da7d4ed7
commit d0bc3b95dd
54 changed files with 1115 additions and 372 deletions
@@ -0,0 +1,32 @@
let ajvPromise;
const compiledSchemas = new WeakMap();
const validateJSON = async (json, schema) => {
try {
ajvPromise ||= import('https://esm.sh/ajv@8').then(
({ default: Ajv }) => new Ajv({ allErrors: true })
);
const ajv = await ajvPromise;
let validate = compiledSchemas.get(schema);
if (!validate) {
validate = ajv.compile(schema);
compiledSchemas.set(schema, validate);
}
const valid = validate(json);
const errors = valid
? []
: (validate.errors ?? []).map(({ instancePath, message }) =>
`${instancePath.substring(1) || 'root'}: ${message}`
);
return { valid, errors };
} catch (error) {
return {
valid: false,
errors: [error.message || 'An unknown validation error occurred.'],
};
}
};
export default validateJSON;