Reformat code
This commit is contained in:
parent
6e27539eca
commit
420cd788c4
1 changed files with 10630 additions and 2646 deletions
14
src/app/utils/hash.ts
Normal file
14
src/app/utils/hash.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export const hashCode = (text: string) => {
|
||||
let hash = 0;
|
||||
if (text.length == 0) {
|
||||
return hash;
|
||||
}
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
const char = text.charCodeAt(i);
|
||||
hash = (hash << 5) - hash + char;
|
||||
hash = hash & hash;
|
||||
}
|
||||
|
||||
hash /= Math.pow(2, 32) - 1;
|
||||
return hash;
|
||||
};
|
||||
Loading…
Reference in a new issue