getAtPath

function
patch-utils.ts:30
signature
getAtPath(obj, dottedPath): any

Walks a dotted path (e.g., "counter.value") into an object.

Parameters

NameTypeDescription
objanyRoot object to traverse.
NameTypeDescription
dottedPathstringDot-separated path string.

Returns

any, The value at the path, or undefined if unreachable.

Example

example
import { getAtPath } from "@yoltra/devtools-protocol";

const state = { counter: { value: 10 } };
getAtPath(state, "counter.value"); // 10
getAtPath(state, "missing.key");   // undefined