@imjano/get_object_in_object
Version:
Through a dot-separated path (example: 'subObject.foo.bar') you can find an object inside another parent object.
12 lines (11 loc) • 487 B
TypeScript
/**
*
* @param object where you want to find the result object
* @param path path to find the result object
* @description Given a path divided by dots (example: 'foo.bar') you can find an object inside another parent object
* @example
* const path = 'foo.bar'
* const obj = { foo: { bar: 'hello' } }
* console.log( getObjectInObject( obj, path ) ) //output: 'hello'
*/
export default function getObjectInObject(object: Record<string, any>, path: string | Array<string>): any;