src/index.js
/**
 * Basic Filter as described in RFC4647 3.3.1 produces a (potentially empty) set of prioritised language tags
 *
 * RFC4647 3.3.1  Basic Filtering
 *
 * @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
 */
Basic Filter as described in RFC4647 3.3.1 produces a (potentially empty) set of prioritised language tags
RFC4647 3.3.1  Basic Filtering

@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
Basic Filter as described in RFC4647 3 . 3 . 1 produces a ( potentially empty ) set of prioritised language tags RFC4647 3 . 3 . 1 Basic Filtering @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 basicFilter(range, languageTags) {
  if (!Array.isArray(languageTags)) return [];
  const list = languagePriorityList(range);
  if (list.length > 0 && isWildTag(list[0])) return languageTags; 
  function languagesTagsComparator(tag, index, array) {
    if (!languageTags[index]) return array;
    if (tagEquality(tag, languageTags[index]) || prefixInTag(tag, languageTags[index])) {
      if (array.indexOf(languageTags[index]) === -1) array.push(languageTags[index]);
    }
    return languagesTagsComparator(tag, ++index, array);
  }
  return filterTags(list, 0, [], languagesTagsComparator, false);
}
function basicFilter ( range , languageTags ) { if ( ! Array . isArray ( languageTags ) ) return [ ] ; const list = languagePriorityList ( range ) ; if ( list . length > 0 && isWildTag ( list [ 0 ] ) ) return languageTags ; function languagesTagsComparator ( tag , index , array ) { if ( ! languageTags [ index ] ) return array ; if ( tagEquality ( tag , languageTags [ index ] ) || prefixInTag ( tag , languageTags [ index ] ) ) { if ( array . indexOf ( languageTags [ index ] ) === - 1 ) array . push ( languageTags [ index ] ) ; } return languagesTagsComparator ( tag , ++ index , array ) ; } return filterTags ( list , 0 , [ ] , languagesTagsComparator , false ) ; }
Basic Filter as described in RFC4647 3.3.1 produces a (potentially empty) set of prioritised language tags
 RFC4647 3.3.1  Basic Filtering
Basic Filter as described in RFC4647 3 . 3 . 1 produces a ( potentially empty ) set of prioritised language tags RFC4647 3 . 3 . 1 Basic Filtering
// RFC4647 wildcard matches all