示例工程 27-framework-comparison
27-framework-comparison/app/.tsc/src/lib/decision.js
export const DEFAULT_WEIGHTS = {
bundle: 3,
ecosystem: 4,
team: 3,
migration: 3,
};
export const PRESET_WEIGHTS = {
balanced: DEFAULT_WEIGHTS,
team: { bundle: 1, ecosystem: 1, team: 5, migration: 1 },
bundle: { bundle: 5, ecosystem: 1, team: 1, migration: 1 },
};
export const FRAMEWORKS = [
{
id: "react",
label: "React 19",
scores: { bundle: 2, ecosystem: 5, team: 5, migration: 3 },
},
{
id: "vue",
label: "Vue 3",
scores: { bundle: 4, ecosystem: 5, team: 4, migration: 4 },
},
{
id: "svelte",
label: "Svelte 5",
scores: { bundle: 5, ecosystem: 4, team: 3, migration: 2 },
},
];
export function score(framework, weights) {
return (framework.scores.bundle * weights.bundle +
framework.scores.ecosystem * weights.ecosystem +
framework.scores.team * weights.team +
framework.scores.migration * weights.migration);
}
export function rankFrameworks(weights) {
return FRAMEWORKS.map((framework) => ({
id: framework.id,
label: framework.label,
total: score(framework, weights),
})).sort((a, b) => b.total - a.total);
}
export function winner(weights) {
return (rankFrameworks(weights)[0] ?? {
id: "react",
label: "React 19",
total: 0,
});
}
//# sourceMappingURL=decision.js.map