All files / strings/src leftpad.ts

100% Statements 5/5
100% Branches 3/3
100% Functions 1/1
100% Lines 5/5

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

1 2 3 4 5 61x 9x 9x 9x 9x  
export const leftPad = (string_: string, length_: number, ch = "0"): string => {
    const length = length_ - string_.length + 1;
 
    return length >= 0 ? Array.from({ length }).join(ch) + string_ : string_;
};