Content-Type, Accept, and media/MIME-type parsing
The MediaType represents a parsed Media Type. For use in HTTP, the first (but only the first)
q parameter will be parsed as a float.
Other parameters are available through the
The first argument is the full media type, the second argument, if provided, is strictly a list of parameters.
toString method converts the object back into a Media type.
var p = 'text/html;level=1;q=0.5';pq === 05;pparamslevel === "1"var q = 'application/json' profile: '';qtype === "application/json";qparamsprofile === "";qq = 1;q === 'application/json;q=1;profile=""';
Returns a new instance of MediaType.
Splits a string by a delimiter character (default: semicolon), ignoring quoted sections (default: double quote).
Splits an Accept (or similar) header into an Array of strings of content-types.
Pick an ideal representation to send, given an Array of representations to choose from, and the client-preferred list as an Array.
See example.js for an example.
Accepts two MediaType instances and tests them for being a subset/superset.
If a is a superset of b (b is smaller than a), return 1. If b is a superset of a, return -1. If they are the exact same, return 0. If they are disjoint, return null.
The q-value, if any, is ignored.
=== 0=== 1=== -1=== null