INNER CODE UNIT · JavaScript

collectImages

timothystewart6/techno-tim.github.io · tools/lquip/index.js:8

async function collectImages(dirPath) {
  const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
  const files = [];

  for (const entry of entries) {
    const fullPath = path.join(dirPath, entry.name);

    if (entry.isDirectory()) {
      files.push(...await collectImages(fullPath));
      continue;
    }

    if (supportedExtensions.has(path.extname(entry.name).toLowerCase())) {
      files.push(fullPath);
    }
  }

  return files.sort();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…