• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

variablesoftware / logface / 15371407231

01 Jun 2025 05:16AM UTC coverage: 91.974% (+0.5%) from 91.47%
15371407231

push

github

px
✨ fix: (config): add new logface configuration with emoji sets and randomization

256 of 293 branches covered (87.37%)

Branch coverage included in aggregate %.

443 of 467 relevant lines covered (94.86%)

33.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.5
/src/utils/formatWithReplacements.ts
1
/**
2
 * Format a string with printf-style replacements (e.g., %s, %d, %f, %o, %O).
3
 * @param fmt - The format string
4
 * @param args - Arguments to replace in the format string
5
 * @returns An array with the formatted string as the first element, followed by any unused args
6
 */
7
export function formatWithReplacements(
1✔
8
  fmt: string,
9✔
9
  args: unknown[],
9✔
10
): unknown[] {
9✔
11
  if (typeof fmt !== "string") return [fmt, ...args];
9✔
12
  let i = 0;
8✔
13
  const formatted = fmt.replace(/%[sdifoO]/g, (match) => {
8✔
14
    if (i >= args.length) return match;
13✔
15
    const val = args[i++];
11✔
16
    switch (match) {
11✔
17
      case "%s":
13✔
18
        return String(val);
5✔
19
      case "%d":
13✔
20
      case "%i":
13✔
21
        return String(parseInt(val as string, 10));
3✔
22
      case "%f":
13✔
23
        return String(parseFloat(val as string));
1✔
24
      case "%o":
13✔
25
      case "%O":
13✔
26
        return typeof val === "object" ? JSON.stringify(val) : String(val);
2!
27
      default:
13!
28
        return match;
×
29
    }
13✔
30
  });
8✔
31
  return [formatted, ...args.slice(i)];
8✔
32
}
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc