stylus/vendor/lz-string-unsafe/lz-string-unsafe.min.js

1 line
3.2 KiB
JavaScript
Raw Normal View History

2018-07-21 17:58:54 +00:00
var LZStringUnsafe=function(){function b(z,A){for(var B=0;A>>=1;B++)r=1&z>>B|r<<1,++s===t&&(s=0,q.push(u(r)),r=0)}function d(z){return x[z]}function e(z){return y[z]}function f(z){return p(z+32)}function g(z,A,B){if(q=[],null!=z){r=0,s=0,t=A,u=B;var C=0,D=0,E=0,F=[3],G=[2,2,F],H=!0,I=0,J=3,K=4;if(z.length){I=z.charCodeAt(0),E=256>I?0:1,b(E,K),b(I,E?65536:256),G[1]=I;nextchar:for(C=1;C<z.length;C++){for(I=z.charCodeAt(C),D=1;D<F.length;D+=2)if(F[D]==I){F=F[D+1];continue nextchar}for(H?H=!1:b(F[0],K),D=1;G[D]!=I&&D<G.length;)D+=2;D==G.length&&(++J>=K&&(K<<=1),E=256>I?0:1,b(E,K),b(I,E?65536:256),G.push(I),G.push([J]),H=!0),F.push(I),F.push([++J]),J>=K&&(K<<=1),F=G[D+1]}for(H?H=!1:b(F[0],K),D=1;G[D]!=I&&D<G.length;)D+=2;D==G.length&&(++J>=K&&(K<<=1),E=256>I?0:1,b(E,K),b(I,E?65536:256)),++J>=K&&(K<<=1)}b(2,K),r<<=t-s,q.push(u(r))}return q}function h(z,A,B){for(var C=[0,1,2],D=4,E=4,F=3,G="",H=[],I="",J=0,K=2,L=0,M="",N=B(0),O=A,P=1;L!=K;)J+=(1&N>>--O)<<L++,0==O&&(O=A,N=B(P++));if(2==J)return"";for(K=8*J+8,J=L=0;L!=K;)J+=(1&N>>--O)<<L++,0==O&&(O=A,N=B(P++));for(M=p(J),C[3]=M,I=M,H.push(M);P<=z;){for(K=F,J=L=0;L!=K;)J+=(1&N>>--O)<<L++,0==O&&(O=A,N=B(P++));if(2>J){for(K=8+8*J,J=L=0;L!=K;)J+=(1&N>>--O)<<L++,0==O&&(O=A,N=B(P++));C[E]=p(J),J=E++,0==--D&&(D=1<<F++)}else if(2==J)return H.join("");if(J>C.length)return null;G=J<C.length?C[J]:I+I.charAt(0),H.push(G),C[E++]=I+G.charAt(0),I=G,0==--D&&(D=1<<F++)}return""}function l(z){return g(z,16,p)}function m(z){return null==z?"":0==z.length?null:h(z.length,16,function(A){return z[A].charCodeAt(0)})}for(var q,r,s,t,u,n=0,o={},p=String.fromCharCode,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+",x=(v+"/=").split(""),y=(v+"-$").split("");65>n;)62<n&&(o[y[n].charCodeAt(0)]=n),o[x[n].charCodeAt(0)]=n++;return{compressToBase64:function(z){if(null==z)return"";for(var A=g(z,6,d),B=A.length%4;B--;)A.push("=");return A.join("")},decompressFromBase64:function(z){return null==z?"":""==z?null:h(z.length,6,function(A){return o[z.charCodeAt(A)]})},compressToUTF16:function(z){if(null==z)return"";var A=g(z,15,f);return A.push(" "),A.join("")},decompressFromUTF16:function(z){return null==z?"":""==z?null:h(z.length,15,function(A){return z.charCodeAt(A)-32})},compressToUint8Array:function(z){for(var E,A=l(z),B=new Uint8Array(2*A.length),C=0,D=A.length;C<D;C++)E=A[C].charCodeAt(0),B[2*C]=E>>>8,B[2*C+1]=255&E;return B},decompressFromUint8Array:function(z){if(null===z||z===void 0)return m(z);return 0==z.length?null:h(z.length,8,function(A){return z[A]})},compressToEncodedURIComponent:function(z){return null==z?"":g(z,6,e).join("")},decompressFromEncodedURIComponent:function(z){return null==z?"":""==z?null:(z=z.replace(/ /g,"+"),h(z.length,6,function(A){return o[z.charCodeAt(A)]}))},compress:function(z){return l(z).join("")},compressToArray:l,decompress:function(z){return null==z?"":""==z?null:h(z.length,16,function(A){return z.charCodeAt(A)})},decompressFromArray:m}}();"function"==typeof define&&define.amd?define(function(){return LZStringUnsafe}):"undefined"!=typeof module&&null!=module?module.exports=LZStringUnsafe:"undefined"!=typeof angular&&null!=angular&&angular.module("LZStringUnsafe",[]).factory("LZStringUnsafe",function(){return LZStringUnsafe});