@ -126,6 +126,8 @@ exports.fillIfDefined = function (a, b, allowDeletion = false) {
}
}
}
}
/ * *
/ * *
* Extend object a with the properties of object b or a series of objects
* Extend object a with the properties of object b or a series of objects
* Only properties with defined values are copied
* Only properties with defined values are copied
@ -214,7 +216,7 @@ exports.selectiveDeepExtend = function (props, a, b, allowDeletion = false) {
exports . deepExtend ( a [ prop ] , b [ prop ] , false , allowDeletion ) ;
exports . deepExtend ( a [ prop ] , b [ prop ] , false , allowDeletion ) ;
}
}
else {
else {
if ( ( b [ prop ] === undefined || b [ prop ] === null ) && a [ prop ] !== undefined && allowDeletion === true ) {
if ( ( b [ prop ] === null ) && a [ prop ] !== undefined && allowDeletion === true ) {
delete a [ prop ] ;
delete a [ prop ] ;
}
}
else {
else {
@ -257,7 +259,7 @@ exports.selectiveNotDeepExtend = function (props, a, b, allowDeletion = false) {
exports . deepExtend ( a [ prop ] , b [ prop ] ) ;
exports . deepExtend ( a [ prop ] , b [ prop ] ) ;
}
}
else {
else {
if ( ( b [ prop ] === undefined || b [ prop ] === null ) && a [ prop ] !== undefined && allowDeletion === true ) {
if ( ( b [ prop ] === null ) && a [ prop ] !== undefined && allowDeletion === true ) {
delete a [ prop ] ;
delete a [ prop ] ;
}
}
else {
else {
@ -281,7 +283,7 @@ exports.selectiveNotDeepExtend = function (props, a, b, allowDeletion = false) {
* @ param { Object } b
* @ param { Object } b
* @ param [ Boolean ] protoExtend -- > optional parameter . If true , the prototype values will also be extended .
* @ param [ Boolean ] protoExtend -- > optional parameter . If true , the prototype values will also be extended .
* ( ie . the options objects that inherit from others will also get the inherited options )
* ( ie . the options objects that inherit from others will also get the inherited options )
* @ param [ Boolean ] global -- > optional parameter . If true , the values of fields that are undefined or null will not deleted
* @ param [ Boolean ] global -- > optional parameter . If true , the values of fields that are null will not deleted
* @ returns { Object }
* @ returns { Object }
* /
* /
exports . deepExtend = function ( a , b , protoExtend , allowDeletion ) {
exports . deepExtend = function ( a , b , protoExtend , allowDeletion ) {
@ -295,7 +297,7 @@ exports.deepExtend = function(a, b, protoExtend, allowDeletion) {
exports . deepExtend ( a [ prop ] , b [ prop ] , protoExtend ) ;
exports . deepExtend ( a [ prop ] , b [ prop ] , protoExtend ) ;
}
}
else {
else {
if ( ( b [ prop ] === undefined || b [ prop ] === null ) && a [ prop ] !== undefined && allowDeletion === true ) {
if ( ( b [ prop ] === null ) && a [ prop ] !== undefined && allowDeletion === true ) {
delete a [ prop ] ;
delete a [ prop ] ;
}
}
else {
else {
@ -1209,16 +1211,22 @@ exports.bridgeObject = function(referenceObject) {
* @ param [ String ] option | this is the option key in the options argument
* @ param [ String ] option | this is the option key in the options argument
* @ private
* @ private
* /
* /
exports . mergeOptions = function ( mergeTarget , options , option ) {
if ( options [ option ] !== undefined ) {
if ( typeof options [ option ] == 'boolean' ) {
mergeTarget [ option ] . enabled = options [ option ] ;
}
else {
mergeTarget [ option ] . enabled = true ;
for ( var prop in options [ option ] ) {
if ( options [ option ] . hasOwnProperty ( prop ) ) {
mergeTarget [ option ] [ prop ] = options [ option ] [ prop ] ;
exports . mergeOptions = function ( mergeTarget , options , option , allowDeletion = false ) {
if ( options [ option ] === null ) {
mergeTarget [ option ] = undefined ;
delete mergeTarget [ option ] ;
}
else {
if ( options [ option ] !== undefined ) {
if ( typeof options [ option ] == 'boolean' ) {
mergeTarget [ option ] . enabled = options [ option ] ;
}
else {
mergeTarget [ option ] . enabled = true ;
for ( var prop in options [ option ] ) {
if ( options [ option ] . hasOwnProperty ( prop ) ) {
mergeTarget [ option ] [ prop ] = options [ option ] [ prop ] ;
}
}
}
}
}
}
}