diff --git a/ogx.list.min.js b/ogx.list.min.js index 967c216..f6c715a 100644 --- a/ogx.list.min.js +++ b/ogx.list.min.js @@ -1 +1 @@ -if(typeof OGX==="undefined"){var OGX={}}OGX.List=function(){if(typeof moment==="undefined"){console.log("Error: moment.js not found!");return}if(typeof debug==="undefined"){debug=function(){}}var filteringMode="and";var filterCount=0;var indexes=false;if(arguments.length===1&&arguments[0]instanceof Array){arguments=arguments[0]}var array=Object.create(Array.prototype);array=Array.apply(array,arguments)||array;for(var method in OGX.List.prototype){if(OGX.List.prototype.hasOwnProperty(method)){array[method]=OGX.List.prototype[method]}}array.insert=function(e,t){if(typeof t==="undefined"){array.push(e)}else{array.splice(t,0,e)}if(indexes){addToCache(e)}return true};array.delete=function(e){var t=this;var i=array.splice(e,1);if(i.length){if(indexes){var r=matchesCache(i[0]);if(r){setTimeout(()=>{t.rebuild(r)},0)}}return i[0]}return false};array.last=function(){if(this.length){return this[this.length-1]}return};array.findDelete=function(__property,__value,__limit){var t=0;if(typeof __limit==="undefined"){__limit=0}var removed=new OGX.List;var ev,prop;for(var i=0;i0&&__limit===t){if(__limit===1){return removed[0]}else{return removed}}i--}}}return removed};array.findReplace=function(__property,__value,__object,__limit){var t=0;if(typeof __limit==="undefined"){__limit=0}var replaced=new OGX.List;var ev,prop;for(var i=0;i0&&__limit===t){if(__limit===1){return replaced[0]}else{return replaced}}}}}if(!replaced.length){return false}else{return replaced}};array.findUpdate=function(__property,__value,__object,__strict,__limit){var t=0;if(typeof __strict==="undefined"){__strict=false}if(typeof __limit==="undefined"){__limit=0}var updated=new OGX.List;var upd,ev,prop;for(var i=0;i0&&__limit===t){if(__limit===1){return updated[0]}else{return updated}}}}}}if(!updated.length){return false}else{return updated}};array.findIndex=function(__property,__value){var isReg=false;if(__value instanceof RegExp){isReg=true}var ev,prop;for(var i=0;i0&&r===i){if(i===1){return a[0]}else{return a}}}if(!a.length){return false}else{return a}};array.swap=function(e,t){var i=this[e];this[e]=this[t];this[t]=i};array.cache=function(){if(!indexes){indexes={}}var e=[];var t=[];var i;if(arguments.length>1){for(var r=0;r1){t=arguments.join("|")}if(indexes.hasOwnProperty(t)){delete indexes[t];return true}return false};array.deleteProperty=function(e){var t=0;for(var i=0;i1){return indexes[a][s].splice(0,i)}else{return indexes[a][s][0]}}return indexes[a][s]}return false};array.clear=function(){indexes=false;filterCount=0;this.length=0};array.unique=function(__prop,__as_object,__new_props){if(typeof __as_object==="undefined"){__as_object=true}if(typeof __new_props==="undefined"){__new_props=[__prop]}else{if(!Array.isArray(__new_props)){__new_props=[__new_props]}}var q={};q[__prop]={regex:/(.){1,}/};var l=this.get();var ar=[];var final=new OGX.List;var o;var ev;for(var i=0;ieval("b."+__prop)?__way:0}}array.group=function(e,t,i){if(Array.isArray(e)){return array.groupm(e,t,i)}var r;var a={};for(var s=0;s{that.rebuild(affected_indexes)},0)}return filtered}}return[]};array.filter=function(__limit,__as_position){if(typeof __limit==="undefined"){__limit=0}if(typeof __as_position==="undefined"){__as_position=false}var ar=[];var positions=[];var isDate,isString,isNum,isArray,isObject;var hasFilters=false;var reg=/[0-9]{4}\-[0-9]{2}\-[0-9]{2}( [0-9]{2}\:[0-9]{2}\:[0-9]{2})?/g;var isMatch=false;var matches=0;var str,o,err;var counter,total;for(var i=0;i=moment(this.filters[a][j][b]).unix()){isMatch=false}else{matches++}}else{if(typeof this.filters[a][j][b]!=="number"){isMatch=false;break}if(o>=this.filters[a][j][b]){isMatch=false}else{matches++}}break;case"lte":if(isDate){if(typeof this.filters[a][j][b]!=="string"||!this.filters[a][j][b].match(reg)){isMatch=false;break}if(moment(o).unix()>moment(this.filters[a][j][b]).unix()){isMatch=false}else{matches++}}else{if(typeof this.filters[a][j][b]!=="number"){isMatch=false;break}if(o>this.filters[a][j][b]){isMatch=false}else{matches++}}break;case"btw":if(isDate){if(typeof this.filters[a][j][b]!=="string"||!this.filters[a][j][b].match(reg)){isMatch=false;break}if(moment(this.filters[a][j][b][0]).unix()>moment(o).unix()||moment(this.filters[a][j][b][1]).unix()o||this.filters[a][j][b][1]{t.rebuild(r)},0)}}return i[0]}return false};array.last=function(){if(this.length){return this[this.length-1]}return};array.findDelete=function(__property,__value,__limit){var t=0;if(typeof __limit==="undefined"){__limit=0}var removed=new OGX.List;var ev,prop;for(var i=0;i0&&__limit===t){if(__limit===1){return removed[0]}else{return removed}}i--}}}return removed};array.findReplace=function(__property,__value,__object,__limit){var t=0;if(typeof __limit==="undefined"){__limit=0}var replaced=new OGX.List;var ev,prop;for(var i=0;i0&&__limit===t){if(__limit===1){return replaced[0]}else{return replaced}}}}}if(!replaced.length){return false}else{return replaced}};array.findUpdate=function(__property,__value,__object,__strict,__limit){var t=0;if(typeof __strict==="undefined"){__strict=false}if(typeof __limit==="undefined"){__limit=0}var updated=new OGX.List;var upd,ev,prop;for(var i=0;i0&&__limit===t){if(__limit===1){return updated[0]}else{return updated}}}}}}if(!updated.length){return false}else{return updated}};array.findIndex=function(__property,__value){var isReg=false;if(__value instanceof RegExp){isReg=true}var ev,prop;for(var i=0;i0&&r===i){if(i===1){return a[0]}else{return a}}}if(!a.length){return false}else{return a}};array.swap=function(e,t){var i=this[e];this[e]=this[t];this[t]=i};array.cache=function(){if(!indexes){indexes={}}var e=[];var t=[];var i;if(arguments.length>1){for(var r=0;r1){t=arguments.join("|")}if(indexes.hasOwnProperty(t)){delete indexes[t];return true}return false};array.deleteProperty=function(e){var t=0;for(var i=0;i1){return indexes[a][s].splice(0,i)}else{return indexes[a][s][0]}}return indexes[a][s]}return false};array.clear=function(){indexes=false;filterCount=0;this.length=0};array.unique=function(__prop,__as_object,__new_props){if(typeof __as_object==="undefined"){__as_object=true}if(typeof __new_props==="undefined"){__new_props=[__prop]}else{if(!Array.isArray(__new_props)){__new_props=[__new_props]}}var q={};q[__prop]={regex:/(.){1,}/};var l=this.get();var ar=[];var final=new OGX.List;var o;var ev;for(var i=0;ieval("b."+__prop)?__way:0}}array.group=function(e,t,i){if(Array.isArray(e)){return array.groupm(e,t,i)}var r;var a={};for(var s=0;s{that.rebuild(affected_indexes)},0)}return filtered}}return[]};array.filter=function(__limit,__as_position){if(typeof __limit==="undefined"){__limit=0}if(typeof __as_position==="undefined"){__as_position=false}var ar=[];var positions=[];var isDate,isString,isNum,isArray,isObject;var hasFilters=false;var reg=/[0-9]{4}\-[0-9]{2}\-[0-9]{2}( [0-9]{2}\:[0-9]{2}\:[0-9]{2})?/g;var isMatch=false;var matches=0;var str,o,err;var counter,total;for(var i=0;i=moment(this.filters[a][j][b]).unix()){isMatch=false}else{matches++}}else{if(typeof this.filters[a][j][b]!=="number"){isMatch=false;break}if(o>=this.filters[a][j][b]){isMatch=false}else{matches++}}break;case"lte":if(isDate){if(typeof this.filters[a][j][b]!=="string"||!this.filters[a][j][b].match(reg)){isMatch=false;break}if(moment(o).unix()>moment(this.filters[a][j][b]).unix()){isMatch=false}else{matches++}}else{if(typeof this.filters[a][j][b]!=="number"){isMatch=false;break}if(o>this.filters[a][j][b]){isMatch=false}else{matches++}}break;case"btw":if(isDate){if(typeof this.filters[a][j][b]!=="string"||!this.filters[a][j][b].match(reg)){isMatch=false;break}if(moment(this.filters[a][j][b][0]).unix()>moment(o).unix()||moment(this.filters[a][j][b][1]).unix()o||this.filters[a][j][b][1]