All files / src/string maxSubstrWord.ts

80% Statements 4/5
83.33% Branches 5/6
100% Functions 1/1
75% Lines 3/4

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              2x 3x 3x        
 
/**
 * 从头开始,最大截取多少个字符串
 * @param str 
 * @param len 最大截取多少个字符串
 * @param isSpot 是否带 ...
 */
export const maxSubstrWord = (str: string, len = 5, isSpot = true): string => {
  Eif (typeof str === 'string') {
    return isSpot ? `${str.substr(0, len)}...` : str.substr(0, len);
  } else {
    return str;
  }
};