-
Notifications
You must be signed in to change notification settings - Fork 1
/
LzStr2.min.js
1 lines (1 loc) · 2.32 KB
/
LzStr2.min.js
1
var LZString=(()=>{var r,e,o,s="",t=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",h=(n+"+/").split(""),a=(n+"-.~").split(""),c=(n+"+/-.~!#$%&()*,:;<>?@[]^_`{|}=").split(""),p=r=>r.join(""),u=r=>r.charCodeAt(0),l=(r,e)=>r.charCodeAt(e),m=(o,s,t)=>{var n=[],h=0,a=0,c=s,p=0,l=0,m=[3],f=[2,2,m],i=!0,d=0,g=4,v=!0,A=0,C=0,F=()=>{m.push(d),m.push([E])},T=F,U=(r,e)=>{for(var o=0;e>>=1;o++)h=r>>o&1|h<<1,++a===c&&(a=0,n.push(t(h)),h=0)},y=()=>{for(i?i=!1:U(m[0],g),p=1,C=f.length;f[p]!=d&&p<C;)p+=2;p==C&&(++E>=g&&(g<<=1),U(l=d<256?0:1,g),U(d,l?65536:256),f.push(d),f.push([E]),i=!0),++E>=g&&(g<<=1)},E=3;r&&(F=(()=>{r===d?v?(--E>=g&&(g>>=1),v=!1):T():(v=!0,T())})),d=u(o),U(l=d<256?0:1,g),U(d,l?65536:256),f[1]=d;r:for(var B=o.length,S=1;S<B;S++){for(d=o.charCodeAt(S),A=m.length,p=1;p<A;p+=2)if(m[p]==d){m=m[p+1];continue r}y(),F(),m=f[p+1]}return y(),U(2,g),h<<=c-a,n.push(t(h)),e&&n.unshift(e),n},f=(n,h,a)=>{var c,u,l=["","",""],m=4,f=3,i=[],d=0,g=2,v=0,A=e?e.length:0,C=a(A),F=h,T=()=>{l[o++]=u+c.charAt(0)},U=T;if(o=4,A++,r&&(T=(()=>{s===c[0]?s===u[0]?U():m++:U()})),v)return null;var y=()=>{for(d=v=0;v!=g;)d+=(C>>--F&1)<<v++,0==F&&(F=h,C=a(A++))};for(y(),g=8*d+8,y(),u=t(d),l[3]=u,i.push(u);A<=n;){if(g=f,y(),d<2)g=8+8*d,y(),l[o]=t(d),d=o++,0==--m&&(m=1<<f++);else if(2==d)return p(i);c=d<l.length?l[d]:u+u.charAt(0),i.push(c),T(),u=c,0==--m&&(m=1<<f++)}},i=r=>m(r,16,t);return{compressToBase64:r=>{var e=m(r,6,r=>h[r]);return p(e)},decompressFromBase64:r=>{var e={};return h.forEach((r,o)=>{e[u(r)]=o}),f(r.length,6,o=>e[l(r,o)])},compressToUTF16:r=>{var e=m(r,15,r=>t(r+32));return e.push(" "),p(e)},decompressFromUTF16:r=>f(r.length,15,e=>l(r,e)-32),compressToUint8Array:r=>Uint8Array.from(m(r,8,r=>r)),decompressFromUint8Array:r=>f(r.length,8,e=>r[e]),compressToEncodedURIComponent:r=>{return p(m(r,6,r=>a[r]))},decompressFromEncodedURIComponent:r=>{var e={};return a.forEach((r,o)=>{e[u(r)]=o}),f(r.length,6,o=>e[l(r,o)])},compressToB91:r=>{return p(m(r,13,r=>c[Math.floor(r/91)]+c[r%91]))},decompressFromB91:r=>{var e={};return c.forEach((r,o)=>{e[u(r)]=o}),f(r.length/2,13,o=>91*e[l(r,2*o)]+e[l(r,2*o+1)])},compress:r=>p(i(r)),decompress:r=>f(r.length,16,e=>r.charCodeAt(e)),compressToArray:i,decompressFromArray:r=>null==r?"":0==r.length?null:f(r.length,16,e=>u(r[e])),config:(o,t)=>{e=o,s=t,r=u(t)},dictSize:()=>o}})();