Skip to main content

Class: HashUtils

Defined in: utils/HashUtils.ts:2

Utility methods for non-cryptographic hashing

Constructors

Constructor

new HashUtils(): HashUtils

Returns

HashUtils

Methods

djb2()

static djb2(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()

static djb2Pick<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