-
Notifications
You must be signed in to change notification settings - Fork 1
/
jlist-min.js
1 lines (1 loc) · 7.22 KB
/
jlist-min.js
1
var jList=function(){"use strict";function a(a,b){return a-b}function b(a,b){return b-a}function c(a){return a.replace(/([.?*+\^$\[\]\\(){}\-])/g,"\\$1")}return{listAppend:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and value must be provided"};return c=void 0===c?",":c,(""!==a?a+c:"")+b},listChangeDelims:function(a,b,d){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and new_delimiter must be provided"};d=void 0===d?",":d;var e=RegExp(c(d),"g");return a.replace(e,b)},listConcatenate:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list1 and list2 must be provided"};return c=void 0===c?",":c,a+(""!==a&&""!==b?c:"")+b},listContains:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and substring must be provided"};c=void 0===c?",":c;var d,e=a.split(c);for(d=0;e.length>d;d+=1)if(-1!==e[d].indexOf(b))return d+1;return 0},listContainsNoCase:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and substring must be provided"};return c=void 0===c?",":c,a=a.toUpperCase(),b=(b+"").toUpperCase(),this.listContains(a,b,c)},listDeleteAt:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and position must be provided"};c=void 0===c?",":c;var d=a.split(c);return b>=1&&d.length>=b?(d.splice(b-1,1),d.join(c)):a},listDifference:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list1 and list2 must be provided"};c=void 0===c?",":c;var f,g,d=a.split(c),e=b.split(c),h=d.length,i=e.length,j=[];if(""!==a)for(f=0;h>f;f+=1)g=d[f],this.listFind(b,g,c)||j.push(g);if(""!==b)for(f=0;i>f;f+=1)g=e[f],this.listFind(a,g,c)||j.push(g);return this.listRemoveDuplicates(j.join(c),c)},listFind:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and value must be provided"};c=void 0===c?",":c;var d,e=a.split(c);if(void 0!==e.indexOf)return e.indexOf(b)+1;for(d=0;e.length>d;d+=1)if(e[d]===b)return d+1;return 0},listFindNoCase:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and value must be provided"};return c=void 0===c?",":c,a=a.toUpperCase(),b=(b+"").toUpperCase(),this.listFind(a,b,c)},listFirst:function(a,b){if(void 0===a)throw{name:"Error",message:"Missing parameter: list must be provided"};return b=void 0===b?",":b,this.listGetAt(a,1,b)},listGetAt:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and position must be provided"};c=void 0===c?",":c;var d=a.split(c);return b>=1&&d.length>=b?d[b-1]:""},listInsertAt:function(a,b,c,d){if(void 0===a||void 0===b||void 0===c)throw{name:"Error",message:"Missing parameter: list, position and value must be provided"};if(d=void 0===d?",":d,""===a)return 1===b?c:"";var e=a.split(d);return b>=1&&e.length>=b?(e.splice(b-1,0,c),e.join(d)):a},listIntersection:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list1 and list2 must be provided"};c=void 0===c?",":c;var e,f,d=a.split(c),g=d.length,h=[];for(e=0;g>e;e+=1)f=d[e],this.listFind(b,f,c)&&h.push(f);return this.listRemoveDuplicates(h.join(c),c)},listLast:function(a,b){if(void 0===a)throw{name:"Error",message:"Missing parameter: list must be provided"};return b=void 0===b?",":b,this.listGetAt(a,this.listLen(a,b),b)},listLen:function(a,b){if(void 0===a)throw{name:"Error",message:"Missing parameter: list must be provided"};return b=void 0===b?",":b,""===a?0:a.split(b).length},listPrepend:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and value must be provided"};return c=void 0===c?",":c,b+(""!==a?c+a:"")},listQualify:function(a,b,c){if(void 0===a)throw{name:"Error",message:"Missing parameter: list must be provided"};if(b=void 0===b?"'":b,c=void 0===c?",":c,""===a)return a;for(var d=a.split(c),e=d.length-1;e>=0;)d[e]=b+d[e]+b,e-=1;return d.join(c)},listRemove:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list1 and list2 must be provided"};c=void 0===c?",":c;var e,f,d=a.split(c),g=d.length,h=[];for(e=0;g>e;e+=1)f=d[e],this.listFind(b,f,c)||h.push(f);return h.join(c)},listRemoveNoCase:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list1 and list2 must be provided"};c=void 0===c?",":c;var e,f,d=a.split(c),g=d.length,h=[];for(e=0;g>e;e+=1)f=d[e],this.listFindNoCase(b,f,c)||h.push(f);return h.join(c)},listRemoveDuplicates:function(a,b){if(void 0===a)throw{name:"Error",message:"Missing parameter: list must be provided"};b=void 0===b?",":b;var d,e,c=a.split(b),f=c.length,g=[],h={};for(d=0;f>d;d+=1)e=c[d],h[e]||(h[e]={},g.push(e));return g.join(b)},listRemoveDuplicatesNoCase:function(a,b){if(void 0===a)throw{name:"Error",message:"Missing parameter: list must be provided"};b=void 0===b?",":b;var d,e,g,c=a.split(b),f=c.length,h=[],i={};for(d=0;f>d;d+=1)e=c[d],g=e.toUpperCase(),i[g]||(i[g]={},h.push(e));return h.join(b)},listReplace:function(a,b,c,d){if(void 0===a||void 0===b||void 0===c)throw{name:"Error",message:"Missing parameter: list, value1 and value2 must be provided"};d=void 0===d?",":d;var f,g,e=a.split(d),h=e.length,i=[];for(f=0;h>f;f+=1)g=e[f],g===b?i.push(c):i.push(g);return i.join(d)},listReplaceNoCase:function(a,b,c,d){if(void 0===a||void 0===b||void 0===c)throw{name:"Error",message:"Missing parameter: list, value1 and value2 must be provided"};d=void 0===d?",":d;var f,g,e=a.split(d),h=e.length,i=[];for(f=0;h>f;f+=1)g=e[f],g.toUpperCase()===b.toUpperCase()?i.push(c):i.push(g);return i.join(d)},listRest:function(a,b){if(void 0===a)throw{name:"Error",message:"Missing parameter: list must be provided"};b=void 0===b?",":b;var c=a.split(b);return c.splice(0,1),c.join(b)},listReverse:function(a,b){if(void 0===a)throw{name:"Error",message:"Missing parameter: list must be provided"};b=void 0===b?",":b;var c=a.split(b);return c.reverse(),c.join(b)},listSetAt:function(a,b,c,d){if(void 0===a||void 0===b||void 0===c)throw{name:"Error",message:"Missing parameter: list, position and value must be provided"};if(d=void 0===d?",":d,""===a)return"";var e=a.split(d);return b>=1&&e.length>=b?(e[b-1]=c,e.join(d)):a},listSort:function(c,d,e,f){if(void 0===c)throw{name:"Error",message:"Missing parameter: list must be provided"};d=void 0===d?"alpha":d.toLowerCase(),e=void 0===e?"asc":e.toLowerCase(),f=void 0===f?",":f,d=d.toLowerCase(),e=e.toLowerCase();var g=c.split(f);return"alpha"===d?(g.sort(),"desc"===e&&g.reverse()):"asc"===e?g.sort(a):g.sort(b),g.join(f)},listUnion:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list1 and list2 must be provided"};return c=void 0===c?",":c,this.listRemoveDuplicates(this.listConcatenate(a,b,c),c)},listValueCount:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and value must be provided"};c=void 0===c?",":c,b+="";for(var d=a.split(c),e=d.length,f=0;e;)e-=1,d[e]===b&&(f+=1);return f},listValueCountNoCase:function(a,b,c){if(void 0===a||void 0===b)throw{name:"Error",message:"Missing parameter: list and value must be provided"};return c=void 0===c?",":c,a=a.toUpperCase(),b=(b+"").toUpperCase(),this.listValueCount(a,b,c)}}}();