INNER CODE UNIT · TypeScript

collapseResult

x-cmd/x-cmd · mod/ajv/lib/ajv.ts:274

function collapseResult(result: string): "success" | "syntax-error" | "schema-error" {
    if (result === R.Valid || result === R.Compiled || result === R.Pass || result === R.Migrated) {
        return "success";
    }
    if (result === R.SyntaxError) return "syntax-error";
    return "schema-error";
}

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)]++;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…