All files / src topTrim.ts

100% Statements 13/13
100% Branches 2/2
100% Functions 1/1
100% Lines 10/10

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          4x 48x 48x   48x 224x 224x 90x     224x 137x       48x    
/**
 * Trims given string from top
 *
 * @private withing the repository
 */
export function topTrim(content: string): string {
    const linesWithContent: string[] = [];
    let contentStarted = false;
 
    const lines = content.split('\n');
    for (const line of lines) {
        if (line.trim() !== '') {
            contentStarted = true;
        }
 
        if (contentStarted) {
            linesWithContent.push(line);
        }
    }
 
    return linesWithContent.join('\n');
}