mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
10 lines
428 B
TypeScript
10 lines
428 B
TypeScript
export function getValue(obj, path) {
|
|
if (!obj) return undefined; // Return early if obj is falsy
|
|
|
|
var pathArray = path.split('.'); // Use a different variable for the split path
|
|
for (var i = 0, len = pathArray.length; i < len; i++) {
|
|
if (!obj) return undefined; // Check if obj is falsy at each step
|
|
obj = obj[pathArray[i]]; // Dive one level deeper
|
|
}
|
|
return obj; // Return the final value
|
|
} |