版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

18 строки
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;