bun
bun copied to clipboard
`Bun.file` should extend `File` not `Blob`
Hope some of this can also be addressed.
- https://github.com/oven-sh/bun/issues/4460#issuecomment-1725323631
Is this as simple as just updating the type to extend a File and making sure the name property of the BunFile is non-nullable? I'm new so I'm unsure of the cascading effects., but it seems that File and Blob are basically the same except for that difference.
Neither BunFile
or Blob
should have a name
or lastModified
property, they should live on the File
class itself.
I think it should look more like this:
class Blob {
size = 0
type = ""
slice() { ... }
text() { ... }
arrayBuffer() { ... }
stream() { ... }
[Symbol.toStringTag] = "Blob"
}
class File extends Blob {
name = ""
lastModified = 0
[Symbol.toStringTag] = "File"
}
class BunFile extends File {
constructor() {
this.file = super(...)
}
json() { ... }
exist() { ... }
writer() { ... }
formData() { ... }
slice() { ... } // in case Bun wants to override Blob.slice to return a BunFile instead.
}
bump
What is this breaking?