Class: HashUtils
Defined in: utils/HashUtils.ts:2
Utility methods for non-cryptographic hashing
Constructors
Constructor
new HashUtils():
HashUtils
Returns
HashUtils
Methods
djb2()
staticdjb2(str):number
Defined in: utils/HashUtils.ts:11
Computes the djb2 hash of a string
Returns a non-negative 32-bit integer.
Parameters
str
string
The string to hash
Returns
number
See
http://www.cse.yorku.ca/~oz/hash.html
djb2Pick()
staticdjb2Pick<T>(values,key):T
Defined in: utils/HashUtils.ts:26
Deterministically selects a value from an array based on the djb2 hash of a key string
Type Parameters
T
T
Parameters
values
T[]
The array of values to select from
key
string
The string key to hash and use for selection
Returns
T
A value from the array corresponding to the hashed key