21b05459537649cafdf558697805fdeedc156fa8
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / dot-prop / index.d.ts
1 declare const dotProp: {
2         /**
3         @param object - Object to get the `path` value.
4         @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
5         @param defaultValue - Default value.
6
7         @example
8         ```
9         import dotProp = require('dot-prop');
10
11         dotProp.get({foo: {bar: 'unicorn'}}, 'foo.bar');
12         //=> 'unicorn'
13
14         dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep');
15         //=> undefined
16
17         dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');
18         //=> 'default value'
19
20         dotProp.get({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
21         //=> 'unicorn'
22         ```
23         */
24         get<T>(
25                 object: {[key: string]: any} | undefined,
26                 path: string
27         ): T | undefined;
28         get<T>(
29                 object: {[key: string]: any} | undefined,
30                 path: string,
31                 defaultValue: T
32         ): T;
33
34         /**
35         @param object - Object to set the `path` value.
36         @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
37         @param value - Value to set at `path`.
38
39         @example
40         ```
41         import dotProp = require('dot-prop');
42
43         const object = {foo: {bar: 'a'}};
44         dotProp.set(object, 'foo.bar', 'b');
45         console.log(object);
46         //=> {foo: {bar: 'b'}}
47
48         const foo = dotProp.set({}, 'foo.bar', 'c');
49         console.log(foo);
50         //=> {foo: {bar: 'c'}}
51
52         dotProp.set(object, 'foo.baz', 'x');
53         console.log(object);
54         //=> {foo: {bar: 'b', baz: 'x'}}
55         ```
56         */
57         set<T extends {[key: string]: any}>(
58                 object: T,
59                 path: string,
60                 value: unknown
61         ): T;
62
63         /**
64         @param object - Object to test the `path` value.
65         @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
66
67         @example
68         ```
69         import dotProp = require('dot-prop');
70
71         dotProp.has({foo: {bar: 'unicorn'}}, 'foo.bar');
72         //=> true
73         ```
74         */
75         has(object: {[key: string]: any} | undefined, path: string): boolean;
76
77         /**
78         @param object - Object to delete the `path` value.
79         @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
80
81         @example
82         ```
83         import dotProp = require('dot-prop');
84
85         const object = {foo: {bar: 'a'}};
86         dotProp.delete(object, 'foo.bar');
87         console.log(object);
88         //=> {foo: {}}
89
90         object.foo.bar = {x: 'y', y: 'x'};
91         dotProp.delete(object, 'foo.bar.x');
92         console.log(object);
93         //=> {foo: {bar: {y: 'x'}}}
94         ```
95         */
96         delete(object: {[key: string]: any}, path: string): void;
97 };
98
99 export = dotProp;