-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.min.js
More file actions
1 lines (1 loc) · 1.29 KB
/
set.min.js
File metadata and controls
1 lines (1 loc) · 1.29 KB
1
function setBuilder(a){"use strict";return this instanceof setBuilder?(this.parse(a),this):new setBuilder(a)}setBuilder.prototype=function(){"use strict";function a(){if(j++,!i)return c[j]||!1;var a=+g;return g=+g,g+=e,f>d&&a>f?!1:d>f&&f>a?!1:a}var b,c,d,e,f,g,h,i=!1,j=0,k=!1;return{parse:function(a){b=a,j=0;var l,m=a.replace(/[\{\}]/g,""),n=m.split(",");for(l=0;n[l];l+=1)n[l]=n[l].trim();if(c=n,a.search(/\.{2,}/)>-1&&(i=!0),d=c[0],g=d,f=c[c.length-1],d.match(/^\.\.+$/))throw"Lists from -infinity to any number not supported";if(isNaN(c[1])){if(isNaN(f))throw"Your set makes no sense";e=1,c[1]=d+e}else e=c[1]-d;return h=d<c[1]?"asc":"dsc",f.match(/^\.\.+$/)&&(k=!0,f=Math.pow(2,53),"dsc"===h&&(f*=-1)),this},head:function(){return a()},tail:function(){return this.head(),this.nextAll()},next:function(a){a=a||1;for(var b=[];a--;)b.push(this.head());return b},nextAll:function(){for(var a=[];!1!==this.peek();)a.push(g),this.head();return a},peek:function(){var a=this.head();return g-=e,a},serializeAll:function(){return b},serialize:function(){var a="{";return"asc"===h&&g>f||"dsc"===h&&f>g?!1:g===f||this.peek()===!1?"{"+g+"}":this.peek()===f?"{"+g+", "+f+"}":(a+=g+", ",a+=+g+e+", ",a+=k?"...}":"..., "+f+"}")},serializeTail:function(){return this.head(),this.serialize()},rewind:function(){this.parse(b)}}}();