import type { Dictionary } from './types.js'; /** * Read a value from an object or array by following a path of keys. * * Returns a `{ success, value }` discriminator — use `success` to distinguish * a missing path from a stored `null` or `undefined`. * * @typeParam T - Optional type to assert the found value as (defaults to `unknown`). * Not inferred from `input` - since `path` can navigate to any depth, * there's no way to derive it automatically, so it must be given explicitly. * * @param input - The object or array to read from * @param path - A dot-separated string (e.g. `'a.b.0.c'`) or an array of keys * (e.g. `['a', 'b', '0', 'c']`). Empty segments are ignored, so * `'a..b'` and `'.a.b.'` resolve the same as `'a.b'`. * * @returns `{ success, value }` — see the property docs for details. * * @remarks * - An empty path (or one that filters down to no keys) returns * `{ success: false, value: null }`. * - On arrays, only canonical numeric-string keys are accepted; `'length'`, * `'map'`, and other inherited or non-numeric keys return failure. * - Sparse-array holes are treated as missing (`success: false`), not as a * stored `undefined`. * * @example * ```ts * // Object input * getProperty({ a: { b: 2 } }, 'a.b'); // --> { success: true, value: 2 } * getProperty({ a: [{ b: 'hi' }] }, 'a.0.b'); // --> { success: true, value: 'hi' } * getProperty({ a: 1 }, 'a.b'); // --> { success: false, value: null } * * // Distinguishing missing from stored null * getProperty({ a: null }, 'a'); // --> { success: true, value: null } * getProperty({}, 'a'); // --> { success: false, value: null } * * // Array input * getProperty([10, 20, 30], '1'); // --> { success: true, value: 20 } * getProperty(['a', ['b', 'c']], '1.0'); // --> { success: true, value: 'b' } * * // Array path * getProperty({ a: { b: 2 } }, ['a', 'b']); // --> { success: true, value: 2 } * * // Asserting the value's type explicitly (not inferred - see @typeParam) * getProperty({ a: { b: 2 } }, 'a.b'); // --> value is typed `number | null` * ``` */ export declare function getProperty(input: Dictionary | unknown[], path: string | string[]): { /** Whether the path was fully traversed */ success: boolean; /** The value at the path, or `null` if any step could not be traversed */ value: T | null; };