lovell/media-type

Export MediaType constructor and parse when string given to it

Opened this issue · 1 comments

moll commented

Hey,

To make MediaType behave more like a proper value type, it'd be beneficial to first export the actual constructor for instanceof checks and to then parse when a string is given to it.

new MediaType("application/vnd.foo+json; v=1") for example to match how the built-in Date behaves.

You could always add MediaType.parse and MediaType.stringify as well to match the JSON API.

Thanks - this should probably be tackled at the same time as #3.