getKeyObjectFromValue
Function that given an object and a value, returns the corrispondent key of this value or undefined.
Types
GetKeyObjectFromValueProps
@templateT - The object type to search within.@templateE - The type of the key to return. Defaults tokeyof T.
Parameters accepted by getKeyObjectFromValue.
| Property | Type | Required | Description |
|---|---|---|---|
object | T | ✓ | The object to search through. Its values are compared against value using strict equality. |
value | unknown | The value to look up within object. When a property of object strictly equals this value, the corresponding key is returned. When omitted or when no match is found, undefined is returned. |
GetKeyObjectFromValueResult
@templateE - The key type, defaulting tokeyof T.
Return value of getKeyObjectFromValue.
The key of type E whose associated value in the object strictly equals the searched value, or undefined when no match is found.
ts
export type GetKeyObjectFromValueResult<E extends string | number | symbol> = E | undefined;