Files
n8n-enterprise-unlocked/packages/design-system/src/utils/valueByPath.ts

15 lines
336 B
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Get a deeply nested value based on a given path string
*
* @param object
* @param path
* @returns {T}
*/
export function getValueByPath<T = any>(object: any, path: string): T {
return path.split('.').reduce((acc, part) => {
return acc && acc[part];
}, object);
}