1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = hash;
|
7 |
|
8 |
|
9 | // a simple djb2 hash based on hash-string:
|
10 | // https://github.com/MatthewBarker/hash-string/blob/master/source/hash-string.js
|
11 | // returns a hex-encoded hash
|
12 | function hash(text) {
|
13 | if (!text) {
|
14 | return '';
|
15 | }
|
16 |
|
17 | var hashValue = 5381;
|
18 | var index = text.length - 1;
|
19 |
|
20 | while (index) {
|
21 | hashValue = hashValue * 33 ^ text.charCodeAt(index);
|
22 | index -= 1;
|
23 | }
|
24 |
|
25 | return (hashValue >>> 0).toString(16);
|
26 | }
|
27 | module.exports = exports['default']; |
\ | No newline at end of file |