@jiminp/tooltool
    Preparing search index...

    Function recordAccess

    • Accesses a nested record at the given path, returning a value and setter.

      Type Parameters

      • T = unknown

        The value type.

      Parameters

      • obj: Record<string, unknown>

        The nested record.

      • ...path: (string | string[])[]

        Path segments (strings or arrays of strings).

      Returns [T | undefined, (value: T) => void]

      [value, setValue] — value is undefined if path doesn't exist; setter creates intermediate objects as needed.

      const obj = { a: { b: { c: 42 } } };
      const [value, setValue] = recordAccess<number>(obj, ['a', 'b', 'c']);
      value; // 42
      setValue(100);
      obj.a.b.c; // 100