]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | /** |
2 | * @fileoverview Defining the hashing function in one place. | |
3 | * @author Michael Ficarra | |
4 | */ | |
5 | ||
6 | "use strict"; | |
7 | ||
8 | //------------------------------------------------------------------------------ | |
9 | // Requirements | |
10 | //------------------------------------------------------------------------------ | |
11 | ||
12 | const murmur = require("imurmurhash"); | |
13 | ||
14 | //------------------------------------------------------------------------------ | |
15 | // Helpers | |
16 | //------------------------------------------------------------------------------ | |
17 | ||
18 | //------------------------------------------------------------------------------ | |
19 | // Private | |
20 | //------------------------------------------------------------------------------ | |
21 | ||
22 | /** | |
23 | * hash the given string | |
609c276f TL |
24 | * @param {string} str the string to hash |
25 | * @returns {string} the hash | |
eb39fafa DC |
26 | */ |
27 | function hash(str) { | |
28 | return murmur(str).result().toString(36); | |
29 | } | |
30 | ||
31 | //------------------------------------------------------------------------------ | |
32 | // Public Interface | |
33 | //------------------------------------------------------------------------------ | |
34 | ||
35 | module.exports = hash; |