All files / src/tools/manifest message-keys.ts

100% Statements 4/4
100% Branches 4/4
100% Functions 3/3
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19                            645x   5448x    
/**
 * Reading the message keys a face's appinfo declares.
 *
 * The manifest checks, the provider list, and the permissions all ask whether a face declares a key,
 * so they read the names the same way here.
 */
 
/**
 * The key names a face declares, with any [n] array suffix taken off.
 *
 * @param messageKeys The face's message keys, as its appinfo declares them, a list or a map.
 * @return The names, each once.
 */
export function keyNames(messageKeys: unknown): Set<string> {
  const names = Array.isArray(messageKeys) ? messageKeys : Object.keys(messageKeys ?? {});
 
  return new Set(names.filter((name) => typeof name === 'string').map((name) => name.split('[')[0]));
}