@nesvet/n
Version:
Various utilities
16 lines • 496 B
JavaScript
export function getPath(object, path) {
if (path) {
if (path.includes(".")) {
let subObject = object; // eslint-disable-line @typescript-eslint/no-explicit-any
for (const key of path.split(".")) {
subObject = subObject?.[key];
if (subObject === undefined)
break;
}
return subObject;
}
return object[path];
}
return object;
}
//# sourceMappingURL=getPath.js.map