feat: add converter registry

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-30 09:06:12 +02:00
co-authored by Claude Sonnet 5
parent 4b7ad9ef4e
commit aeebc47379
2 changed files with 56 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
let entries = new Map();
function key(sourceFormat, targetFormat) {
return `${sourceFormat}->${targetFormat}`;
}
export function register({ family, sourceFormat, targetFormat, convert }) {
entries.set(key(sourceFormat, targetFormat), { family, convert });
}
export function resolve(sourceFormat, targetFormat) {
return entries.get(key(sourceFormat, targetFormat)) ?? null;
}
export function listTargetFormats(sourceFormat) {
const prefix = `${sourceFormat}->`;
return [...entries.keys()]
.filter((k) => k.startsWith(prefix))
.map((k) => k.slice(prefix.length));
}
export function _resetForTests() {
entries = new Map();
}