hashStringBetween()function
hashStringBetween(str: string, min = 0, max = 256): number
| Param | Type | |
|---|---|---|
str | string | The string to hash. required |
min | unknown | The inclusive lower bound of the output range. Defaults to 0. Defaults to 0 |
max | unknown | The exclusive upper bound of the output range. Defaults to 256. Defaults to 256 |
| Return | |
|---|---|
number | A number in the range min to max derived from the string. |
Hash a string into an idempotent number wrapped between two values.
- Useful for deterministically mapping a string into a fixed range, e.g. a colour or bucket index.
Examples
hashStringBetween("abc", 0, 10) // 4