UNPKG

get-wild

Version:

Pluck nested properties from an object with support for wildcards

21 lines (20 loc) 786 B
interface Collect { (value: {}): Array<unknown>; (value: {}, index: number): ArrayLike<unknown>; } type Options = { collect?: Collect; default?: unknown; flatMap?: PropertyKey | false; map?: PropertyKey | false; parser?: Options["split"]; split?: string | Parser; }; type Parser = (path: string) => Array<PropertyKey>; type Path = PropertyKey | Array<PropertyKey>; type Getter = (options?: Options) => <T = any>(value: unknown, path: Path, $default?: unknown) => T; declare const getter: Getter; declare const get: <T = any>(value: unknown, path: Path, $default?: unknown) => T; type Step = string | number; declare const parser: (path: string) => Step[]; export { Collect, Options, Parser, Path, get, getter, parser as parse, parser, parser as split };