get-wild
Version:
Pluck nested properties from an object with support for wildcards
19 lines (18 loc) • 606 B
TypeScript
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 Get = <T = any>(path: Path, $default?: unknown) => <U = T>(value: unknown) => U;
declare const get$0: Get;
declare const getter$0: (options?: Options) => Get;
export { get$0 as get, getter$0 as getter };