pathtrace
Simplifies working with nested objects and arrays by providing easy methods to retrieve, set, and check values at any path.

Why pathtrace? · Install · Usage · API
---
## Why pathtrace?
Use one path notation for nested reads, writes, removals and wildcard selection.
| Concern | Without it | With pathtrace |
| --- | --- | --- |
| A dynamic path | Split keys and walk each level yourself | Read `users[0].name` with `getPathValue()` |
| Missing containers | Decide when to create an object or array | `setPathValue()` creates intermediates from the next segment |
| Wildcard selection | Write a traversal for each object shape | Expand `*` or `**` into concrete paths |
| Missing vs undefined | Inspect each parent and property | `PathInfo.exists` distinguishes an existing undefined value |
| Reusing paths | Maintain a parser and escaping rules | Convert paths to segments and back |
For a known shape, use `data.users[0]?.name`. For a path supplied by configuration, use the same operation with a string:
```typescript
import { getPathValue, setPathValue } from 'pathtrace';
const data = { users: [{ name: 'Ada' }] };
console.log(getPathValue(data, 'users[0].name')); // Ada
setPathValue(data, 'users[1].name', 'Lin');
console.log(data.users[1]?.name); // Lin
```