const metrics = { memory: { heap: 100 } };
setDeep(metrics, 'memory.rss', 1024);
// metrics is now { memory: { heap: 100, rss: 1024 } }
// Creates missing intermediate objects
const config = {};
setDeep(config, 'server.port', 3000);
setDeep(config, 'server.host', 'localhost');
setDeep(config, 'database.connection.timeout', 5000);
// config is now { server: { port: 3000, host: 'localhost' }, database: { connection: { timeout: 5000 } } }
Sets a value deep within a nested object using dot notation path.
Creates intermediate objects if they don't exist along the path. Mutates the original object in place. Use this when you need to update nested configuration objects, set metrics in nested structures, or build objects incrementally without manual property checking at each level.