Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a File class maybe? #91

Closed
jimmywarting opened this issue May 8, 2021 · 0 comments · Fixed by #97
Closed

Adding a File class maybe? #91

jimmywarting opened this issue May 8, 2021 · 0 comments · Fixed by #97

Comments

@jimmywarting
Copy link
Contributor

would it be worth to have a file class that extends the blob?

It wouldn't have to be more adv than this:

// file.js
import Blob from './index.js'

export class File extends Blob {
  constructor (blobParts, fileName, options = {}) {
    const { lastModified = Date.now(), ...blobPropertyBag } = options
    super(blobParts, blobPropertyBag)
    this.name = (''+fileName).replace(/\u002F/g, "\u003A")
    this.lastModified = +lastModified
    this.lastModifiedDate = new Date(lastModified)
  }

  [Symbol.toStringTag] = 'File'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant