function preferredLanguages(accept, provided) {
  // RFC 2616 sec 14.4: no header = *
  var accepts = parseAcceptLanguage(accept === undefined ? '*' : accept || '');

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

  var 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)];
  });
}
function preferredLanguages(accept, provided) {
  // RFC 2616 sec 14.4: no header = *
  var accepts = parseAcceptLanguage(accept === undefined ? '*' : accept || '');

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

  var 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)];
  });
}
function preferredLanguages ( accept , provided ) { // RFC 2616 sec 14.4: no header = * var accepts = parseAcceptLanguage ( accept === undefined ? '*' : accept || '' ) ; if ( ! provided ) { // sorted list of all languages return accepts . filter ( isQuality ) . sort ( compareSpecs ) . map ( getFullLanguage ) ; } var 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.
@public
Get the preferred languages from an Accept - Language header .