was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 5  →  ?path2? @ 6
/tags/1.0.0/dist/was.js
@@ -12,7 +12,7 @@
var o = {};
o[a[i]] = b[i];
return o;
});
});
};
}
$.extend({
@@ -23,7 +23,7 @@
var o = {};
o[a[i]] = b[i];
return o;
});
});
}
});
 
@@ -67,6 +67,68 @@
}
});
 
/*************************************************************************/
/* 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;
}
});
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/tags/1.0.0/dist/was.min.js
@@ -1,4 +1,4 @@
/*! was - v1.0.0 - 2017-05-28
* http://grimore.org
* Copyright (c) 2017 Wizardry and Steamworks <office@grimore.org>; Licensed GPL-3.0 */
function wasCSVToArray(a){var b=[],c=[],d="";do{var e=a.charAt(0);if(a=a.slice(1,a.length),","!==e)if('"'!==e||a.charAt(0)!==e)if('"'!==e)d+=e;else{if(c[c.length-1]!==e){c.push(e);continue}c.pop()}else d+=e,a=a.slice(1,a.length);else{if('"'!==c[c.length-1]){b.push(d),d="";continue}d+=e}}while(""!==a);return b.push(d),b}function wasArrayToCSV(a){for(var b=[],c=0;c<a.length;++c){var d=a[c].toString().replace('"','""');/"\s,\r\n/.test(d)?b[c]='"'+d+'"':b[c]=d}return b.join()}Array.prototype.product||(Array.prototype.product=function(a){var b=this;return $.map(new Array(Math.max(this.length,b.length)),function(c,d){var e={};return e[b[d]]=a[d],e})}),$.extend({product:function(a,b){return $.map(new Array(Math.max(this.length,a.length)),function(c,d){var e={};return e[a[d]]=b[d],e})}}),Array.prototype.stride||(Array.prototype.stride=function(a){return this.filter(function(b,c){return c%a==0})}),$.extend({stride:function(a,b){return a.filter(function(a,c){return c%b==0})}}),Array.prototype.chunk||(Array.prototype.chunk=function(a){return this.length?[this.slice(0,a)].concat(this.slice(a).chunk(a)):[]}),$.extend({chunk:function(a,b){return a.length?[a.slice(0,b)].concat(a.slice(b).chunk(b)):[]}});
function wasCSVToArray(a){var b=[],c=[],d="";do{var e=a.charAt(0);if(a=a.slice(1,a.length),","!==e)if('"'!==e||a.charAt(0)!==e)if('"'!==e)d+=e;else{if(c[c.length-1]!==e){c.push(e);continue}c.pop()}else d+=e,a=a.slice(1,a.length);else{if('"'!==c[c.length-1]){b.push(d),d="";continue}d+=e}}while(""!==a);return b.push(d),b}function wasArrayToCSV(a){for(var b=[],c=0;c<a.length;++c){var d=a[c].toString().replace('"','""');/"\s,\r\n/.test(d)?b[c]='"'+d+'"':b[c]=d}return b.join()}Array.prototype.product||(Array.prototype.product=function(a){var b=this;return $.map(new Array(Math.max(this.length,b.length)),function(c,d){var e={};return e[b[d]]=a[d],e})}),$.extend({product:function(a,b){return $.map(new Array(Math.max(this.length,a.length)),function(c,d){var e={};return e[a[d]]=b[d],e})}}),Array.prototype.stride||(Array.prototype.stride=function(a){return this.filter(function(b,c){return c%a==0})}),$.extend({stride:function(a,b){return a.filter(function(a,c){return c%b==0})}}),Array.prototype.chunk||(Array.prototype.chunk=function(a){return this.length?[this.slice(0,a)].concat(this.slice(a).chunk(a)):[]}),$.extend({chunk:function(a,b){return a.length?[a.slice(0,b)].concat(a.slice(b).chunk(b)):[]}}),Array.prototype.equals||(Array.prototype.equals=function(a){if(!a)return!1;if(this.length!==a.length)return!1;for(var b=0,c=this.length;b<c;b++)if(this[b]instanceof Array&&a[b]instanceof Array){if(!this[b].equals(a[b]))return!1}else if(this[b]!==a[b])return!1;return!0}),$.extend({equals:function(a){if(!a)return!1;if(this.length!==a.length)return!1;for(var b=0,c=this.length;b<c;b++)if(this[b]instanceof Array&&a[b]instanceof Array){if(!this[b].equals(a[b]))return!1}else if(this[b]!==a[b])return!1;return!0}});
/tags/1.0.0/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;
}
});