core/validators/chapter.validator.ts

core/validators/chapter.validator.ts is a file in Bane's Lab Content. 13 lines of code and 4 definitions.

import type { Attribution, Chapter, ShapeInput, ShapeRenderer } from "#types/chapter.types";

const differs = function differs(first: Chapter, second: Chapter | undefined): boolean {
    return first.body !== second?.body || first.file !== second.file;
};

export const unstableChapters = function unstableChapters(
    render: ShapeRenderer,
    input: ShapeInput,
    attribution: Attribution,
): string[] {
    const first = render(input, attribution);
    const second = render(input, attribution);
    return first.filter((chapter, index) => differs(chapter, second[index])).map((chapter) => chapter.file);
};