22 lines
711 B
TypeScript
22 lines
711 B
TypeScript
/**
|
|
* N-11. A non-finite or fractional capacity silently disables eviction, so it is
|
|
* a construction-time configuration error rather than a runtime drop.
|
|
*
|
|
* This lives in the adapter kernel rather than inside the telemetry adapter:
|
|
* the diagnostics adapter needs the same guard, and importing it from telemetry
|
|
* made one concrete adapter depend on another for a rule that belongs to
|
|
* neither of them.
|
|
*/
|
|
export function assertBoundedCapacity(
|
|
value: number,
|
|
ceiling: number,
|
|
label: string,
|
|
): number {
|
|
if (!Number.isSafeInteger(value) || value < 1 || value > ceiling) {
|
|
throw new TypeError(
|
|
`${label} must be a safe integer between 1 and ${ceiling}`,
|
|
);
|
|
}
|
|
return value;
|
|
}
|