9 lines
271 B
TypeScript
9 lines
271 B
TypeScript
export function getObjectEntryByKey(key: string, data: { [key: string]: any }): any | undefined {
|
|
let entry = data;
|
|
for (const part of key.split('.')) {
|
|
entry = entry[part];
|
|
if (entry === null || typeof entry !== 'object') return entry;
|
|
}
|
|
return entry;
|
|
}
|