Skip to content

Adding a File class maybe? #91

Closed
@jimmywarting

Description

@jimmywarting

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions