MCPcopy Create free account
hub / github.com/ScattrdBlade/bigFileUpload / extractFilesFromValue

Function extractFilesFromValue

index.tsx:61–79  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

59 }
60}
61function extractFilesFromValue(value: unknown): File[] {
62 if (value instanceof File) return [value];
63
64 if (!Array.isArray(value)) return [];
65
66 return value.flatMap(entry => {
67 if (entry instanceof File) return [entry];
68
69 if (!entry || typeof entry !== "object") return [];
70
71 const uploadFile = "file" in entry ? entry.file : null;
72 if (uploadFile instanceof File) return [uploadFile];
73
74 const item = "item" in entry && entry.item && typeof entry.item === "object" ? entry.item : null;
75 if (!item || !("file" in item)) return [];
76
77 return item.file instanceof File ? [item.file] : [];
78 });
79}
80
81function interceptUploadAddFiles(event: unknown): void {
82 if (!event || typeof event !== "object" || !("type" in event)) return;

Callers 1

interceptUploadAddFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected