(array: (string | number)[])
| 5 | * @returns The computed hash value. |
| 6 | */ |
| 7 | export const hashArray = (array: (string | number)[]) => { |
| 8 | let hash = 0x811c9dc5; |
| 9 | |
| 10 | for (let i = 0, li = array.length; i < li; i++) { |
| 11 | const str = `${array[i]}`; |
| 12 | hash ^= str.length; |
| 13 | hash = Math.imul(hash, 0x01000193) >>> 0; |
| 14 | |
| 15 | for (let j = 0, lj = str.length; j < lj; j++) { |
| 16 | hash ^= str.charCodeAt(j); |
| 17 | hash = Math.imul(hash, 0x01000193) >>> 0; |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | return hash; |
| 22 | }; |