UNPKG

cmte

Version:

Design by Committee™ except it's just you and LLMs

10 lines 454 B
/** * Safely get a nested property from an object using dot notation. * @param {object} obj The object to query. * @param {string} path The dot-separated path string. * @returns {any} The value at the path, or undefined if not found. */ export function getNestedProperty(obj, path) { if (!path) return undefined; // Handle empty path return path.split('.').reduce((o, k) => (o && o[k] !== undefined && o[k] !== null) ? o[k] : undefined, obj); }