src/index.js
/**
 * Extended Filter as described in RFC4647 3.3.2 produces a (potentially empty) set of prioritised language tags
 *
 * @param {String} range A range string to languagePriorityList
 * @param {Array} languageTags A list of bcp47 locales that are supported
 * @return {Array<String>} returns tags from supportedLanguagesTags that match or all tags if wildcard '*' is given
 */
Extended Filter as described in RFC4647 3.3.2 produces a (potentially empty) set of prioritised language tags
@param {String} range A range string to languagePriorityList
@param {Array} languageTags A list of bcp47 locales that are supported
@return {Array} returns tags from supportedLanguagesTags that match or all tags if wildcard '*' is given
Extended Filter as described in RFC4647 3 . 3 . 2 produces a ( potentially empty ) set of prioritised language tags @param { String } range A range string to languagePriorityList @param { Array } languageTags A list of bcp47 locales that are supported @return { Array } returns tags from supportedLanguagesTags that match or all tags if wildcard ' * ' is given
function extendedFilter(range, languageTags) {
  if (!Array.isArray(languageTags) || languageTags.length === 0) return [];
  function extendedTagMatch(rangeSubTags, languageSubTags, rIndex, lIndex) {
    if (!rangeSubTags[rIndex]) return true;
    if (!languageSubTags[lIndex] || languageSubTags[lIndex].length === 1) return false;
    if (isWild(rangeSubTags[rIndex])) ++rIndex;
    if (tagEquality(rangeSubTags[rIndex], languageSubTags[lIndex])) ++rIndex;
    return extendedTagMatch(rangeSubTags, languageSubTags, rIndex, ++lIndex);
  }
  function languagesTagsComparator(rangeSubTags, index, array) {
    if (!languageTags[index]) return array;
    if (extendedTagMatch(rangeSubTags, languageTags[index].split('-'), 0, 0)) array.push(languageTags[index]);
    return languagesTagsComparator(rangeSubTags, ++index, array);
  }
  return filterTags(languagePriorityList(range), 0, [], languagesTagsComparator, true);
}
function extendedFilter ( range , languageTags ) { if ( ! Array . isArray ( languageTags ) || languageTags . length === 0 ) return [ ] ; function extendedTagMatch ( rangeSubTags , languageSubTags , rIndex , lIndex ) { if ( ! rangeSubTags [ rIndex ] ) return true ; if ( ! languageSubTags [ lIndex ] || languageSubTags [ lIndex ] . length === 1 ) return false ; if ( isWild ( rangeSubTags [ rIndex ] ) ) ++ rIndex ; if ( tagEquality ( rangeSubTags [ rIndex ] , languageSubTags [ lIndex ] ) ) ++ rIndex ; return extendedTagMatch ( rangeSubTags , languageSubTags , rIndex , ++ lIndex ) ; } function languagesTagsComparator ( rangeSubTags , index , array ) { if ( ! languageTags [ index ] ) return array ; if ( extendedTagMatch ( rangeSubTags , languageTags [ index ] . split ( '-' ) , 0 , 0 ) ) array . push ( languageTags [ index ] ) ; return languagesTagsComparator ( rangeSubTags , ++ index , array ) ; } return filterTags ( languagePriorityList ( range ) , 0 , [ ] , languagesTagsComparator , true ) ; }
Extended Filter as described in RFC4647 3.3.2 produces a (potentially empty) set of prioritised language tags
 @param {String} range A range string to languagePriorityList
 @param {Array} languageTags A list of bcp47 locales that are supported
 @return {Array<String>} returns tags from supportedLanguagesTags that match or all tags if wildcard '*' is given
Extended Filter as described in RFC4647 3 . 3 . 2 produces a ( potentially empty ) set of prioritised language tags @param { String } range A range string to languagePriorityList @param { Array } languageTags A list of bcp47 locales that are supported @return { Array<String > } returns tags from supportedLanguagesTags that match or all tags if wildcard ' * ' is given