INNER CODE UNIT · JavaScript
baseName
timothystewart6/techno-tim.github.io · tools/lquip/index.js:33
const baseName = file.slice(0, -extension.length);
if (!imageMap.has(baseName)) {
imageMap.set(baseName, new Map());
}
imageMap.get(baseName).set(extension, file);
}
return Array.from(imageMap.entries())
.sort(([left], [right]) => left.localeCompare(right))
.map(([, variants]) => {
const inputPath = preferredInputExtensions
.map((extension) => variants.get(extension))
.find(Boolean);
const outputPath = variants.get('.webp') || inputPath;
return { inputPath, outputPath };