File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Creates a new Object using all values from obj1 and obj2.
2+ // If a value exists in both obj1 and obj2, the value in obj1 is used.
3+
4+ var Clone = require ( './Clone' ) ;
5+
6+ var Merge = function ( obj1 , obj2 )
7+ {
8+ var clone = Clone ( obj1 ) ;
9+
10+ for ( var key in obj2 )
11+ {
12+ if ( ! clone . hasOwnProperty ( key ) )
13+ {
14+ clone [ key ] = obj2 [ key ] ;
15+ }
16+ }
17+
18+ return clone ;
19+ } ;
20+
21+ module . exports = Merge ;
Original file line number Diff line number Diff line change 1+ // Creates a new Object using all values from obj1.
2+ //
3+ // Then scans obj2. If a property is found in obj2 that *also* exists in obj1,
4+ // the value from obj2 is used, otherwise the property is skipped.
5+
6+ var Clone = require ( './Clone' ) ;
7+
8+ var MergeRight = function ( obj1 , obj2 )
9+ {
10+ var clone = Clone ( obj1 ) ;
11+
12+ for ( var key in obj2 )
13+ {
14+ if ( clone . hasOwnProperty ( key ) )
15+ {
16+ clone [ key ] = obj2 [ key ] ;
17+ }
18+ }
19+
20+ return clone ;
21+ } ;
22+
23+ module . exports = MergeRight ;
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ module.exports = {
77 GetAdvancedValue : require ( './GetAdvancedValue' ) ,
88 GetMinMaxValue : require ( './GetMinMaxValue' ) ,
99 GetValue : require ( './GetValue' ) ,
10- IsPlainObject : require ( './IsPlainObject' )
10+ IsPlainObject : require ( './IsPlainObject' ) ,
11+ Merge : require ( './Merge' ) ,
12+ MergeRight : require ( './MergeRight' )
1113
1214} ;
You can’t perform that action at this time.
0 commit comments