1 | declare const objectPath: objectPath.ObjectPathStatic & {
|
2 | withInheritedProps: objectPath.ObjectPathStatic;
|
3 | create(options?: objectPath.Options): objectPath.ObjectPathStatic;
|
4 | };
|
5 |
|
6 | declare namespace objectPath {
|
7 | interface Options {
|
8 | includeInheritedProps?: boolean | undefined;
|
9 | }
|
10 |
|
11 | type Path = Array<number | string> | number | string;
|
12 |
|
13 | interface ObjectPathStatic {
|
14 | |
15 |
|
16 |
|
17 | <T extends object>(object: T): ObjectPathBound<T>;
|
18 |
|
19 | |
20 |
|
21 |
|
22 | del(object: object, path: Path): { [key: string]: any };
|
23 |
|
24 | |
25 |
|
26 |
|
27 | has(object: object, path: Path): boolean;
|
28 |
|
29 | |
30 |
|
31 |
|
32 | get(object: object, path: Path): any;
|
33 | get<TResult>(object: object, path: Path, defaultValue: TResult): TResult;
|
34 |
|
35 | |
36 |
|
37 |
|
38 |
|
39 | set<TResult = any>(
|
40 | object: object,
|
41 | path: Path,
|
42 | value: TResult,
|
43 | doNotReplace?: boolean,
|
44 | ): TResult | undefined;
|
45 |
|
46 | |
47 |
|
48 |
|
49 | push(object: object, path: Path, ...items: any[]): void;
|
50 |
|
51 | |
52 |
|
53 |
|
54 | coalesce<TResult>(object: object, paths: Path | Path[], defaultValue: TResult): TResult;
|
55 | coalesce<TResult = any>(
|
56 | object: object,
|
57 | paths: Path | Path[],
|
58 | defaultValue?: TResult,
|
59 | ): TResult | undefined;
|
60 |
|
61 | |
62 |
|
63 |
|
64 |
|
65 | empty(object: object, path: Path): any;
|
66 |
|
67 | |
68 |
|
69 |
|
70 | ensureExists<TResult>(object: object, path: Path, defaultValue: TResult): TResult;
|
71 | ensureExists<TResult = any>(
|
72 | object: object,
|
73 | path: Path,
|
74 | defaultValue?: TResult,
|
75 | ): TResult | undefined;
|
76 |
|
77 | |
78 |
|
79 |
|
80 | insert(object: object, path: Path, value: any, at?: number): void;
|
81 | }
|
82 |
|
83 | interface ObjectPathBound<T extends object> {
|
84 | |
85 |
|
86 |
|
87 | del(path: Path): { [key: string]: any };
|
88 |
|
89 | |
90 |
|
91 |
|
92 | has(path: Path): boolean;
|
93 |
|
94 | |
95 |
|
96 |
|
97 | get(path: Path): any;
|
98 | get<TResult>(path: Path, defaultValue: TResult): TResult;
|
99 |
|
100 | |
101 |
|
102 |
|
103 | set<TResult = any>(path: Path, value: TResult, doNotReplace?: boolean): TResult | undefined;
|
104 |
|
105 | |
106 |
|
107 |
|
108 | push(path: Path, ...items: any[]): void;
|
109 |
|
110 | |
111 |
|
112 |
|
113 | coalesce<TResult>(paths: Path | Path[], defaultValue: TResult): TResult;
|
114 | coalesce<TResult = any>(paths: Path | Path[], defaultValue?: TResult): TResult | undefined;
|
115 |
|
116 | |
117 |
|
118 |
|
119 | empty(path: Path): any;
|
120 |
|
121 | |
122 |
|
123 |
|
124 | ensureExists<TResult>(path: Path, defaultValue: TResult): TResult;
|
125 | ensureExists<TResult = any>(path: Path, defaultValue?: TResult): TResult | undefined;
|
126 |
|
127 | |
128 |
|
129 |
|
130 | insert(path: Path, value: any, at?: number): void;
|
131 | }
|
132 | }
|
133 |
|
134 | export = objectPath;
|