UNPKG

@jsenv/core

Version:

Tool to develop, test and build js projects

21 lines (18 loc) 487 B
const parseSrcSet = (srcset) => { const srcCandidates = []; srcset.split(",").forEach((set) => { const [specifier, descriptor] = set.trim().split(" "); srcCandidates.push({ specifier, descriptor, }); }); return srcCandidates; }; const stringifySrcSet = (srcCandidates) => { const srcset = srcCandidates .map(({ specifier, descriptor }) => `${specifier} ${descriptor}`) .join(", "); return srcset; }; export { parseSrcSet, stringifySrcSet };