1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-04-19 02:50:55 +00:00
comunicapiv2/src/utils/ArrayUtils.ts

24 lines
448 B
TypeScript

/**
* Array utilities
*
* @author Pierre HUBERT
*/
/**
* Find the key matching a given value in an object
*
* @param object Object to search in
* @param value The value to search for
* @returns Matching key, or null if not found
*/
export function findKey(object: Object, value: any): string {
for (const key in object) {
if (!object.hasOwnProperty(key))
continue;
if(object[key] == value)
return key;
}
return null;
}