UNPKG

async-lz-string

Version:
2 lines 12.8 kB
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(()=>(()=>{"use strict";var t={48:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.decompressFromUTF16=e.compressToUTF16=e.decompressFromBase64=e.compressToBase64=void 0;var o=n(304),i=n(134),s=new o.CompressorImpl,u=new i.DecompressorImpl,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l={};e.compressToBase64=function(t){return r(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return null===t?[2,""]:[4,s.compress(t,6,(function(t){return c.charAt(t)}))];case 1:switch((e=n.sent()).length%4){default:case 0:return[2,e];case 1:return[2,e+"==="];case 2:return[2,e+"=="];case 3:return[2,e+"="]}return[2]}}))}))},e.decompressFromBase64=function(t){return r(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return null===t?[2,""]:""===t?[2,null]:[4,u.decompress(t.length,32,(function(e){return function(t,e){if(!l[t]){l[t]={};for(var n=0;n<t.length;n++)l[t][t.charAt(n)]=n}return l[t][e]}(c,t.charAt(e))}))];case 1:return[2,e.sent()]}}))}))},e.compressToUTF16=function(t){return r(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return null===t?[2,""]:[4,s.compress(t,15,(function(t){return String.fromCharCode(t+32)}))];case 1:return[2,e.sent()+" "]}}))}))},e.decompressFromUTF16=function(t){return r(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return null===t?[2,""]:""===t?[2,null]:[4,u.decompress(t.length,16384,(function(e){return t.charCodeAt(e)-32}))];case 1:return[2,e.sent()]}}))}))}},304:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CompressorImpl=void 0;var o=n(658),i=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],s=function(){function t(){}return t.writeValueToData=function(t,e,n,r,a){if(n%4!=0||t.dataPosition+n>r-1)for(var o=0;o<n;o++)t.dataVal=t.dataVal<<1|1&e,t.dataPosition==r-1?(t.dataPosition=0,t.data.push(a(t.dataVal)),t.dataVal=0):t.dataPosition++,e>>=1;else t.dataVal<<=n,t.dataVal|=function(t,e){for(var n=0,r=0;r<e;++r)n<<=4,n|=i[15&t],t>>=4;return n}(e,n/4),t.dataPosition+=n},t.writeWToDataVal=function(e,n,r){e.dictionaryToCreate.has(e.w)?(e.w.charCodeAt(0)<256?(t.writeValueToData(e,0,e.numBits,n,r),t.writeValueToData(e,e.w.charCodeAt(0),8,n,r)):(t.writeValueToData(e,1,e.numBits,n,r),t.writeValueToData(e,e.w.charCodeAt(0),16,n,r)),e.enlargeIn--,0==e.enlargeIn&&(e.enlargeIn=Math.pow(2,e.numBits),e.numBits++),e.dictionaryToCreate.delete(e.w)):t.writeValueToData(e,e.dictionary.get(e.w),e.numBits,n,r),e.enlargeIn--,0==e.enlargeIn&&(e.enlargeIn=Math.pow(2,e.numBits),e.numBits++)},t.loopIteration=function(t,e,n,r,a){var o=t.charAt(e);a.dictionary.has(o)||(a.dictionary.set(o,a.dictSize++),a.dictionaryToCreate.set(o,!0));var i=a.w+o;a.dictionary.has(i)?a.w=i:(this.writeWToDataVal(a,n,r),a.dictionary.set(i,a.dictSize++),a.w=String(o))},t.prototype.compress=function(e,n,i){var s=this;return new Promise((function(u){return r(s,void 0,void 0,(function(){var r,s;return a(this,(function(a){switch(a.label){case 0:if(null==e)return u(""),[2];r={data:[],dataPosition:0,dataVal:0,dictionary:new Map,dictionaryToCreate:new Map,dictSize:3,enlargeIn:2,numBits:2,w:""},s=0,a.label=1;case 1:return s<e.length?(t.loopIteration(e,s,n,i,r),s%1e4!=0?[3,3]:[4,(0,o.wait)()]):[3,4];case 2:a.sent(),a.label=3;case 3:return s+=1,[3,1];case 4:return""!==r.w&&t.writeWToDataVal(r,n,i),t.writeValueToData(r,2,r.numBits,n,i),r.dataVal<<=n-r.dataPosition,r.data.push(i(r.dataVal)),u(r.data.join("")),[2]}}))}))}))},t}();e.CompressorImpl=s},134:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DecompressorImpl=void 0;var o=n(658),i=function(){function t(){}return t.prototype.decompress=function(t,e,n){var i=this;return new Promise((function(s){return r(i,void 0,void 0,(function(){var r,i,u;return a(this,(function(a){switch(a.label){case 0:for(r={bits:0,c:null,dataIndex:1,dataPosition:e,dataVal:n(0),dictionary:new Map,dictSize:4,enlargeIn:4,entry:"",maxPower:Math.pow(2,2),numBits:3,power:1,resb:null,result:[],w:null},i=0;i<3;i+=1)r.dictionary.set(i,i);for(;r.power!=r.maxPower;)r.resb=r.dataVal&r.dataPosition,r.dataPosition>>=1,0==r.dataPosition&&(r.dataPosition=e,r.dataVal=n(r.dataIndex++)),r.bits|=(r.resb>0?1:0)*r.power,r.power<<=1;switch(r.bits){case 0:for(r.bits=0,r.maxPower=Math.pow(2,8),r.power=1;r.power!=r.maxPower;)r.resb=r.dataVal&r.dataPosition,r.dataPosition>>=1,0==r.dataPosition&&(r.dataPosition=e,r.dataVal=n(r.dataIndex++)),r.bits|=(r.resb>0?1:0)*r.power,r.power<<=1;r.c=String.fromCharCode(r.bits);break;case 1:for(r.bits=0,r.maxPower=Math.pow(2,16),r.power=1;r.power!==r.maxPower;)r.resb=r.dataVal&r.dataPosition,r.dataPosition>>=1,0===r.dataPosition&&(r.dataPosition=e,r.dataVal=n(r.dataIndex++)),r.bits|=(r.resb>0?1:0)*r.power,r.power<<=1;r.c=String.fromCharCode(r.bits);break;case 2:return s(""),[2]}r.dictionary[3]=r.c,r.w=r.c,r.result.push(r.c),u=1,a.label=1;case 1:return u%2e4!=0?[3,3]:[4,(0,o.wait)()];case 2:a.sent(),a.label=3;case 3:if(r.dataIndex>t)return s(""),[2];for(r.bits=0,r.maxPower=Math.pow(2,r.numBits),r.power=1;r.power!=r.maxPower;)r.resb=r.dataVal&r.dataPosition,r.dataPosition>>=1,0==r.dataPosition&&(r.dataPosition=e,r.dataVal=n(r.dataIndex++)),r.bits|=(r.resb>0?1:0)*r.power,r.power<<=1;switch(r.c=r.bits){case 0:for(r.bits=0,r.maxPower=Math.pow(2,8),r.power=1;r.power!==r.maxPower;)r.resb=r.dataVal&r.dataPosition,r.dataPosition>>=1,0==r.dataPosition&&(r.dataPosition=e,r.dataVal=n(r.dataIndex++)),r.bits|=(r.resb>0?1:0)*r.power,r.power<<=1;r.dictionary[r.dictSize++]=String.fromCharCode(r.bits),r.c=r.dictSize-1,r.enlargeIn--;break;case 1:for(r.bits=0,r.maxPower=Math.pow(2,16),r.power=1;r.power!==r.maxPower;)r.resb=r.dataVal&r.dataPosition,r.dataPosition>>=1,0==r.dataPosition&&(r.dataPosition=e,r.dataVal=n(r.dataIndex++)),r.bits|=(r.resb>0?1:0)*r.power,r.power<<=1;r.dictionary[r.dictSize++]=String.fromCharCode(r.bits),r.c=r.dictSize-1,r.enlargeIn--;break;case 2:return s(r.result.join("")),[2]}if(0==r.enlargeIn&&(r.enlargeIn=Math.pow(2,r.numBits),r.numBits++),r.dictionary[r.c])r.entry=r.dictionary[r.c];else{if(r.c!==r.dictSize)return s(null),[2];r.entry=r.w+r.w.charAt(0)}return r.result.push(r.entry),r.dictionary[r.dictSize++]=r.w+r.entry.charAt(0),r.enlargeIn--,r.w=r.entry,0==r.enlargeIn&&(r.enlargeIn=Math.pow(2,r.numBits),r.numBits++),u++,[3,1];case 4:return[2]}}))}))}))},t}();e.DecompressorImpl=i},658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.wait=void 0,e.wait=function(){return n(this,void 0,void 0,(function(){return r(this,(function(t){return[2,new Promise((function(t){setTimeout(t,0)}))]}))}))}}},e={};return function n(r){var a=e[r];if(void 0!==a)return a.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.exports}(48)})())); //# sourceMappingURL=async-lz-string.js.map