All files / src/background/methods strings.ts

0% Statements 0/11
0% Branches 0/4
0% Functions 0/5
0% Lines 0/11

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 24 25 26                                                   
export function reverseString(string:string):string {
    if (string === "")
        return "";
    else
        return reverseString(string.substr(1)) + string.charAt(0);
}
 
export function stringReplaceSubstringOneTimeFromBeginningAndEnd(string:string, substring:string, replaceWith:string):string {
    string = string.replace(substring, replaceWith);
    string = reverseString(string);
    string = string.replace(substring, replaceWith);
    string = reverseString(string);
    return string;
}
 
export function deleteSpaces(string:string):string {
    return string.replace(/\s/,"")
}
 
export function trimString(string:string, maxLength: number):string {
    return string.length > maxLength ? string.substr(0, maxLength-1) : string;
}
 
export function trimStringWithDotsAtEnd(string:string, maxLength: number):string {
    return trimString(string, maxLength) + '…';
}