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