MCPcopy Index your code
hub / github.com/tensorflow/tfjs-examples / findImagesFromDirectoriesRecursive

Function findImagesFromDirectoriesRecursive

electron/image_utils.js:66–90  ·  view source on GitHub ↗
(dirPath)

Source from the content-addressed store, hash-verified

64 * under the directory.
65 */
66export function findImagesFromDirectoriesRecursive(dirPath) {
67 const imageFilePaths = [];
68 const items = fs.readdirSync(dirPath);
69 for (const item of items) {
70 const fullPath = path.join(dirPath, item);
71 if (fs.lstatSync(fullPath).isDirectory()) {
72 // NOTE: This doesn't follow symlinks.
73 try {
74 imageFilePaths.push(...findImagesFromDirectoriesRecursive(fullPath));
75 } catch (err) {}
76 } else {
77 let extMatch = false;
78 for (const extName of IMAGE_EXTENSION_NAMES) {
79 if (item.toLowerCase().endsWith(extName)) {
80 extMatch = true;
81 break;
82 }
83 }
84 if (extMatch) {
85 imageFilePaths.push(fullPath);
86 }
87 }
88 }
89 return imageFilePaths;
90}

Callers 1

main.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected