function preferredEncodings(accept, provided) {
  const accepts = parseAcceptEncoding(accept || "");
  if (!provided) {
    // sorted list of all encodings
    return accepts.filter(isQuality).sort(compareSpecs).map(getFullEncoding);
  }
  const priorities = provided.map(function getPriority(type, index) {
    return getEncodingPriority(type, accepts, index);
  });
  // sorted list of accepted encodings
  return priorities.filter(isQuality).sort(compareSpecs).map(
    function getEncoding(priority) {
      return provided[priorities.indexOf(priority)];
    },
  );
}
/**
 * Get the preferred encodings from an Accept-Encoding header.
 */
Get the preferred encodings from an Accept-Encoding header.
Get the preferred encodings from an Accept - Encoding header .
function preferredEncodings(accept, provided) {
  const accepts = parseAcceptEncoding(accept || "");
  if (!provided) {
    return accepts.filter(isQuality).sort(compareSpecs).map(getFullEncoding);
  }
  const priorities = provided.map(function getPriority(type, index) {
    return getEncodingPriority(type, accepts, index);
  });
  return priorities.filter(isQuality).sort(compareSpecs).map(
    function getEncoding(priority) {
      return provided[priorities.indexOf(priority)];
    },
  );
}
function preferredEncodings ( accept , provided ) { const accepts = parseAcceptEncoding ( accept || "" ) ; if ( ! provided ) { return accepts . filter ( isQuality ) . sort ( compareSpecs ) . map ( getFullEncoding ) ; } const priorities = provided . map ( function getPriority ( type , index ) { return getEncodingPriority ( type , accepts , index ) ; } ) ; return priorities . filter ( isQuality ) . sort ( compareSpecs ) . map ( function getEncoding ( priority ) { return provided [ priorities . indexOf ( priority ) ] ; } , ) ; }
Get the preferred encodings from an Accept-Encoding header.
Get the preferred encodings from an Accept - Encoding header .
// sorted list of all encodings // sorted list of accepted encodings