MCPcopy Create free account
hub / github.com/Sethispr/image-compressor / traverseFileTree

Function traverseFileTree

components/Dropzone.tsx:66–90  ·  view source on GitHub ↗
(item: any, path?: string)

Source from the content-addressed store, hash-verified

64
65 // eslint-disable-next-line @typescript-eslint/no-explicit-any
66 const traverseFileTree = async (item: any, path?: string) => {
67 if (processedCount >= MAX_FILES) return;
68 path = path || '';
69
70 if (item.isFile) {
71 processedCount++;
72 return new Promise<void>(resolve => {
73 item.file((file: File) => {
74 if (isValidFile(file)) files.push(file);
75 resolve();
76 });
77 });
78 } else if (item.isDirectory) {
79 const dirReader = item.createReader();
80 return new Promise<void>(resolve => {
81 // eslint-disable-next-line @typescript-eslint/no-explicit-any
82 dirReader.readEntries(async (entries: any[]) => {
83 for (const entry of entries) {
84 await traverseFileTree(entry, path + item.name + '/');
85 }
86 resolve();
87 });
88 });
89 }
90 };
91
92 const items = e.dataTransfer.items;
93 const promises = [];

Callers 1

handleWindowDropFunction · 0.85

Calls 1

isValidFileFunction · 0.85

Tested by

no test coverage detected