Logos DX
    Preparing search index...

    Function setDeepMany

    • Sets multiple values deep within a nested object using dot notation paths.

      Efficiently sets multiple nested properties in a single call. Each entry is processed sequentially, and if any entry fails, an error is thrown immediately. Use this when you need to initialize or update multiple nested properties at once, such as building configuration objects or setting multiple metrics.

      Type Parameters

      • T extends object

      Parameters

      • obj: T

        object to modify

      • entries: [PathNames<T>, any][]

        array of [path, value] tuples to set

      Returns void

      const response = {};
      setDeepMany(response, [
      ['status.code', 200],
      ['status.message', 'OK'],
      ['data.results', [1, 2, 3]],
      ['data.total', 3]
      ]);
      // response is now { status: { code: 200, message: 'OK' }, data: { results: [1, 2, 3], total: 3 } }
      // Building configuration objects
      const config = {};
      setDeepMany(config, [
      ['server.port', 3000],
      ['server.host', 'localhost'],
      ['database.url', 'postgres://localhost'],
      ['database.pool.min', 2],
      ['database.pool.max', 10],
      ['features.auth.enabled', true],
      ['features.logging.level', 'info']
      ]);
      // Setting multiple metrics at once
      const metrics = { memory: { heap: 100 } };
      setDeepMany(metrics, [
      ['memory.rss', 1024],
      ['memory.external', 512],
      ['cpu.user', 50],
      ['cpu.system', 30]
      ]);