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

[v2 Feedback request] Mime class API #163

Closed
broofa opened this issue Jun 17, 2017 · 1 comment
Closed

[v2 Feedback request] Mime class API #163

broofa opened this issue Jun 17, 2017 · 1 comment
Labels

Comments

@broofa
Copy link
Owner

broofa commented Jun 17, 2017

With v2, I wanted to revisit the mime API which, frankly, has never felt great to me. So to that end I'm looking for feedback on https://github.com/broofa/node-mime/blob/v2/Mime.js

Notable differences:

  • mime.lookup -> mime.getType
  • mime.extension -> mime.getExtension
  • mime.charset.lookup -> deleted (this has never added all that much value)
  • mime.define -> similar, but now throws if there's an extension conflict. Takes a force param to suppress the error and override.
  • mime.load -> deleted (Relic of when node-mime straight from apache's mime.types file, introduced dependencies on path and fs that have been problematic as this module has moved into new spaces (Electron, react-native, etc)

Also of interest ...

  • require('mime/Mime') gets you the Mime class for creating new instances
  • new Mime(require('mime/types/standard')) will get you a light version of the module with only "standard" types (i.e. types not on a .vnd, .x, or .prs facet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant