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