function format(obj) {
  const parameters = obj.parameters;
  const type = obj.type;
  if (!type || !TYPE_REGEXP.test(type)) {
    throw new TypeError("invalid type");
  }
  let string = type;
  // append parameters
  if (parameters && typeof parameters === "object") {
    let param;
    const params = Object.keys(parameters).sort();
    for (let i = 0; i < params.length; i++) {
      param = params[i];
      if (!TOKEN_REGEXP.test(param)) {
        throw new TypeError("invalid parameter name");
      }
      string += "; " + param + "=" + qstring(parameters[param]);
    }
  }
  return string;
}
/**
 * Format ContentType object to media type.
 */
Format ContentType object to media type.
Format ContentType object to media type .
function format(obj) {
  const parameters = obj.parameters;
  const type = obj.type;
  if (!type || !TYPE_REGEXP.test(type)) {
    throw new TypeError("invalid type");
  }
  let string = type;
  if (parameters && typeof parameters === "object") {
    let param;
    const params = Object.keys(parameters).sort();
    for (let i = 0; i < params.length; i++) {
      param = params[i];
      if (!TOKEN_REGEXP.test(param)) {
        throw new TypeError("invalid parameter name");
      }
      string += "; " + param + "=" + qstring(parameters[param]);
    }
  }
  return string;
}
function format ( obj ) { const parameters = obj . parameters ; const type = obj . type ; if ( ! type || ! TYPE_REGEXP . test ( type ) ) { throw new TypeError ( "invalid type" ) ; } let string = type ; if ( parameters && typeof parameters === "object" ) { let param ; const params = Object . keys ( parameters ) . sort ( ) ; for ( let i = 0 ; i < params . length ; i ++ ) { param = params [ i ] ; if ( ! TOKEN_REGEXP . test ( param ) ) { throw new TypeError ( "invalid parameter name" ) ; } string += "; " + param + "=" + qstring ( parameters [ param ] ) ; } } return string ; }
Format ContentType object to media type.
Format ContentType object to media type .
// append parameters