/base/000_base/bower_components/was/lib/collections/arrays/arrays.js |
@@ -10,7 +10,7 @@ |
var o = {}; |
o[a[i]] = b[i]; |
return o; |
}); |
}); |
}; |
} |
$.extend({ |
@@ -21,7 +21,7 @@ |
var o = {}; |
o[a[i]] = b[i]; |
return o; |
}); |
}); |
} |
}); |
|
@@ -64,3 +64,65 @@ |
.concat(a.slice(n).chunk(n)); |
} |
}); |
|
/*************************************************************************/ |
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
/*************************************************************************/ |
/*stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript*/ |
/*************************************************************************/ |
if (!Array.prototype.equals) { |
// attach the .equals method to Array's prototype to call it on any array |
Array.prototype.equals = function(a) { |
// if the other array is a falsy value, return |
if (!a) { |
return false; |
} |
|
// compare lengths - can save a lot of time |
if (this.length !== a.length) { |
return false; |
} |
|
for (var i = 0, l = this.length; i < l; i++) { |
// Check if we have nested arrays |
if (this[i] instanceof Array && a[i] instanceof Array) { |
// recurse into the nested arrays |
if (!this[i].equals(a[i])) { |
return false; |
} |
} else if (this[i] !== a[i]) { |
// Warning - two different object instances will never be equal: {x:20} != {x:20} |
return false; |
} |
} |
return true; |
}; |
} |
|
$.extend({ |
equals: function(a) { |
// if the other array is a falsy value, return |
if (!a) { |
return false; |
} |
|
// compare lengths - can save a lot of time |
if (this.length !== a.length) { |
return false; |
} |
|
for (var i = 0, l = this.length; i < l; i++) { |
// Check if we have nested arrays |
if (this[i] instanceof Array && a[i] instanceof Array) { |
// recurse into the nested arrays |
if (!this[i].equals(a[i])) { |
return false; |
} |
} else if (this[i] !== a[i]) { |
// Warning - two different object instances will never be equal: {x:20} != {x:20} |
return false; |
} |
} |
return true; |
} |
}); |