Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

35 rindas
1.0 KiB

pirms 4 gadiem
  1. /**
  2. * @fileoverview Defining the hashing function in one place.
  3. * @author Michael Ficarra
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Requirements
  8. //------------------------------------------------------------------------------
  9. const murmur = require("imurmurhash");
  10. //------------------------------------------------------------------------------
  11. // Helpers
  12. //------------------------------------------------------------------------------
  13. //------------------------------------------------------------------------------
  14. // Private
  15. //------------------------------------------------------------------------------
  16. /**
  17. * hash the given string
  18. * @param {string} str the string to hash
  19. * @returns {string} the hash
  20. */
  21. function hash(str) {
  22. return murmur(str).result().toString(36);
  23. }
  24. //------------------------------------------------------------------------------
  25. // Public Interface
  26. //------------------------------------------------------------------------------
  27. module.exports = hash;