fn
get
v0.0.4testedSafely read a deeply nested value from a collection by a dot-separated path
Example
ts
get({ user: { name: 'John' } }, 'user.name'); // 'John'
get({ items: [{ id: 1 }] }, 'items.0.id'); // 1
get({ a: 1 }, 'a.b.c'); // undefinedSignature
ts
export function get<O extends Collection, K extends string>(obj: O, path: K): Get<O, K> | undefined{ ... }Type Parameters
Oextends CollectionKextends stringParameters
| Parameter | Type | Description |
|---|---|---|
obj | O | The source object or array |
path | K | Dot-separated path, e.g. `'user.addresses.0.street'` |
Returns
ExtractFromCollection<O, Path<K>> | undefinedThe resolved value, or `undefined` if any segment is missing