n8n/packages/design-system/src/utils/valueByPath.ts
Alex Grozav 29f2629716
feat: Add basic Datatable and Pagination components (#5652)
* feat: add Datatable component

* feat: migrate to n8n-pagination and add datatable tests

* chore: fix linting issue
2023-03-15 18:52:02 +02:00

15 lines
417 B
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access */
/**
* 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);
}