function preferredMediaTypes(accept, provided) {
  // RFC 2616 sec 14.2: no header = */*
  var accepts = parseAccept(accept === undefined ? '*/*' : accept || '');

  if (!provided) {
    // sorted list of all types
    return accepts
      .filter(isQuality)
      .sort(compareSpecs)
      .map(getFullType);
  }

  var priorities = provided.map(function getPriority(type, index) {
    return getMediaTypePriority(type, accepts, index);
  });

  // sorted list of accepted types
  return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) {
    return provided[priorities.indexOf(priority)];
  });
}
function preferredMediaTypes(accept, provided) {
  // RFC 2616 sec 14.2: no header = */*
  var accepts = parseAccept(accept === undefined ? '*/*' : accept || '');

  if (!provided) {
    // sorted list of all types
    return accepts
      .filter(isQuality)
      .sort(compareSpecs)
      .map(getFullType);
  }

  var priorities = provided.map(function getPriority(type, index) {
    return getMediaTypePriority(type, accepts, index);
  });

  // sorted list of accepted types
  return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) {
    return provided[priorities.indexOf(priority)];
  });
}
function preferredMediaTypes ( accept , provided ) { // RFC 2616 sec 14.2: no header = */* var accepts = parseAccept ( accept === undefined ? '*/*' : accept || '' ) ; if ( ! provided ) { // sorted list of all types return accepts . filter ( isQuality ) . sort ( compareSpecs ) . map ( getFullType ) ; } var priorities = provided . map ( function getPriority ( type , index ) { return getMediaTypePriority ( type , accepts , index ) ; } ) ; // sorted list of accepted types return priorities . filter ( isQuality ) . sort ( compareSpecs ) . map ( function getType ( priority ) { return provided [ priorities . indexOf ( priority ) ] ; } ) ; }
Get the preferred media types from an Accept header.
@public
Get the preferred media types from an Accept header .