Skip to content

Commit

Permalink
use if statement instead of filtering, #73
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 11, 2019
1 parent 91bb985 commit dfee7f3
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions js/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,24 @@ define( require => {
validateMergableObject( target );
assert && assert( sources.length > 0, 'at least one source expected' );

// Support optional args by filtering out any source that is undefined. Don't support this in the target though.
const ignoreUndefined = _.filter( sources, source => source !== undefined );
_.each( sources, source => {
if ( source !== undefined ) {
validateMergableObject( source );
for ( const property in source ) {
if ( source.hasOwnProperty( property ) ) {
const sourceProperty = source[ property ];

_.each( ignoreUndefined, source => {
validateMergableObject( source );
for ( const property in source ) {
if ( source.hasOwnProperty( property ) ) {
const sourceProperty = source[ property ];
// don't support recursing on the key "Options" with no prefix
if ( _.endsWith( property, OPTIONS_SUFFIX ) && property !== OPTIONS_SUFFIX ) {

// don't support recursing on the key "Options" with no prefix
if ( _.endsWith( property, OPTIONS_SUFFIX ) && property !== OPTIONS_SUFFIX ) {
// ensure that the *Options property is a POJSO
validateMergableObject( sourceProperty );

// ensure that the *Options property is a POJSO
validateMergableObject( sourceProperty );

target[ property ] = merge( target[ property ] || {}, sourceProperty );
}
else {
target[ property ] = sourceProperty;
target[ property ] = merge( target[ property ] || {}, sourceProperty );
}
else {
target[ property ] = sourceProperty;
}
}
}
}
Expand Down

0 comments on commit dfee7f3

Please sign in to comment.