import type { DifficultyPreset } from "./protocol"; // A list fetched before a save must not remove the newly saved preset. export function mergeDifficultyPresets( current: DifficultyPreset[], incoming: DifficultyPreset[], ) { return [ ...new Map( [...current, ...incoming].map((preset) => [preset.id, preset]), ).values(), ].sort((a, b) => a.name.localeCompare(b.name)); }