版博士V2.0程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

18 líneas
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;