node-fetch/fetch-blob

Adding a File class maybe?

jimmywarting opened this issue · 0 comments

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'
}