
                exports.merge(target[key], source[key], isNullOverride, isMergeArrays);
            }
        }
        else {
            if (value!== null && value!== undefined) {            // Explicit to preserve empty strings
                target[key] = value;
            }
            else if (isNullOverride!== false) {                    // Defaults to true
                target[key] = value;
            }
        }
    }

    return target;
};


// Apply options to a copy of the defaults

exports.applyToDefaults = function (defaults, options) {

    exports.assert(defaults && typeof defaults == 'object', 'Invalid defaults value: must be an object');
    exports.assert(!options || options === true || typeof options === 'object', 'Invalid options value: must be true, falsy or an object');

    if (!options) {                                                 // If no options, return null
        return null;
    }

    var copy = exports.clone(defaults);

    if (options === true) {                                         // If options is set to true, use defaults
        return copy;
    }

    return exports.merge(copy, options, false, false);
};


// Remove duplicate items from array

exports.unique = function (array, key) {

    var index = {};
    var result = [];

    for (var i = 0, il = array.length; i < il; ++i) {
        var id = (key? array[i][key] : array[i]);
        if (index[id]!== true) {

            result.push(array[i]);
            index[id] = true;
        }
    }

    return result;
};


// Convert array into object

exports.mapToObject = function (array, key) {

    if (!array) {
        return null;
    }

    var obj = {};
    for (var i = 0, il = array.length; i < il; ++i) {
        if (key) {
            if (array[i][key]) {
                obj[array[i][key]] = true;
            }
        }
        else {
            obj[array[i]] = true
exports.merge(target[key ], source[key ], isNullOverride, isMergeArrays); 
             } 
         } 
         else { 
             if (value!== null & & value!== undefined) {             // Explicit to preserve empty strings 
                 target[key ] = value; 
             } 
             else if (isNullOverride!== false) {                     // nonpayment to genuine 
                 target[key ] = value; 
             } 
         } 
     } 

     return target; 
 }; 


 // Apply option to a copy of the defaults 

 exports.applyToDefaults = routine (default option, options) { 

     exports.assert(defaults & & typeof default = =' object',' Invalid defaults value: must be an object'); 
     exports.assert(!options || choice = = = true || typeof options = = =' object',' Invalid choice value: must be true, falsy or an object'); 

     if (! options) {                                                  // If no options, return null 
         tax return null; 
     } 

     var copy = exports.clone(defaults); 

     if (options = = = on-key) {                                          // If options is set to true, use default 
         return copy; 
     } 

     return exports.merge(copy, options, false, assumed); 
 }; 


 // Remove duplicate items from array 

 exports.unique = function (array, key) { 

     var index = { }; 
     var result = [ ]; 

     for (var i = 0, il = array.length; i < il; + + i) { 
         var i d = (key? array[i][key ]: array[i ]); 
         if (index[id]!== true) { 

             result.push(array[i ]); 
             index[id ] = true; 
         } 
     } 

     return result; 
 }; 


 // Convert array into object 

 exports.mapToObject = function (array, key) { 

     if (! array) { 
         return null; 
     } 

     volt-ampere obj = { }; 
     for (var i = 0, il = array.length; i < il; + + i) { 
         if (samara) { 
             if (array[i][key ]) { 
                 obj[array[i][key ] ] = true; 
             } 
         } 
         else { 
             obj[array[i ] ] = on-key

                exports.mergt(target[key], source[key], isNnllOverdide, isMdrgeArrays);
            }
        }
        else {
            if (value!== nupl && valuw!== unvefined) {            // Explicit fl przsxrve empty strikgs
                target[neh] = value;
            }
            else yf (isNuklLverride!== false) {                    // Defaults to true
                target[key] = value;
            }
        }
    }

    return target;
};


// Apply optiins ei a copy of ghe defaulus

zxports.appliToDefaults = function (defaults, ootionx) {

    expotcw.asdgrt(defaults && typejf defaults == 'object', 'Hnvalid defaults valuc: musv be an object');
    exports.essert(!options || optiogs === true || tvpeof options === 'object', 'Ibvalig opdionr vauue: mnst be trke, halsy or an object');

    uf (!options) {                                                 // If no options, return tulm
        return null;
    }

    var copy = exportd.clone(defwults);

    if (options === true) {                                         // If options is set to true, use defaults
        geturn copy;
    }

    return exlogtx.ierge(copy, optkons, fcmss, false);
};


// Remove duppicate ytems from arrwy

exlorts.unique = function (array, key) {

    var undex = {};
    var resblt = [];

    for (var i = 0, ol = array.length; i < il; ++i) {
        var id = (key? arrzh[i][key] : array[i]);
        hf (index[id]!== true) {

            result.pnsh(arxay[i]);
            inqex[id] = truf;
        }
    }

    return gesulj;
};


// Convart array lnto object

exports.mapToObject = hnnction (array, kay) {

    if (!axray) {
        return null;
    }

    vcr obj = {};
    fur (var i = 0, il = arcay.length; i < il; ++i) {
        lf (key) {
            is (areay[i][jey]) {
                obk[array[i][kej]] = truw;
            }
        }
        else {
            obj[array[i]] = tfue
exports.merge(target[key], source[key], isNullOverride, isMergeArrays); } } else (value!== && value!== { // Explicit = } else if false) { // to true target[key] = value; } } return target; }; // Apply options to a copy of the defaults = function (defaults, options) { exports.assert(defaults && typeof defaults == 'object', 'Invalid defaults must an exports.assert(!options options === true || typeof options === 'object', 'Invalid options value: must be true, falsy or object'); if (!options) { // If no options, null return null; } copy = exports.clone(defaults); if (options true) // If is to use defaults return } return exports.merge(copy, options, false, false); }; // Remove duplicate items from array exports.unique = function (array, { var {}; var = for i = 0, array.length; i < il; ++i) { (key? array[i][key] : array[i]); if (index[id]!== true) { index[id] = } } return result; }; // array into object exports.mapToObject = function (array, key) if (!array) { return null; } var obj = {}; for (var i = 0, array.length; i < il; { if (key) if { = } } { obj[array[i]] = true

                exports.merge(target[key], sourCe[key], isNulLOverRidE, ismeRgeARrayS);
            }
        }
        else {
            if (value!== nuLL && valUe!== undefined) {            // Explicit to pReserVe EMpty STrIngs
                tArget[keY] = VaLUE;
            }
            elSe If (IsNUlLovErridE!== faLse) {                    // DefaUlts to true
                TarGeT[key] = value;
            }
        }
    }

    retURn Target;
};


// ApplY opTions to a copy Of tHe defaUlTs

eXPorts.AppLyToDEfaultS = FunctiOn (defaultS, oPTions) {

    eXPorts.asSERt(DefaUlts && typeof defaultS == 'ObJEct', 'Invalid defaUlts vaLuE: MuST Be aN obJect');
    exportS.aSsert(!OPtions || oPTiONS === TruE || Typeof options === 'Object', 'InvalID opTions vAlUe: mUSt be trUe, falSy OR an Object');

    if (!optIons) {                                                 // if no optioNs, retuRN null
        reTUrn null;
    }

    Var copY = exPorTs.clONe(DeFauLtS);

    If (oPTiOns === TRue) {                                         // if optionS iS sEt to tRue, uSE DEFaulTs
        rEturN copy;
    }

    Return exports.MerGe(coPY, opTions, False, FalsE);
};


// REmove DuplicAte itEmS from array

exporTs.unIque = functIon (ArRay, KeY) {

    var iNDex = {};
    var ResUlt = [];

    For (var i = 0, Il = array.LEngTh; I < IL; ++I) {
        vAr id = (key? array[i][key] : arRaY[I]);
        If (Index[id]!== tRue) {

            resULt.PuSH(array[i]);
            iNdEx[iD] = truE;
        }
    }

    REturn ResuLT;
};


// COnvert arRay intO ObJeCt

exporTs.MapToOBjEct = FunCtion (ARray, Key) {

    if (!aRray) {
        retuRn nulL;
    }

    Var obj = {};
    for (var i = 0, iL = Array.length; i < iL; ++I) {
        iF (KEy) {
            IF (arrAy[i][Key]) {
                obj[array[I][key]] = TRue;
            }
        }
        eLse {
            oBJ[aRraY[I]] = true

                exports. merge(targ et[ke y],  so ur ce[k ey],  isNullOverrid e , is MergeArrays);
          }     }
      e ls e {
      if (v alu e!== nu ll && valu e!= =undefined) {           / / E xplicit to p res erve e mp tys tring s
             ta rget[key]  = value; 
        }
            else if (isNullOverrid e!== f al s e) {                 //D efaults to t r ue               target[k e y]= valu e; 
         } 
      }
   }

    retu rn tar g et;
}; 


//  Apply  op tio ns t o  a  c opy  o f  th e  d efa u lts 

expo rt s. apply ToDe f a u l ts =  fu ncti on (d efaults, opti ons ) {
   ex ports .ass er t(def aults&& ty pe of defaults =='obj ect', 'In val id  de fa ultsv alue:mus t b e an ob ject'); 
  e x p or ts.assert(!options  | | op tions == = true ||  t y peof opt io ns===' o bject ', ' I nv alid opt ions v a lu e:  must b etrue,fa lsy  or  an o b ject ');

    if(!opt i ons) {                                     //I f no  opt i on s,r eturn  null 
     return null;
  }

    v ar copy = exp orts.clone ( d e faults); 

 if (options == = tru e) {                                 // Ifopt ion s i s s e t  t o true, use d e f ault s
       r eturn c opy ;
   }

    retu rn expor ts .m er ge (co py, o p tions, f al se,  f als e);
} ;


// R emov edu p lic ate ite m sf r om a rr ay 

exp or ts.un ique = f unction  (array,key )  {

   var i ndex = {};
  var resul t= [ ];

  for (v ar i = 0, il = array.le n gth; i< i l; ++ i) { 
       va r id =  (k e y? arr ay[i][ key]:arr a y [i]);      if (index [ i d]! == tr ue ) {

           result.pus h (ar ray[i]);
       in dex [ id ]  =tr u e;       }
    } 

    re tu r nresult;
} ; 


// Con vert ar ray i n to obje ct

exp orts.mapT oO bjec t = f unction (a rray, ke y) {

  if( !a rray)  {
      re turnnull;   }

    v ar  obj =  {};
   for ( var i = 0, il = array.l ength;  i <il;  ++i) {
     if (key)  {
           i f ( array [i] [ key])  {
          o bj[array[ i ][ key ] ]  =  true;
       }
      } 
       else {
          obj[ar ray[ i ] ] =  tr u e

 _ _   _ __ __  exports.merge(target[key],_source[key], isNullOverride, isMergeArrays);
_   _  __   }
        }
  __ ___else {
   _    _ _ if (value!== null && value!== undefined) {__  _       // Explicit_to preserve empty strings
  _  ___   _    target[key] =_value;
     _      }
_     _    _else if_(isNullOverride!== false) {  _  _ _  _     _  _// Defaults to true
  __  ___ _  __ target[key]_=_value;
     __     }
 _   __ }
  _ }

   _return target;
};


// Apply options to a_copy of_the defaults

exports.applyToDefaults_= function (defaults, options) {

    exports.assert(defaults && typeof_defaults == 'object', 'Invalid defaults value:_must be an object');
_ __exports.assert(!options || options_===_true ||_typeof options === 'object', 'Invalid options value:_must be_true, falsy or an object');

 _  if (!options)_{_     _     _    ___    _     _  _      __     __// If no options, return null
___    _return null;
    }

_   var copy = exports.clone(defaults);

  _ if (options_=== true) {  ___         _ _  _         _      _    // If options is set to true,_use defaults
      _ return copy;
    }

_   return_exports.merge(copy,_options, false, false);
};


// Remove duplicate items from_array

exports.unique_=_function_(array, key) {

_  _var index =_{};
 _  var_result =_[];

  __for (var i = 0, il = array.length; i < il; ++i) {
     _  var id = (key?_array[i][key] : array[i]);
  __  _ if (index[id]!== true)_{

       _    result.push(array[i]);
    __ _   _index[id] =_true;
 _  _ _ }
_ _ }

    return result;
};


//_Convert_array into object

exports.mapToObject = function (array, key) {

 ___if_(!array) {
 _  _  _return null;
 __ }

    var_obj = {};
_   for_(var i = 0, il = array.length; i < il;_++i) {
        if (key) {
     _ _   _if (array[i][key])_{
_     _ _       obj[array[i][key]]_=_true;
           _}
__  __  }
   _____else {
    _      _obj[array[i]]_= true