mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-03 13:19:16 -05:00
various improvements for shopping line item dialog
This commit is contained in:
18
vue3/src/utils/utils.ts
Normal file
18
vue3/src/utils/utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Gets a nested property of an object given a dot-notation path.
|
||||
*
|
||||
* @param object The object to access the property from.
|
||||
* @param path The dot-notation path to the property.
|
||||
* @returns The value of the nested property, or `undefined` if not found.
|
||||
*/
|
||||
export function getNestedProperty(object: any, path: string): any {
|
||||
const pathParts = path.split('.');
|
||||
|
||||
return pathParts.reduce((obj, key) => {
|
||||
if (obj && typeof obj === 'object') {
|
||||
return obj[key]
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}, object);
|
||||
}
|
||||
Reference in New Issue
Block a user