All files / src/lib style-text.js

80% Statements 12/15
50% Branches 2/4
100% Functions 1/1
80% Lines 12/15

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 16193x 193x 193x 193x 193x 193x 193x 542x 542x 542x 542x       542x  
import { styleText as nativeStyleText } from 'node:util';
 
/**
 * @param {Parameters<typeof nativeStyleText>[0]} format
 * @param {any} value
 */
export function styleText(format, value) {
  if (typeof value === 'string') {
    return nativeStyleText(format, value);
  }
  if (typeof value === 'number' || typeof value === 'boolean') {
    return nativeStyleText(format, String(value));
  }
  return '';
}