async function filterTokens(dictionary, filter, options = {}) {
  if (!filter) {
    return dictionary;
  } else {
    if (typeof filter !== 'function') {
      throw new Error('filter is not a function');
    } else {
      const allTokens = await asyncFilter(dictionary.allTokens ?? [], filter, options);
      const tokens = await filterTokenObject(dictionary.tokens, filter, options);
      const tokenMap = /** @type {Map<string,Token>} */ (
        convertTokenData(allTokens, { output: 'map' })
      );

      return {
        allTokens,
        tokens,
        tokenMap,
      };
    }
  }
}
Takes a dictionary and filters the `allTokens` array and the `tokens`
object using a function provided by the user.

@param {Dictionary} dictionary
@param {Filter['filter']} [filter] - A function that receives a token object
  and returns `true` if the token should be included in the output
  or `false` if the token should be excluded from the output
@param {Config} [options]
@returns {Promise<Dictionary>} dictionary - A new dictionary containing only the
  tokens that matched the filter (or the original dictionary if no filter
  function was provided).