INNER CODE UNIT · TypeScript
detectFormat
x-cmd/x-cmd · mod/ajv/lib/ajv.ts:282
function detectFormat(file: string): "json" | "yml" | "toml" | null {
if (/\.ya?ml$/i.test(file)) return "yml";
if (/\.toml$/i.test(file)) return "toml";
if (/\.json$/i.test(file)) return "json";
return null;
}
function bumpStats(result: string, format: string | null): void {
STATS.total++;
STATS.result[collapseResult(result)]++;
if (format !== null) STATS.format[format]++;
}
function emitSummary(): void {
if (STATS.total === 0) return;
const lines: string[] = [
"---",
`total: ${STATS.total}`,