UNPKG
data-structures-again
Version:
latest (3.3.0)
3.3.0
3.2.0
3.1.0
3.0.0
2.5.0
2.3.0
2.2.0
2.1.10
2.1.9
2.1.8
2.1.7
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.0
1.29.1
1.29.0
1.28.0
1.27.1
1.27.0
1.26.0
1.25.0
1.24.2
1.24.1
1.24.0
1.23.0
1.22.0
1.21.1
1.20.1
1.20.0
1.19.3
1.19.2
1.19.1
1.19.0
1.18.8
1.18.7
1.18.6
1.18.5
1.18.4
1.18.3
1.18.2
1.18.1
1.18.0
1.17.6
1.17.5
1.17.4
1.17.3
1.17.2
1.17.1
1.17.0
1.15.2
1.15.1
1.14.0
1.13.0
1.12.2
1.12.1
1.12.0
1.11.1
1.11.0
1.10.0
1.9.0
1.8.0
1.7.0
1.6.0
1.5.0
1.4.0
1.3.0
1.2.1
1.2.0
1.1.3
1.1.2
1.1.1
1.1.0
1.0.1
1.0.0
A Javascript library of simple data structures
github.com/divyanshyadav/data-structures-again
data-structures-again
/
src
/
utils
/
hash.js
17 lines
(13 loc)
•
327 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function
hashCode
(
string
) {
string
=
string
.
toString
()
let
hash =
0
for
(
let
i =
0
; i <
string
.
length
; i++) {
let
chr =
string
.
charCodeAt
(i) hash = ((hash <<
5
) - hash) + chr hash |=
0
// Convert to 32bit integer
}
return
hash }
module
.
exports
= { hashCode }