summaryrefslogtreecommitdiff
path: root/src/utility.js
blob: f2ee3fb7684aa1459859a697904331d950f58094 (plain)
1
2
3
4
5
6
7
8
9
10
11
export default class Utility {
  static hashCode(str) {
    let hash = 0;
    for (let i = 0, len = str.length; i < len; i++) {
        let chr = str.charCodeAt(i);
        hash = (hash << 5) - hash + chr;
        hash |= 0; // Convert to 32bit integer
    }
    return (hash>0) ? hash : -hash;
  }
}