All files / Rindu/utils capitalizeFirstLetter.ts

75% Statements 3/4
16.66% Branches 1/6
100% Functions 1/1
75% Lines 3/4

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    5x 7x 7x                
import { ReactNode } from "react";
 
export function capitalizeFirstLetter(string: string | ReactNode[]): string {
  if (typeof string === "string") {
    return string.charAt(0).toUpperCase() + string.slice(1);
  } else E{
    return (
      string[0]?.toString().charAt(0).toUpperCase() ||
      "" + (string[0]?.toString().slice(1) || "")
    );
  }
}