main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d565449] | 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
|
---|
| 24 | * @param {string} str the string to hash
|
---|
| 25 | * @returns {string} the hash
|
---|
| 26 | */
|
---|
| 27 | function hash(str) {
|
---|
| 28 | return murmur(str).result().toString(36);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | //------------------------------------------------------------------------------
|
---|
| 32 | // Public Interface
|
---|
| 33 | //------------------------------------------------------------------------------
|
---|
| 34 |
|
---|
| 35 | module.exports = hash;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.