validation.js
// merging of nested arrays doesn't work, but we don't need it here
merging of nested arrays doesn't work, but we don't need it here
merging of nested arrays doesn ' t work but we don ' t need it here
function deepMerge (object1, object2) {
  assert.ok(object1);
  assert.ok(object2);
  var result = new Object();
  function _merge (object, another) {
    for (property in object) {
      var value = object[property];
      if (value !== null && value !== undefined) {
        if (value.__proto__.constructor == Array) {
          result[property] = value.slice(0);
          if (another[property] && another[property].__proto__.constructor == Array) {
            another[property].forEach(function (item) {
              if (result[property].indexOf(item) === -1) {
                result[property].push(item);
              };
            });
          };
        } else if (typeof value == "object") {
          result[property] = deepMerge(value, another[property] || {});
        } else {
          result[property] = value;
        };
      };
    }
  };
  _merge(object1, object2);
  _merge(object2, object1);
  return result;
}
function deepMerge ( object1 , object2 ) { assert . ok ( object1 ) ; assert . ok ( object2 ) ; var result = new Object ( ) ; function _merge ( object , another ) { for ( property in object ) { var value = object [ property ] ; if ( value !== null && value !== undefined ) { if ( value . __proto__ . constructor == Array ) { result [ property ] = value . slice ( 0 ) ; if ( another [ property ] && another [ property ] . __proto__ . constructor == Array ) { another [ property ] . forEach ( function ( item ) { if ( result [ property ] . indexOf ( item ) === - 1 ) { result [ property ] . push ( item ) ; } ; } ) ; } ; } else if ( typeof value == "object" ) { result [ property ] = deepMerge ( value , another [ property ] || { } ) ; } else { result [ property ] = value ; } ; } ; } } ; _merge ( object1 , object2 ) ; _merge ( object2 , object1 ) ; return result ; }
merging of nested arrays doesn't work, but we don't need it here
merging of nested arrays doesn ' t work but we don ' t need it here
// copy the first array // copy the second object if it exists and if it's an array // don't push the item into array if the array already // includes this item. E.g.: ["wtf"].push("wtf") => ["wtf"]