UNPKG

1.06 kBJavaScriptView Raw
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
12const murmur = require("imurmurhash");
13
14//------------------------------------------------------------------------------
15// Helpers
16//------------------------------------------------------------------------------
17
18//------------------------------------------------------------------------------
19// Private
20//------------------------------------------------------------------------------
21
22/**
23 * hash the given string
24 * @param {string} str the string to hash
25 * @returns {string} the hash
26 */
27function hash(str) {
28 return murmur(str).result().toString(36);
29}
30
31//------------------------------------------------------------------------------
32// Public Interface
33//------------------------------------------------------------------------------
34
35module.exports = hash;