forked from square/crossfilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crossfilter.min.js
1 lines (1 loc) · 9.89 KB
/
crossfilter.min.js
1
!function(r){function n(r){return r}function e(r,n){for(var e=0,t=n.length,u=Array(t);t>e;++e)u[e]=r[n[e]];return u}function t(r){function n(n,e,t,u){for(;u>t;){var f=t+u>>>1;r(n[f])<e?t=f+1:u=f}return t}function e(n,e,t,u){for(;u>t;){var f=t+u>>>1;e<r(n[f])?u=f:t=f+1}return t}return e.right=e,e.left=n,e}function u(r){function n(r,n,e){for(var u=e-n,f=(u>>>1)+1;--f>0;)t(r,f,u,n);return r}function e(r,n,e){for(var u,f=e-n;--f>0;)u=r[n],r[n]=r[n+f],r[n+f]=u,t(r,1,f,n);return r}function t(n,e,t,u){for(var f,o=n[--u+e],i=r(o);(f=e<<1)<=t&&(t>f&&r(n[u+f])>r(n[u+f+1])&&f++,!(i<=r(n[u+f])));)n[u+e]=n[u+f],e=f;n[u+e]=o}return n.sort=e,n}function f(r){function n(n,t,u,f){var o,i,a,c,l=Array(f=Math.min(u-t,f));for(i=0;f>i;++i)l[i]=n[t++];if(e(l,0,f),u>t){o=r(l[0]);do(a=r(c=n[t])>o)&&(l[0]=c,o=r(e(l,0,f)[0]));while(++t<u)}return l}var e=u(r);return n}function o(r){function n(n,e,t){for(var u=e+1;t>u;++u){for(var f=u,o=n[u],i=r(o);f>e&&r(n[f-1])>i;--f)n[f]=n[f-1];n[f]=o}return n}return n}function i(r){function n(r,n,u){return(z>u-n?t:e)(r,n,u)}function e(e,t,u){var f,o=0|(u-t)/6,i=t+o,a=u-1-o,c=t+u-1>>1,l=c-o,v=c+o,s=e[i],h=r(s),p=e[l],d=r(p),g=e[c],y=r(g),x=e[v],m=r(x),b=e[a],A=r(b);h>d&&(f=s,s=p,p=f,f=h,h=d,d=f),m>A&&(f=x,x=b,b=f,f=m,m=A,A=f),h>y&&(f=s,s=g,g=f,f=h,h=y,y=f),d>y&&(f=p,p=g,g=f,f=d,d=y,y=f),h>m&&(f=s,s=x,x=f,f=h,h=m,m=f),y>m&&(f=g,g=x,x=f,f=y,y=m,m=f),d>A&&(f=p,p=b,b=f,f=d,d=A,A=f),d>y&&(f=p,p=g,g=f,f=d,d=y,y=f),m>A&&(f=x,x=b,b=f,f=m,m=A,A=f);var O=p,k=d,w=x,E=m;e[i]=s,e[l]=e[t],e[c]=g,e[v]=e[u-1],e[a]=b;var M=t+1,C=u-2,U=E>=k&&k>=E;if(U)for(var z=M;C>=z;++z){var N=e[z],S=r(N);if(k>S)z!==M&&(e[z]=e[M],e[M]=N),++M;else if(S>k)for(;;){var q=r(e[C]);{if(!(q>k)){if(k>q){e[z]=e[M],e[M++]=e[C],e[C--]=N;break}e[z]=e[C],e[C--]=N;break}C--}}}else for(var z=M;C>=z;z++){var N=e[z],S=r(N);if(k>S)z!==M&&(e[z]=e[M],e[M]=N),++M;else if(S>E)for(;;){var q=r(e[C]);{if(!(q>E)){k>q?(e[z]=e[M],e[M++]=e[C],e[C--]=N):(e[z]=e[C],e[C--]=N);break}if(C--,z>C)break}}}if(e[t]=e[M-1],e[M-1]=O,e[u-1]=e[C+1],e[C+1]=w,n(e,t,M-1),n(e,C+2,u),U)return e;if(i>M&&C>a){for(var F,q;(F=r(e[M]))<=k&&F>=k;)++M;for(;(q=r(e[C]))<=E&&q>=E;)--C;for(var z=M;C>=z;z++){var N=e[z],S=r(N);if(k>=S&&S>=k)z!==M&&(e[z]=e[M],e[M]=N),M++;else if(E>=S&&S>=E)for(;;){var q=r(e[C]);{if(!(E>=q&&q>=E)){k>q?(e[z]=e[M],e[M++]=e[C],e[C--]=N):(e[z]=e[C],e[C--]=N);break}if(C--,z>C)break}}}}return n(e,M,C+1)}var t=o(r);return n}function a(r){for(var n=Array(r),e=-1;++e<r;)n[e]=0;return n}function c(r,n){for(var e=r.length;n>e;)r[e++]=0;return r}function l(r,n){if(n>32)throw Error("invalid array width!");return r}function v(r,n){return function(e){var t=e.length;return[r.left(e,n,0,t),r.right(e,n,0,t)]}}function s(r,n){var e=n[0],t=n[1];return function(n){var u=n.length;return[r.left(n,e,0,u),r.left(n,t,0,u)]}}function h(r){return[0,r.length]}function p(){return null}function d(){return 0}function g(r){return r+1}function y(r){return r-1}function x(r){return function(n,e){return n+ +r(e)}}function m(r){return function(n,e){return n-r(e)}}function b(){function r(r){var n=C,e=r.length;return e&&(M=M.concat(r),S=F(S,C+=e),j.forEach(function(t){t(r,n,e)})),E}function t(r){var n=A(C,C),e=[];if(r)for(var t=0,u=0;C>t;++t)r(M[t])?n[t]=u++:e.push(t);else for(var t=0,u=0;C>t;++t)S[t]?n[t]=u++:e.push(t);if(q.forEach(function(r){r(0,[],e)}),B.forEach(function(e){e(n,r)}),r)for(var f,t=0,u=0;C>t;++t)r(M[t])&&((f=S[t]&&t!==u)&&(S[u]=f),t!==u&&(M[u]=M[t]),++u);else for(var f,t=0,u=0;C>t;++t)(f=S[t])&&(t!==u&&(S[u]=f,M[u]=M[t]),++u);for(M.length=u;C>u;)S[--C]=0}function o(r){q.push(r),j.push(r),B.push(r)}function a(r){var n=q.indexOf(r);n>=0&&q.splice(n,1),n=j.indexOf(r),n>=0&&j.splice(n,1),n=B.indexOf(r),n>=0&&B.splice(n,1)}function c(r){function t(n,t,u){T=n.map(r),V=$(O(u),0,u),T=e(T,V);var f,o=_(T),i=o[0],a=o[1];if(W)for(f=0;u>f;++f)W(T[f],f)||(S[V[f]+t]|=Y);else{for(f=0;i>f;++f)S[V[f]+t]|=Y;for(f=a;u>f;++f)S[V[f]+t]|=Y}if(!t)return P=T,Q=V,en=i,tn=a,void 0;var c=P,l=Q,v=0,s=0;for(P=Array(C),Q=A(C,C),f=0;t>v&&u>s;++f)c[v]<T[s]?(P[f]=c[v],Q[f]=l[v++]):(P[f]=T[s],Q[f]=V[s++]+t);for(;t>v;++v,++f)P[f]=c[v],Q[f]=l[v];for(;u>s;++s,++f)P[f]=T[s],Q[f]=V[s]+t;o=_(P),en=o[0],tn=o[1]}function o(r,n,e){rn.forEach(function(r){r(T,V,n,e)}),T=V=null}function a(r,n){if(n)for(var e,t=0,u=0;C>t;++t)n(M[e=Q[t]])&&(t!==u&&(P[u]=P[t]),Q[u]=r[e],++u);else for(var e,t=0,u=0;C>t;++t)S[e=Q[t]]&&(t!==u&&(P[u]=P[t]),Q[u]=r[e],++u);for(P.length=u;C>u;)Q[u++]=0;var f=_(P);en=f[0],tn=f[1]}function c(r){var n=r[0],e=r[1];if(W)return W=null,G(function(r,t){return t>=n&&e>t}),en=n,tn=e,X;var t,u,f,o=[],i=[];if(en>n)for(t=n,u=Math.min(en,e);u>t;++t)S[f=Q[t]]^=Y,o.push(f);else if(n>en)for(t=en,u=Math.min(n,tn);u>t;++t)S[f=Q[t]]^=Y,i.push(f);if(e>tn)for(t=Math.max(n,tn),u=e;u>t;++t)S[f=Q[t]]^=Y,o.push(f);else if(tn>e)for(t=Math.max(en,e),u=tn;u>t;++t)S[f=Q[t]]^=Y,i.push(f);return en=n,tn=e,q.forEach(function(r){r(Y,o,i)}),X}function l(r){return null==r?N():Array.isArray(r)?E(r):"function"==typeof r?D(r):b(r)}function b(r){return c((_=v(w,r))(P))}function E(r){return c((_=s(w,r))(P))}function N(){return c((_=h)(P))}function D(r){return _=h,G(W=r),en=0,tn=C,X}function G(r){var n,e,t,u=[],f=[];for(n=0;C>n;++n)!(S[e=Q[n]]&Y)^!!(t=r(P[n],n))&&(t?(S[e]&=Z,u.push(e)):(S[e]|=Y,f.push(e)));q.forEach(function(r){r(Y,u,f)})}function H(r){for(var n,e=[],t=tn;--t>=en&&r>0;)S[n=Q[t]]||(e.push(M[n]),--r);return e}function I(r){for(var n,e=[],t=en;tn>t&&r>0;)S[n=Q[t]]||(e.push(M[n]),--r),t++;return e}function J(r){function e(n,e,t,u){function f(){++T===L&&(x=R(x,K<<=1),j=R(j,K),L=k(K))}var l,v,s,h,d,g,y=N,x=A(T,L),m=H,b=J,O=T,w=0,E=0;for(X&&(m=b=p),N=Array(T),T=0,j=O>1?F(j,C):A(C,L),O&&(s=(v=y[0]).key);u>E&&!((h=r(n[E]))>=h);)++E;for(;u>E;){for(v&&h>=s?(d=v,g=s,x[w]=T,(v=y[++w])&&(s=v.key)):(d={key:h,value:b()},g=h),N[T]=d;!(h>g||(j[l=e[E]+t]=T,S[l]&Z||(d.value=m(d.value,M[l])),++E>=u));)h=r(n[E]);f()}for(;O>w;)N[x[w]=T]=y[w++],f();if(T>w)for(w=0;t>w;++w)j[w]=x[j[w]];l=q.indexOf(V),T>1?(V=o,W=a):(!T&&$&&(T=1,N=[{key:null,value:b()}]),1===T?(V=i,W=c):(V=p,W=p),j=null),q[l]=V}function t(r,n){if(T>1){var e=T,t=N,u=A(e,e);if(n)for(var f=0,l=0;C>f;++f)n(M[f])&&(u[j[l]=j[f]]=1,++l);else for(var f=0,l=0;C>f;++f)S[f]&&(u[j[l]=j[f]]=1,++l);for(N=[],T=0,f=0;e>f;++f)u[f]&&(u[f]=T++,N.push(t[f]));if(T>1)for(var f=0;l>f;++f)j[f]=u[j[f]];else j=null;q[q.indexOf(V)]=T>1?(W=a,V=o):1===T?(W=c,V=i):W=V=p}else if(1===T){if($)return;if(n){for(var f=0;C>f;++f)if(n(M[f]))return}else for(var f=0;C>f;++f)if(S[f])return;N=[],T=0,q[q.indexOf(V)]=V=W=p}}function o(r,n,e){if(r!==Y&&!X){var t,u,f,o;for(t=0,f=n.length;f>t;++t)S[u=n[t]]&Z||(o=N[j[u]],o.value=H(o.value,M[u]));for(t=0,f=e.length;f>t;++t)(S[u=e[t]]&Z)===r&&(o=N[j[u]],o.value=I(o.value,M[u]))}}function i(r,n,e){if(r!==Y&&!X){var t,u,f,o=N[0];for(t=0,f=n.length;f>t;++t)S[u=n[t]]&Z||(o.value=H(o.value,M[u]));for(t=0,f=e.length;f>t;++t)(S[u=e[t]]&Z)===r&&(o.value=I(o.value,M[u]))}}function a(){var r,n;for(r=0;T>r;++r)N[r].value=J();for(r=0;C>r;++r)S[r]&Z||(n=N[j[r]],n.value=H(n.value,M[r]))}function c(){var r,n=N[0];for(n.value=J(),r=0;C>r;++r)S[r]&Z||(n.value=H(n.value,M[r]))}function l(){return X&&(W(),X=!1),N}function v(r){var n=D(l(),0,N.length,r);return G.sort(n,0,n.length)}function s(r,n,e){return H=r,I=n,J=e,X=!0,z}function h(){return s(g,y,d)}function b(r){return s(x(r),m(r),d)}function O(r){function n(n){return r(n.value)}return D=f(n),G=u(n),z}function w(){return O(n)}function E(){return T}function U(){var r=q.indexOf(V);return r>=0&&q.splice(r,1),r=rn.indexOf(e),r>=0&&rn.splice(r,1),r=B.indexOf(t),r>=0&&B.splice(r,1),z}var z={top:v,all:l,reduce:s,reduceCount:h,reduceSum:b,order:O,orderNatural:w,size:E,dispose:U,remove:U};nn.push(z);var N,j,D,G,H,I,J,K=8,L=k(K),T=0,V=p,W=p,X=!0,$=r===p;return arguments.length<1&&(r=n),q.push(V),rn.push(e),B.push(t),e(P,Q,0,C),h().orderNatural()}function K(){var r=J(p),n=r.all;return delete r.all,delete r.top,delete r.order,delete r.orderNatural,delete r.size,r.value=function(){return n()[0].value},r}function L(){nn.forEach(function(r){r.dispose()});var r=j.indexOf(t);return r>=0&&j.splice(r,1),r=j.indexOf(o),r>=0&&j.splice(r,1),r=B.indexOf(a),r>=0&&B.splice(r,1),U&=Z,N()}var P,Q,T,V,W,X={filter:l,filterExact:b,filterRange:E,filterFunction:D,filterAll:N,top:H,bottom:I,group:J,groupAll:K,dispose:L,remove:L},Y=~U&-~U,Z=~Y,$=i(function(r){return T[r]}),_=h,rn=[],nn=[],en=0,tn=0;return j.unshift(t),j.push(o),B.push(a),U|=Y,(z>=32?!Y:U&-(1<<z))&&(S=R(S,z<<=1)),t(M,0,C),o(M,0,C),X}function l(){function r(r,n){var e;if(!h)for(e=n;C>e;++e)S[e]||(a=c(a,M[e]))}function n(r,n,e){var t,u,f;if(!h){for(t=0,f=n.length;f>t;++t)S[u=n[t]]||(a=c(a,M[u]));for(t=0,f=e.length;f>t;++t)S[u=e[t]]===r&&(a=l(a,M[u]))}}function e(){var r;for(a=v(),r=0;C>r;++r)S[r]||(a=c(a,M[r]))}function t(r,n,e){return c=r,l=n,v=e,h=!0,s}function u(){return t(g,y,d)}function f(r){return t(x(r),m(r),d)}function o(){return h&&(e(),h=!1),a}function i(){var e=q.indexOf(n);return e>=0&&q.splice(e),e=j.indexOf(r),e>=0&&j.splice(e),s}var a,c,l,v,s={reduce:t,reduceCount:u,reduceSum:f,value:o,dispose:i,remove:i},h=!0;return q.push(n),j.push(r),r(M,0,C),u()}function b(){return C}var E={add:r,remove:t,dimension:c,groupAll:l,size:b,onChange:o,offChange:a},M=[],C=0,U=0,z=8,S=N(0),q=[],j=[],B=[];return arguments.length?r(arguments[0]):E}function A(r,n){return(257>n?N:65537>n?S:q)(r)}function O(r){for(var n=A(r,r),e=-1;++e<r;)n[e]=e;return n}function k(r){return 8===r?256:16===r?65536:4294967296}b.version="1.3.13-hola.0",b.permute=e;var w=b.bisect=t(n);w.by=t;var E=b.heap=u(n);E.by=u;var M=b.heapselect=f(n);M.by=f;var C=b.insertionsort=o(n);C.by=o;var U=b.quicksort=i(n);U.by=i;var z=32,N=a,S=a,q=a,F=c,R=l;"undefined"!=typeof Uint8Array&&(N=function(r){return new Uint8Array(r)},S=function(r){return new Uint16Array(r)},q=function(r){return new Uint32Array(r)},F=function(r,n){if(r.length>=n)return r;var e=new r.constructor(n);return e.set(r),e},R=function(r,n){var e;switch(n){case 16:e=S(r.length);break;case 32:e=q(r.length);break;default:throw Error("invalid array width!")}return e.set(r),e}),r.crossfilter=b}("undefined"!=typeof exports&&exports||this);