File tree 1 file changed +3
-4
lines changed
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 2
2
module . exports = {
3
3
'get' : function ( obj , path ) {
4
4
// supports a.b, a[1] and foo[bar], etc.
5
- // where obj is ['nope', 'yes', {a: {b: 1}, foo: 2}]
5
+ // for example: where obj is ['nope', 'yes', {a: {b: 1}, foo: 2}]
6
6
// then [1] returns 'yes'; [2].a.b returns 1; [2].a[foo] returns 2;
7
7
path = path . split ( / [ \. \[ \] ] / ) . filter ( d => d ) ;
8
8
return path . reduce ( ( r , p ) => {
@@ -12,9 +12,8 @@ module.exports = {
12
12
} , obj ) ;
13
13
} ,
14
14
'set' : function ( obj , path , value ) {
15
- // todo: replace implementation of assignPathValue with this impl and
16
- // remove updatePathValue (only need one function, not both)
17
- // same as assignPathValue except removes property if value is undefined
15
+ // assign property creates Objects and Arrays as needed
16
+ // removes property if typeof(value) is undefined
18
17
path = path . split ( / [ \. \[ \] ] / ) . filter ( d => d ) ;
19
18
const isRemove = typeof value === 'undefined' ;
20
19
// enable look-ahead to determine if type is array or object
You can’t perform that action at this time.
0 commit comments