t2-mapper/src/imageFileList.ts

18 lines
518 B
TypeScript
Raw Normal View History

export function parseImageFileList(source: string) {
2025-11-16 15:59:30 -08:00
const lines = source
.split(/(?:\r\n|\r|\n)/g)
.map((line) => line.trim())
.filter(Boolean)
.filter((line) => !line.startsWith(";")); // discard comments
2025-11-16 15:59:30 -08:00
return lines.map((line) => {
const fileWithCount = line.match(/^(.+)\s(\d+)$/);
if (fileWithCount) {
const frameCount = parseInt(fileWithCount[2], 10);
return { name: fileWithCount[1], frameCount };
} else {
return { name: line, frameCount: 1 };
}
});
}