function preferredLanguages(accept, provided) {
  // RFC 2616 sec 14.4: no header = *
  const accepts = parseAcceptLanguage(accept === null ? "*" : accept || "");
  if (!provided) {
    // sorted list of all languages
    return accepts.filter(isQuality).sort(compareSpecs).map(getFullLanguage);
  }
  const priorities = provided.map(function getPriority(type, index) {
    return getLanguagePriority(type, accepts, index);
  });
  // sorted list of accepted languages
  return priorities.filter(isQuality).sort(compareSpecs).map(
    function getLanguage(priority) {
      return provided[priorities.indexOf(priority)];
    },
  );
}
/**
 * Get the preferred languages from an Accept-Language header.
 */
Get the preferred languages from an Accept-Language header.
Get the preferred languages from an Accept - Language header .
function preferredLanguages(accept, provided) {
  const accepts = parseAcceptLanguage(accept === null ? "*" : accept || "");
  if (!provided) {
    return accepts.filter(isQuality).sort(compareSpecs).map(getFullLanguage);
  }
  const priorities = provided.map(function getPriority(type, index) {
    return getLanguagePriority(type, accepts, index);
  });
  return priorities.filter(isQuality).sort(compareSpecs).map(
    function getLanguage(priority) {
      return provided[priorities.indexOf(priority)];
    },
  );
}
function preferredLanguages ( accept , provided ) { const accepts = parseAcceptLanguage ( accept === null ? "*" : accept || "" ) ; if ( ! provided ) { return accepts . filter ( isQuality ) . sort ( compareSpecs ) . map ( getFullLanguage ) ; } const priorities = provided . map ( function getPriority ( type , index ) { return getLanguagePriority ( type , accepts , index ) ; } ) ; return priorities . filter ( isQuality ) . sort ( compareSpecs ) . map ( function getLanguage ( priority ) { return provided [ priorities . indexOf ( priority ) ] ; } , ) ; }
Get the preferred languages from an Accept-Language header.
Get the preferred languages from an Accept - Language header .
// RFC 2616 sec 14.4: no header = * // sorted list of all languages // sorted list of accepted languages