Files
MineGeo/shared/difficulty-presets.ts
pavel444-byte 0bd05d6e0b
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 6m4s
Validate and deduplicate custom difficulty presets
2026-10-16 13:29:32 +05:00

14 lines
397 B
TypeScript

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));
}