UNPKG

taglib-wasm

Version:

TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps

70 lines (69 loc) 1.7 kB
function chapterStyle(chapters) { const s = chapters[0]?.source; return s === "nero" || s === "both" ? s : "quicktime"; } const EXTRA_FIELDS = [ { name: "pictures", copy(target, source, complete) { const v = source.getPictures(); if (complete || v.length > 0) target.setPictures(v); } }, { name: "ratings", copy(target, source, complete) { const v = source.getRatings(); if (complete || v.length > 0) target.setRatings(v); } }, { name: "lyrics", copy(target, source, complete) { const v = source.getLyrics(); if (complete || v.length > 0) target.setLyrics(v); } }, { name: "chapters", copy(target, source, complete) { const v = source.getChapters(); if (complete || v.length > 0) target.setChapters(v, chapterStyle(v)); } }, { name: "bextData", copy(target, source, complete) { const v = source.getBextData(); if (v !== void 0) target.setBextData(v); else if (complete) target.setBextData(null); } }, { name: "ixml", copy(target, source, complete) { const v = source.getIxml(); if (v !== void 0) target.setIxml(v); else if (complete) target.setIxml(null); } }, { name: "id3v2Frames", copy(target, source) { const staged = source.getStagedId3v2Frames?.(); if (!staged) return; for (const [id, bodies] of Object.entries(staged)) { target.setId3v2Frames(id, bodies); } } } ]; function copyExtraState(target, source, sourceComplete) { for (const field of EXTRA_FIELDS) { field.copy(target, source, sourceComplete); } } export { EXTRA_FIELDS, copyExtraState };