@@ -40,7 +40,10 @@ Sets a nested property value.
4040var obj = { ' a' : { ' b' : { ' c' : ' d' } } };
4141
4242var bool = deepSet ( obj, ' a.b.c' , ' beep' );
43- // obj => { 'a': { 'b': { 'c': 'beep' } } }
43+ // returns true
44+
45+ console .log ( obj );
46+ // => { 'a': { 'b': { 'c': 'beep' } } }
4447```
4548
4649If the function is able to deep set a nested property, the function returns ` true ` ; otherwise, the function returns ` false ` .
@@ -74,7 +77,10 @@ var arr = [
7477];
7578
7679var bool = deepSet ( arr, ' 1.a.0.x' , 25 );
77- /* arr =>
80+ // returns true
81+
82+ console .log ( arr );
83+ /* =>
7884 [
7985 { 'a': [ { 'x': 5 } ] },
8086 { 'a': [ { 'x': 25 } ] }
@@ -89,8 +95,8 @@ The key `path` may be specified as either a delimited `string` or a key `array`.
8995``` javascript
9096var obj = { ' a' : { ' b' : { ' c' : ' d' } } };
9197
92- var bool = deepSet ( obj, [ ' a' , ' b' , ' c' ], ' beep' );
93- // obj => { 'a': { 'b': { 'c': 'beep' } } }
98+ var bool = deepSet ( obj, [ ' a' , ' b' , ' c' ], ' beep' ); // obj => { 'a': { 'b': { 'c': 'beep' } } }
99+ // returns true
94100```
95101
96102If ` value ` is a ` function ` , the argument is treated as a ` callback ` and should return a value to set.
@@ -108,8 +114,8 @@ function set( val ) {
108114}
109115var obj = { ' a' : { ' b' : { ' c' : ' d' } } };
110116
111- var bool = deepSet ( obj, ' a.b.c' , set );
112- // obj => { 'a': { 'b': { 'c': 'ddddd' } } }
117+ var bool = deepSet ( obj, ' a.b.c' , set ); // obj => { 'a': { 'b': { 'c': 'ddddd' } } }
118+ // returns true
113119```
114120
115121The function accepts the following ` options ` :
@@ -127,7 +133,10 @@ var obj = { 'a': { 'b': { 'c': 'd' } } };
127133var bool = deepSet ( obj, ' a/b/c' , ' beep' , {
128134 ' sep' : ' /'
129135});
130- // obj => { 'a': { 'b': { 'c': 'beep' } } }
136+ // returns true
137+
138+ console .log ( obj );
139+ // => { 'a': { 'b': { 'c': 'beep' } } }
131140```
132141
133142To create a key path which does not already exist, set the ` create ` option to ` true ` .
@@ -140,7 +149,10 @@ var obj = { 'a': { 'b': { 'c': 'd' } } };
140149var bool = deepSet ( obj, ' a.e.c' , ' boop' , {
141150 ' create' : true
142151});
143- /* obj =>
152+ // returns true
153+
154+ console .log ( obj );
155+ /* =>
144156 {
145157 'a': {
146158 'b': {
@@ -177,7 +189,10 @@ var dset = deepSet.factory( 'a.b.c' );
177189var obj = { ' a' : { ' b' : { ' c' : ' d' } } };
178190
179191var bool = dset ( obj, ' beep' );
180- // obj => { 'a': { 'b': { 'c': 'beep' } } }
192+ // returns true
193+
194+ console .log ( obj );
195+ // => { 'a': { 'b': { 'c': 'beep' } } }
181196```
182197
183198</section >
0 commit comments