spec/SpecHelpers.js
function objectSignaturesMatch(object1, object2){

    // because typeof null is object we need to check for it here before Object.keys
    if(object1 === null && object2 === null){
      return true;
    }

    // if the objects have different lengths of keys we should fail immediatly
    if (Object.keys(object1).length !== Object.keys(object2).length) {
      return false;
    }

    // loop over all the keys in object1 (we know the objects have the same number of keys at this point)
    for(var key in object1) {

      // if the keys match keep checking if not we have a mismatch
      if(typeof object1[key] === typeof object2[key]) {

        if(typeof object1[key] === null && typeof object2[key] === null) {

        }

        // if the keys represent an object make sure that it matches.
        else if(object1[key] instanceof Array && object2[key] instanceof Array) {
          if(!arrySignaturesMatch(object1[key],object2[key])){
            return false;
          }
        }

        // if the keys represent an array make sure it matches
        else if(typeof object1[key] === "object" && typeof object2[key] === "object") {
          if(!objectSignaturesMatch(object1[key],object2[key])){
            return false;
          }
        }

      }
    }
    return true;
  }
function objectSignaturesMatch(object1, object2){

    // because typeof null is object we need to check for it here before Object.keys
    if(object1 === null && object2 === null){
      return true;
    }

    // if the objects have different lengths of keys we should fail immediatly
    if (Object.keys(object1).length !== Object.keys(object2).length) {
      return false;
    }

    // loop over all the keys in object1 (we know the objects have the same number of keys at this point)
    for(var key in object1) {

      // if the keys match keep checking if not we have a mismatch
      if(typeof object1[key] === typeof object2[key]) {

        if(typeof object1[key] === null && typeof object2[key] === null) {

        }

        // if the keys represent an object make sure that it matches.
        else if(object1[key] instanceof Array && object2[key] instanceof Array) {
          if(!arrySignaturesMatch(object1[key],object2[key])){
            return false;
          }
        }

        // if the keys represent an array make sure it matches
        else if(typeof object1[key] === "object" && typeof object2[key] === "object") {
          if(!objectSignaturesMatch(object1[key],object2[key])){
            return false;
          }
        }

      }
    }
    return true;
  }
function objectSignaturesMatch ( object1 , object2 ) { // because typeof null is object we need to check for it here before Object.keys if ( object1 === null && object2 === null ) { return true ; } // if the objects have different lengths of keys we should fail immediatly if ( Object . keys ( object1 ) . length !== Object . keys ( object2 ) . length ) { return false ; } // loop over all the keys in object1 (we know the objects have the same number of keys at this point) for ( var key in object1 ) { // if the keys match keep checking if not we have a mismatch if ( typeof object1 [ key ] === typeof object2 [ key ] ) { if ( typeof object1 [ key ] === null && typeof object2 [ key ] === null ) { } // if the keys represent an object make sure that it matches. else if ( object1 [ key ] instanceof Array && object2 [ key ] instanceof Array ) { if ( ! arrySignaturesMatch ( object1 [ key ] , object2 [ key ] ) ) { return false ; } } // if the keys represent an array make sure it matches else if ( typeof object1 [ key ] === "object" && typeof object2 [ key ] === "object" ) { if ( ! objectSignaturesMatch ( object1 [ key ] , object2 [ key ] ) ) { return false ; } } } } return true ; }
do the keys in object 1 match object 2?
do the keys in object 1 match object 2?