diff --git a/bower.json b/bower.json index 06eb7aa..052b00f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "lz-string", - "version": "1.3.7", + "version": "1.3.8", "main": "libs/lz-string.min.js", "ignore": [ "bin/", diff --git a/libs/lz-string.js b/libs/lz-string.js index e999e94..bf0adb0 100644 --- a/libs/lz-string.js +++ b/libs/lz-string.js @@ -6,7 +6,7 @@ // For more information, the home page: // http://pieroxy.net/blog/pages/lz-string/testing.html // -// LZ-based compression algorithm, version 1.3.7 +// LZ-based compression algorithm, version 1.3.8 var LZString = { diff --git a/libs/lz-string.min.js b/libs/lz-string.min.js index b807614..94bd284 100644 --- a/libs/lz-string.min.js +++ b/libs/lz-string.min.js @@ -1 +1 @@ -var LZString={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_f:String.fromCharCode,compressToBase64:function(e){if(e==null)return"";var t="";var n,r,i,s,o,u,a;var f=0;e=LZString.compress(e);while(f>8;r=e.charCodeAt(f/2)&255;if(f/2+1>8;else i=NaN}else{n=e.charCodeAt((f-1)/2)&255;if((f+1)/2>8;i=e.charCodeAt((f+1)/2)&255}else r=i=NaN}f+=3;s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+LZString._keyStr.charAt(s)+LZString._keyStr.charAt(o)+LZString._keyStr.charAt(u)+LZString._keyStr.charAt(a)}return t},decompressFromBase64:function(e){if(e==null)return"";var t="",n=0,r,i,s,o,u,a,f,l,c=0,h=LZString._f;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(c>4;s=(a&15)<<4|f>>2;o=(f&3)<<6|l;if(n%2==0){r=i<<8;if(f!=64){t+=h(r|s)}if(l!=64){r=o<<8}}else{t=t+h(r|i);if(f!=64){r=s<<8}if(l!=64){t+=h(r|o)}}n+=3}return LZString.decompress(t)},compressToUTF16:function(e){if(e==null)return"";var t="",n,r,i,s=0,o=LZString._f;e=LZString.compress(e);for(n=0;n>1)+32);i=(r&1)<<14;break;case 1:t+=o(i+(r>>2)+32);i=(r&3)<<13;break;case 2:t+=o(i+(r>>3)+32);i=(r&7)<<12;break;case 3:t+=o(i+(r>>4)+32);i=(r&15)<<11;break;case 4:t+=o(i+(r>>5)+32);i=(r&31)<<10;break;case 5:t+=o(i+(r>>6)+32);i=(r&63)<<9;break;case 6:t+=o(i+(r>>7)+32);i=(r&127)<<8;break;case 7:t+=o(i+(r>>8)+32);i=(r&255)<<7;break;case 8:t+=o(i+(r>>9)+32);i=(r&511)<<6;break;case 9:t+=o(i+(r>>10)+32);i=(r&1023)<<5;break;case 10:t+=o(i+(r>>11)+32);i=(r&2047)<<4;break;case 11:t+=o(i+(r>>12)+32);i=(r&4095)<<3;break;case 12:t+=o(i+(r>>13)+32);i=(r&8191)<<2;break;case 13:t+=o(i+(r>>14)+32);i=(r&16383)<<1;break;case 14:t+=o(i+(r>>15)+32,(r&32767)+32);s=0;break}}return t+o(i+32)},decompressFromUTF16:function(e){if(e==null)return"";var t="",n,r,i=0,s=0,o=LZString._f;while(s>14);n=(r&16383)<<2;break;case 2:t+=o(n|r>>13);n=(r&8191)<<3;break;case 3:t+=o(n|r>>12);n=(r&4095)<<4;break;case 4:t+=o(n|r>>11);n=(r&2047)<<5;break;case 5:t+=o(n|r>>10);n=(r&1023)<<6;break;case 6:t+=o(n|r>>9);n=(r&511)<<7;break;case 7:t+=o(n|r>>8);n=(r&255)<<8;break;case 8:t+=o(n|r>>7);n=(r&127)<<9;break;case 9:t+=o(n|r>>6);n=(r&63)<<10;break;case 10:t+=o(n|r>>5);n=(r&31)<<11;break;case 11:t+=o(n|r>>4);n=(r&15)<<12;break;case 12:t+=o(n|r>>3);n=(r&7)<<13;break;case 13:t+=o(n|r>>2);n=(r&3)<<14;break;case 14:t+=o(n|r>>1);n=(r&1)<<15;break;case 15:t+=o(n|r);i=0;break}s++}return LZString.decompress(t)},compressToUint8Array:function(e){var t=LZString.compress(e);var n=new Uint8Array(t.length*2);for(var r=0,i=t.length;r>>8;n[r*2+1]=s%256}return n},decompressFromUint8Array:function(e){if(e===null||e===undefined){return LZString.decompress(e)}else{var t=new Array(e.length/2);for(var n=0,r=t.length;n>1}}else{n=1;for(t=0;t>1}}a--;if(a==0){a=Math.pow(2,l);l++}delete i[u]}else{n=r[u];for(t=0;t>1}}a--;if(a==0){a=Math.pow(2,l);l++}r[o]=f++;u=String(s)}}if(u!==""){if(Object.prototype.hasOwnProperty.call(i,u)){if(u.charCodeAt(0)<256){for(t=0;t>1}}else{n=1;for(t=0;t>1}}a--;if(a==0){a=Math.pow(2,l);l++}delete i[u]}else{n=r[u];for(t=0;t>1}}a--;if(a==0){a=Math.pow(2,l);l++}}n=2;for(t=0;t>1}while(true){h=h<<1;if(p==15){c+=v(h);break}else p++}return c},decompress:function(e){if(e==null)return"";if(e=="")return null;var t=[],n,r=4,i=4,s=3,o="",u="",a,f,l,c,h,p,d,v=LZString._f,m={string:e,val:e.charCodeAt(0),position:32768,index:1};for(a=0;a<3;a+=1){t[a]=a}l=0;h=Math.pow(2,2);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}switch(n=l){case 0:l=0;h=Math.pow(2,8);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}d=v(l);break;case 1:l=0;h=Math.pow(2,16);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}d=v(l);break;case 2:return""}t[3]=d;f=u=d;while(true){if(m.index>m.string.length){return""}l=0;h=Math.pow(2,s);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}switch(d=l){case 0:l=0;h=Math.pow(2,8);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}t[i++]=v(l);d=i-1;r--;break;case 1:l=0;h=Math.pow(2,16);p=1;while(p!=h){c=m.val&m.position;m.position>>=1;if(m.position==0){m.position=32768;m.val=m.string.charCodeAt(m.index++)}l|=(c>0?1:0)*p;p<<=1}t[i++]=v(l);d=i-1;r--;break;case 2:return u}if(r==0){r=Math.pow(2,s);s++}if(t[d]){o=t[d]}else{if(d===i){o=f+f.charAt(0)}else{return null}}u+=o;t[i++]=f+o.charAt(0);r--;f=o;if(r==0){r=Math.pow(2,s);s++}}}};if(typeof module!=="undefined"&&module!=null){module.exports=LZString} \ No newline at end of file +var LZString={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_f:String.fromCharCode,compressToBase64:function(r){if(null==r)return"";var e,o,t,n,i,a,s,c="",p=0;for(r=LZString.compress(r);p<2*r.length;)p%2==0?(e=r.charCodeAt(p/2)>>8,o=255&r.charCodeAt(p/2),t=p/2+1>8:0/0):(e=255&r.charCodeAt((p-1)/2),(p+1)/2>8,t=255&r.charCodeAt((p+1)/2)):o=t=0/0),p+=3,n=e>>2,i=(3&e)<<4|o>>4,a=(15&o)<<2|t>>6,s=63&t,isNaN(o)?a=s=64:isNaN(t)&&(s=64),c=c+LZString._keyStr[n]+LZString._keyStr[i]+LZString._keyStr[a]+LZString._keyStr[s];return c},decompressFromBase64:function(r){if(null==r)return"";var e,o,t,n,i,a,s,c,p="",l=0,f=0,d=LZString._f;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");f>4,t=(15&a)<<4|s>>2,n=(3&s)<<6|c,l%2==0?(e=o<<8,64!=s&&(p+=d(e|t)),64!=c&&(e=n<<8)):(p+=d(e|o),64!=s&&(e=t<<8),64!=c&&(p+=d(e|n))),l+=3;return LZString.decompress(p)},compressToUTF16:function(r){if(null==r)return"";var e,o,t,n="",i=0,a=LZString._f;for(r=LZString.compress(r),e=0;e>1)+32),t=(1&o)<<14,i++;break;case 14:n+=a(t+(o>>15)+32,(32767&o)+32),i=0;break;default:n+=a(t+(o>>i+1)+32),t=(o&(2<>14),e=(16383&o)<<2;break;case 2:t+=a(e|o>>13),e=(8191&o)<<3;break;case 3:t+=a(e|o>>12),e=(4095&o)<<4;break;case 4:t+=a(e|o>>11),e=(2047&o)<<5;break;case 5:t+=a(e|o>>10),e=(1023&o)<<6;break;case 6:t+=a(e|o>>9),e=(511&o)<<7;break;case 7:t+=a(e|o>>8),e=(255&o)<<8;break;case 8:t+=a(e|o>>7),e=(127&o)<<9;break;case 9:t+=a(e|o>>6),e=(63&o)<<10;break;case 10:t+=a(e|o>>5),e=(31&o)<<11;break;case 11:t+=a(e|o>>4),e=(15&o)<<12;break;case 12:t+=a(e|o>>3),e=(7&o)<<13;break;case 13:t+=a(e|o>>2),e=(3&o)<<14;break;case 14:t+=a(e|o>>1),e=(1&o)<<15;break;case 15:t+=a(e|o),n=0}i++}return LZString.decompress(t)},compressToUint8Array:function(r){for(var e=LZString.compress(r),o=new Uint8Array(2*e.length),t=0,n=e.length;n>t;t++){var i=e.charCodeAt(t);o[2*t]=i>>>8,o[2*t+1]=i%256}return o},decompressFromUint8Array:function(r){if(null===r||void 0===r)return LZString.decompress(r);for(var e=new Array(r.length/2),o=0,t=e.length;t>o;o++)e[o]=256*r[2*o]+r[2*o+1];return LZString.decompress(String.fromCharCode.apply(null,e))},compressToEncodedURIComponent:function(r){return LZString.compressToBase64(r).replace(/=/g,"$").replace(/\//g,"-")},decompressFromEncodedURIComponent:function(r){return r&&(r=r.replace(/$/g,"=").replace(/-/g,"/")),LZString.decompressFromBase64(r)},compress:function(r){if(null==r)return"";var e,o,t,n={},i={},a="",s="",c="",p=2,l=3,f=2,d="",h=0,g=0,u=LZString._f;for(t=0;te;e++)h<<=1,15==g?(g=0,d+=u(h),h=0):g++;for(o=c.charCodeAt(0),e=0;8>e;e++)h=h<<1|1&o,15==g?(g=0,d+=u(h),h=0):g++,o>>=1}else{for(o=1,e=0;f>e;e++)h=h<<1|o,15==g?(g=0,d+=u(h),h=0):g++,o=0;for(o=c.charCodeAt(0),e=0;16>e;e++)h=h<<1|1&o,15==g?(g=0,d+=u(h),h=0):g++,o>>=1}p--,0==p&&(p=Math.pow(2,f),f++),delete i[c]}else for(o=n[c],e=0;f>e;e++)h=h<<1|1&o,15==g?(g=0,d+=u(h),h=0):g++,o>>=1;p--,0==p&&(p=Math.pow(2,f),f++),n[s]=l++,c=String(a)}if(""!==c){if(Object.prototype.hasOwnProperty.call(i,c)){if(c.charCodeAt(0)<256){for(e=0;f>e;e++)h<<=1,15==g?(g=0,d+=u(h),h=0):g++;for(o=c.charCodeAt(0),e=0;8>e;e++)h=h<<1|1&o,15==g?(g=0,d+=u(h),h=0):g++,o>>=1}else{for(o=1,e=0;f>e;e++)h=h<<1|o,15==g?(g=0,d+=u(h),h=0):g++,o=0;for(o=c.charCodeAt(0),e=0;16>e;e++)h=h<<1|1&o,15==g?(g=0,d+=u(h),h=0):g++,o>>=1}p--,0==p&&(p=Math.pow(2,f),f++),delete i[c]}else for(o=n[c],e=0;f>e;e++)h=h<<1|1&o,15==g?(g=0,d+=u(h),h=0):g++,o>>=1;p--,0==p&&(p=Math.pow(2,f),f++)}for(o=2,e=0;f>e;e++)h=h<<1|1&o,15==g?(g=0,d+=u(h),h=0):g++,o>>=1;for(;;){if(h<<=1,15==g){d+=u(h);break}g++}return d},decompress:function(r){if(null==r)return"";if(""==r)return null;var e,o,t,n,i,a,s,c,p=[],l=4,f=4,d=3,h="",g="",u=LZString._f,S={string:r,val:r.charCodeAt(0),position:32768,index:1};for(o=0;3>o;o+=1)p[o]=o;for(n=0,a=Math.pow(2,2),s=1;s!=a;)i=S.val&S.position,S.position>>=1,0==S.position&&(S.position=32768,S.val=S.string.charCodeAt(S.index++)),n|=(i>0?1:0)*s,s<<=1;switch(e=n){case 0:for(n=0,a=Math.pow(2,8),s=1;s!=a;)i=S.val&S.position,S.position>>=1,0==S.position&&(S.position=32768,S.val=S.string.charCodeAt(S.index++)),n|=(i>0?1:0)*s,s<<=1;c=u(n);break;case 1:for(n=0,a=Math.pow(2,16),s=1;s!=a;)i=S.val&S.position,S.position>>=1,0==S.position&&(S.position=32768,S.val=S.string.charCodeAt(S.index++)),n|=(i>0?1:0)*s,s<<=1;c=u(n);break;case 2:return""}for(p[3]=c,t=g=c;;){if(S.index>S.string.length)return"";for(n=0,a=Math.pow(2,d),s=1;s!=a;)i=S.val&S.position,S.position>>=1,0==S.position&&(S.position=32768,S.val=S.string.charCodeAt(S.index++)),n|=(i>0?1:0)*s,s<<=1;switch(c=n){case 0:for(n=0,a=Math.pow(2,8),s=1;s!=a;)i=S.val&S.position,S.position>>=1,0==S.position&&(S.position=32768,S.val=S.string.charCodeAt(S.index++)),n|=(i>0?1:0)*s,s<<=1;p[f++]=u(n),c=f-1,l--;break;case 1:for(n=0,a=Math.pow(2,16),s=1;s!=a;)i=S.val&S.position,S.position>>=1,0==S.position&&(S.position=32768,S.val=S.string.charCodeAt(S.index++)),n|=(i>0?1:0)*s,s<<=1;p[f++]=u(n),c=f-1,l--;break;case 2:return g}if(0==l&&(l=Math.pow(2,d),d++),p[c])h=p[c];else{if(c!==f)return null;h=t+t[0]}g+=h,p[f++]=t+h[0],l--,t=h,0==l&&(l=Math.pow(2,d),d++)}}};"undefined"!=typeof module&&null!=module&&(module.exports=LZString); \ No newline at end of file diff --git a/package.json b/package.json index a4d3199..948ad98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lz-string", - "version": "1.3.7", + "version": "1.3.8", "license": "WTFPL", "description": "LZ-based compression algorithm", "homepage": "http://pieroxy.net/blog/pages/lz-string/index.html",