Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

/**
 * Generate a 32bit integer hash for a given string
 * Sources:
 *   - http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
 *   - https://stackoverflow.com/questions/194846/is-there-any-kind-of-hash-code-function-in-javascript/8076436#8076436
 *   - https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0
 *   - https://en.wikipedia.org/wiki/Java_hashCode()
 */
var _default = function _default(str) {
  var hash = 0;
  if (str.length === 0) return hash;

  for (var i = 0; i < str.length; i += 1) {
    var char = str.charCodeAt(i); // eslint-disable-next-line no-bitwise

    hash = (hash << 5) - hash + char; // eslint-disable-next-line no-bitwise

    hash &= hash; // Convert to 32bit integer
  }

  return hash;
};

exports.default = _default;
//# sourceMappingURL=hash.js.map