UNPKG

@apify/actors-mcp-server

Version:

Model Context Protocol Server for Apify

27 lines 918 B
/** * Recursively gets the value in a nested object for each key in the keys array. * Each key can be a dot-separated path (e.g. 'a.b.c'). * Returns an object mapping each key to its resolved value (or undefined if not found). */ export function getValuesByDotKeys(obj, keys) { const result = {}; for (const key of keys) { const path = key.split('.'); let current = obj; for (const segment of path) { if (current !== null && typeof current === 'object' && Object.prototype.hasOwnProperty.call(current, segment)) { // Use index signature to avoid 'any' and type errors current = current[segment]; } else { current = undefined; break; } } result[key] = current; } return result; } //# sourceMappingURL=generic.js.map