UNPKG

bbo

Version:

bbo is a utility library of zero dependencies for javascript.

30 lines (24 loc) 589 B
import './get_tag.js'; import './is_array.js'; import './is_string.js'; import './is_map.js'; import './is_set.js'; import size from './size.js'; /** * string hash map * From https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery */ function hash(str) { var _str = String(str); var hash = 0; var i; var chr; if (size(_str) === 0) return hash; for (i = 0; i < _str.length; i++) { chr = _str.charCodeAt(i); hash = (hash << 5) - hash + chr; hash |= 0; // Convert to 32bit integer } return hash; } export default hash;