budibase/packages/client/src/utils/hash.js

13 lines
265 B
JavaScript
Raw Normal View History

2021-05-03 09:31:09 +02:00
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
}