版博士V2.0程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

18 řádky
408 B

  1. "use strict";
  2. function hash(str) {
  3. var hash = 5381,
  4. i = str.length;
  5. while(i) {
  6. hash = (hash * 33) ^ str.charCodeAt(--i);
  7. }
  8. /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
  9. * integers. Since we want the results to be always positive, convert the
  10. * signed int to an unsigned by doing an unsigned bitshift. */
  11. return hash >>> 0;
  12. }
  13. module.exports = hash;