mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-11-29 10:55:21 +01:00
1ada95e04a
- Convert project to Javascript/Typescript - Allow custom headers to be passed in (optional) - Allow body to be optional
35 lines
1 KiB
JavaScript
35 lines
1 KiB
JavaScript
/**
|
|
* @fileoverview Defining the hashing function in one place.
|
|
* @author Michael Ficarra
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Requirements
|
|
//------------------------------------------------------------------------------
|
|
|
|
const murmur = require("imurmurhash");
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Helpers
|
|
//------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Private
|
|
//------------------------------------------------------------------------------
|
|
|
|
/**
|
|
* hash the given string
|
|
* @param {string} str the string to hash
|
|
* @returns {string} the hash
|
|
*/
|
|
function hash(str) {
|
|
return murmur(str).result().toString(36);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Public Interface
|
|
//------------------------------------------------------------------------------
|
|
|
|
module.exports = hash;
|