Matt Visnovsky
2024-05-06 09:49:36 -06:00
parent 86b997c664
commit 0384b34007
4 changed files with 5 additions and 23 deletions

View File

@@ -642,13 +642,3 @@ export function intHash(str : string, length = 10) : number {
// Normalize the hash to the range [0, 10]
return (hash % length + length) % length; // Ensure the result is non-negative
}
/**
* Retrieves the key from the provided object corresponding to the given value.
* @param {object} obj - The object to search.
* @param {*} value - The value to search for.
* @returns {string|null} - The key associated with the value, or null if not found.
*/
export function getKey(obj: any, value: string) {
return Object.keys(obj).find(key => obj[key] === value) || null;
}