1 declare const dotProp: {
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.
9 import dotProp = require('dot-prop');
11 dotProp.get({foo: {bar: 'unicorn'}}, 'foo.bar');
14 dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep');
17 dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');
20 dotProp.get({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
25 object: {[key: string]: any} | undefined,
29 object: {[key: string]: any} | undefined,
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`.
42 import dotProp = require('dot-prop');
44 const object = {foo: {bar: 'a'}};
45 dotProp.set(object, 'foo.bar', 'b');
47 //=> {foo: {bar: 'b'}}
49 const foo = dotProp.set({}, 'foo.bar', 'c');
51 //=> {foo: {bar: 'c'}}
53 dotProp.set(object, 'foo.baz', 'x');
55 //=> {foo: {bar: 'b', baz: 'x'}}
58 set<T extends {[key: string]: any}>(
65 @param object - Object to test the `path` value.
66 @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
70 import dotProp = require('dot-prop');
72 dotProp.has({foo: {bar: 'unicorn'}}, 'foo.bar');
76 has(object: {[key: string]: any} | undefined, path: string): boolean;
79 @param object - Object to delete the `path` value.
80 @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
81 @returns A boolean of whether the property existed before being deleted.
85 import dotProp = require('dot-prop');
87 const object = {foo: {bar: 'a'}};
88 dotProp.delete(object, 'foo.bar');
92 object.foo.bar = {x: 'y', y: 'x'};
93 dotProp.delete(object, 'foo.bar.x');
95 //=> {foo: {bar: {y: 'x'}}}
98 delete(object: {[key: string]: any}, path: string): boolean;