1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00
budibase/packages/client/src/utils/hash.js

12 lines
263 B
JavaScript

export const hashString = str => {
if (!str) {
return 0
}
let hash = 0
for (let i = 0; i < str.length; i++) {
let char = str.charCodeAt(i)
hash = (hash << 5) - hash + char
hash = hash & hash // Convert to 32bit integer
}
return hash
}