Files
rea/src/domain/analysisView/analysisViewCoverage.ts
T

29 lines
761 B
TypeScript

import type { AnalysisViewCoverage } from "./analysisView.js";
/** Coverage for a summary, facet, or single selected object. */
export const completeWithinViewCoverage = (
examined: number,
total: number,
): AnalysisViewCoverage => ({
status: "complete-within-view",
examined,
total,
next_offset: null,
exhausted: true,
});
/** Coverage for a stable page, including an offset past the collection. */
export const pageViewCoverage = (
offset: number,
examined: number,
total: number,
): AnalysisViewCoverage => {
const exhausted = offset >= total || offset + examined >= total;
return {
status: examined === 0 ? "empty" : "page",
examined,
total,
next_offset: exhausted ? null : offset + examined,
exhausted,
};
};