micktaiwan/meteor-vermongo

Uncaught TypeError: fieldNames.diff(...).equals is not a function(anonymous function) @ vermongo.js:56

sailesh opened this issue · 1 comments

Hello Mick,

Similar issue to #1
Array.prototype.equals is not defined in the package level. You should already have it in your project level. I defined it as below from http://stackoverflow.com/questions/7837456/comparing-two-arrays-in-javascript/14853974#14853974

Regards

//attach the .equals method to Array's prototype to call it on any array
if (!Array.prototype.equals) {
  Array.prototype.equals = function (array) {
    // if the other array is a falsy value, return
    if (!array)
      return false;

    // compare lengths - can save a lot of time
    if (this.length != array.length)
      return false;

    for (var i = 0, l = this.length; i < l; i++) {
      // Check if we have nested arrays
      if (this[i] instanceof Array && array[i] instanceof Array) {
        // recurse into the nested arrays
        if (!this[i].equals(array[i]))
          return false;
      }
      else if (this[i] != array[i]) {
        // Warning - two different object instances will never be equal: {x:20} != {x:20}
        return false;
      }
    }
    return true;
  }
}

Thank you very much @sailesh
I was using the exact same method in my project.
It is urgent that I implement some unit tests :)
New version published on atmosphere.