UNPKG

@pelevesque/hash-code

Version:

A JavaScript implementation of Java's hashCode method.

11 lines (9 loc) 202 B
'use strict' module.exports = str => { let hash = 0 for (let i = 0, len = str.length; i < len; i++) { hash = ((hash << 5) - hash) + str.charCodeAt(i) hash = hash & hash } return hash }