24 lines
591 B
TypeScript
24 lines
591 B
TypeScript
export type VariantPlanItem = {
|
|
kind: "thumb" | "poster";
|
|
size: number;
|
|
};
|
|
|
|
export function pickSmallestVariantSize(plan: VariantPlanItem[]): number | null {
|
|
if (plan.length === 0) return null;
|
|
return plan.reduce((min, item) => (item.size < min ? item.size : min), plan[0].size);
|
|
}
|
|
|
|
export function computeImageVariantPlan(): VariantPlanItem[] {
|
|
return [
|
|
{ kind: "thumb", size: 256 },
|
|
{ kind: "thumb", size: 768 },
|
|
];
|
|
}
|
|
|
|
export function computeVideoPosterPlan(): VariantPlanItem[] {
|
|
return [
|
|
{ kind: "poster", size: 256 },
|
|
{ kind: "poster", size: 768 },
|
|
];
|
|
}
|