INNER CODE UNIT · TypeScript

readSchema

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

async function readSchema(p: string): Promise<Record<string, unknown>> {
    let text: string;
    try {
        text = await Deno.readTextFile(p);
    } catch (e) {
        throw new IoError(p, e);
    }
    return parseData(p, text) as Record<string, unknown>;
}

// Pick JSON / YAML / TOML parsing based on file extension.  Parser errors
// already carry line/column info — we just re-prefix with the path so the
// caller can identify which file failed.
function parseData(p: string, text: string): unknown {
    if (/\.toml$/i.test(p)) {
        try {
            return parseToml(text);
        } catch (e) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…