function filterLanguages(languages, only, ignore) {
  if (only.length === 0 && ignore.length === 0) {
    return languages
  }

  /** @type {Record<string, Record<string, number>>} */
  const filteredLanguages = {}
  /** @type {string} */
  let language

  for (language in languages) {
    if (allow(language, only, ignore)) {
      filteredLanguages[language] = languages[language]
    }
  }

  return filteredLanguages
}
Filter `languages` by removing languages in
`ignore`, or including languages in `only`.

@param {Record<string, Record<string, number>>} languages
  Languages to filter
@param {Array<string>} only
  Allowed languages; if non-empty, only included languages are kept.
@param {Array<string>} ignore
  Disallowed languages; included languages are ignored.
@return {Record<string, Record<string, number>>}
  Filtered array of languages.