All files / kernel-test-local/src utils.ts

100% Statements 9/9
100% Branches 4/4
100% Functions 6/6
100% Lines 7/7

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 20 21 22 23 24 25 26 27 28 29 30 31                    3x     2x 1x   2x 1x   1x                 1x    
import type { LogEntry } from '@metamask/logger';
 
import { IGNORE_TAGS } from './constants.ts';
 
/**
 * Filter a logger transport to ignore command line specified ignore tags.
 *
 * @param transports - The transports to filter.
 * @returns A transport that filters out the ignore tags.
 */
export const filterTransports = (
  ...transports: ((entry: LogEntry) => void)[]
): ((entry: LogEntry) => void) =>
  IGNORE_TAGS.includes('all')
    ? () => undefined
    : (entry) => {
        if (IGNORE_TAGS.some((tag) => entry.tags.includes(tag))) {
          return;
        }
        transports.forEach((transport) => transport(entry));
      };
 
/**
 * Generate a random letter.
 *
 * @returns a random letter.
 */
export function randomLetter(): string {
  return String.fromCharCode(Math.floor(Math.random() * 26) + 97);
}