All files / src/_util hash-string.ts

87.5% Statements 7/8
50% Branches 1/2
100% Functions 1/1
100% Lines 7/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  98x       98x 98x 11467x 11467x   11467x   98x    
export function hashString(str) {
  let hash = 0;
  let i;
  let chr;
  let len;
  Iif (str.length === 0) return hash;
  for (i = 0, len = str.length; i < len; i++) {
    chr = str.charCodeAt(i);
    hash = (hash << 5) - hash + chr; // eslint-disable-line no-bitwise
    // Convert to 32bit integer
    hash |= 0; // eslint-disable-line no-bitwise
  }
  return hash;
}