All files / src/utils packText.ts

57.14% Statements 4/7
40% Branches 2/5
100% Functions 1/1
57.14% Lines 4/7

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          5x   76x         76x               76x    
export interface PackOptions {
 
    removeWhiteSpaces?: boolean
}
 
export default function packText(text: string, options: PackOptions = {}) {
 
    Iif (options.removeWhiteSpaces === undefined) {
 
        options.removeWhiteSpaces = true; // True by default
    }
 
    Iif (options.removeWhiteSpaces === true) {
 
        text = text.replace(/\n|\r/g,'');
 
        return text.replace(/\s/g,' ');
    }
    else {
 
        return text.replace(/\n|\r/g,'');
    }
}