All files / utils string-utils.ts

100% Statements 9/9
70% Branches 7/10
100% Functions 1/1
100% Lines 9/9

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 1712x   409x 409x     409x 409x 1075x 1075x 899x     409x      
export class StringUtils {
  static findLast(str: string, re = /[a-z0-9]/i, startNdx: number = -1): number {
    Eif (startNdx < 0 || startNdx > str.length) {
      startNdx = str.length - 1;
    }
 
    let found = false;
    while (!found && startNdx >= 0) {
      found = re.test(str.charAt(startNdx));
      if (!found)
        startNdx--;
    }
 
    return startNdx;
  }
}