DuyTa's picture
Upload folder using huggingface_hub
bc20498 verified
raw
history blame
383 Bytes
// https://github.com/darkskyapp/string-hash/blob/master/index.js
const regex_return_characters = /\r/g;
/**
* @param {string} str
* @returns {string}
*/
export default function hash(str) {
str = str.replace(regex_return_characters, '');
let hash = 5381;
let i = str.length;
while (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
return (hash >>> 0).toString(36);
}