mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-08 17:51:20 +02:00
additional clean up
This commit is contained in:
parent
c7a1e33641
commit
662d0692df
@ -102,26 +102,13 @@ export function createStirlingFile(file: File, id?: FileId): StirlingFile {
|
|||||||
const fileId = id || createFileId();
|
const fileId = id || createFileId();
|
||||||
const quickKey = createQuickKey(file);
|
const quickKey = createQuickKey(file);
|
||||||
|
|
||||||
// File properties are not enumerable, so we need to copy them explicitly
|
// Create a new object that inherits from the File instance
|
||||||
// This avoids prototype chain issues while preserving all File functionality
|
// This preserves all File methods and properties while avoiding binding issues
|
||||||
const stirlingFile = {
|
const stirlingFile = Object.assign(
|
||||||
// Explicitly copy File properties (they're not enumerable)
|
Object.create(Object.getPrototypeOf(file)), // Proper prototype chain
|
||||||
name: file.name,
|
file, // Copy all properties (enumerable and non-enumerable)
|
||||||
size: file.size,
|
{ fileId, quickKey } // Add our custom properties
|
||||||
type: file.type,
|
) as StirlingFile;
|
||||||
lastModified: file.lastModified,
|
|
||||||
webkitRelativePath: file.webkitRelativePath,
|
|
||||||
|
|
||||||
// Add our custom properties
|
|
||||||
fileId: fileId,
|
|
||||||
quickKey: quickKey,
|
|
||||||
|
|
||||||
// Preserve File prototype methods by binding them to the original file
|
|
||||||
arrayBuffer: file.arrayBuffer.bind(file),
|
|
||||||
slice: file.slice.bind(file),
|
|
||||||
stream: file.stream.bind(file),
|
|
||||||
text: file.text.bind(file)
|
|
||||||
} as StirlingFile;
|
|
||||||
|
|
||||||
return stirlingFile;
|
return stirlingFile;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user