UNPKG

cache-manager-soumojit-shome

Version:

A lightweight utility for managing cache in web applications using the browser's Cache API.

1 lines 5.33 kB
(function(_0x59f904,_0x50ac6e){const _0x34e857=a0_0x3426,_0x4c617a=_0x59f904();while(!![]){try{const _0x1d8e76=parseInt(_0x34e857(0x1b3))/0x1*(parseInt(_0x34e857(0x1c7))/0x2)+parseInt(_0x34e857(0x1c0))/0x3*(-parseInt(_0x34e857(0x1b7))/0x4)+parseInt(_0x34e857(0x1c8))/0x5+-parseInt(_0x34e857(0x1b1))/0x6+-parseInt(_0x34e857(0x1bc))/0x7+parseInt(_0x34e857(0x1cb))/0x8+-parseInt(_0x34e857(0x1ca))/0x9*(parseInt(_0x34e857(0x1ac))/0xa);if(_0x1d8e76===_0x50ac6e)break;else _0x4c617a['push'](_0x4c617a['shift']());}catch(_0x5efb47){_0x4c617a['push'](_0x4c617a['shift']());}}}(a0_0x4fa3,0xeb8d7));const a0_0x4d4c6f=(function(){let _0xae88e3=!![];return function(_0x3694b5,_0xa629a8){const _0x1c4edd=_0xae88e3?function(){const _0x2c4e57=a0_0x3426;if(_0xa629a8){const _0x1cb39c=_0xa629a8[_0x2c4e57(0x1c4)](_0x3694b5,arguments);return _0xa629a8=null,_0x1cb39c;}}:function(){};return _0xae88e3=![],_0x1c4edd;};}()),a0_0x2f000c=a0_0x4d4c6f(this,function(){const _0x397c86=a0_0x3426;return a0_0x2f000c['toString']()[_0x397c86(0x1c9)]('(((.+)+)+)+$')[_0x397c86(0x1c2)]()['constructor'](a0_0x2f000c)['search']('(((.+)+)+)+$');});a0_0x2f000c();const AddDataIntoCache=async(_0x3de20f,_0x2eb052,_0x342cec=0x3e8*0x3c*0x1e,_0x119505,_0x2b1b7f)=>{const _0x5e55ff=a0_0x3426;try{if(typeof window===_0x5e55ff(0x1bb)||!(_0x5e55ff(0x1bd)in window))return{'success':![],'message':'Cache\x20API\x20not\x20supported'};const _0x120ea2=_0x2b1b7f+'/'+_0x3de20f,_0x380902={'data':_0x2eb052,'expiry':Date[_0x5e55ff(0x1b2)]()+_0x342cec},_0x2e3b20=await caches['open'](_0x119505);return await _0x2e3b20[_0x5e55ff(0x1b6)](_0x120ea2,new Response(JSON[_0x5e55ff(0x1b5)](_0x380902))),{'success':!![]};}catch(_0x249b40){return console[_0x5e55ff(0x1c6)](_0x5e55ff(0x1b9),_0x249b40),{'success':![],'error':_0x249b40['message']};}},GetDataFromCache=async(_0x27ddfc,_0x2bcba7,_0x1b11b3)=>{const _0x509064=a0_0x3426;try{if(typeof window==='undefined'||!(_0x509064(0x1bd)in window))return{'success':![],'message':'Cache\x20API\x20not\x20supported'};const _0x34535e=_0x1b11b3+'/'+_0x27ddfc,_0x5602a1=await caches[_0x509064(0x1ae)](_0x2bcba7),_0x7360ff=await _0x5602a1[_0x509064(0x1c3)](_0x34535e);if(!_0x7360ff)return{'success':![],'message':_0x509064(0x1ad)};const _0x22c47a=await _0x7360ff[_0x509064(0x1bf)](),{data:_0x3a258c,expiry:_0x4b24e6}=_0x22c47a;if(Date[_0x509064(0x1b2)]()>_0x4b24e6)return await _0x5602a1['delete'](_0x34535e),{'success':![],'message':_0x509064(0x1af)};return{'success':!![],'data':_0x3a258c};}catch(_0x45edf0){return console[_0x509064(0x1c6)](_0x509064(0x1b4),_0x45edf0),{'success':![],'error':_0x45edf0[_0x509064(0x1be)]};}},UpdateDataInCache=async(_0x1fefbf,_0x556d09,_0x281059,_0x463958)=>{const _0xef5ff6=a0_0x3426;try{if(typeof window===_0xef5ff6(0x1bb)||!('caches'in window))return{'success':![],'message':'Cache\x20API\x20not\x20supported'};const _0x390919=_0x463958+'/'+_0x1fefbf,_0x49eca7=await caches[_0xef5ff6(0x1ae)](_0x281059),_0x55bcc5=await _0x49eca7['match'](_0x390919);if(!_0x55bcc5)return{'success':![],'message':_0xef5ff6(0x1ad)};const _0x17feed=await _0x55bcc5[_0xef5ff6(0x1bf)](),_0x48d845={..._0x17feed,'data':{..._0x17feed[_0xef5ff6(0x1b0)],..._0x556d09}};return await _0x49eca7[_0xef5ff6(0x1b6)](_0x390919,new Response(JSON[_0xef5ff6(0x1b5)](_0x48d845))),{'success':!![],'data':_0x48d845};}catch(_0x5c4725){return console[_0xef5ff6(0x1c6)](_0xef5ff6(0x1c1),_0x5c4725),{'success':![],'error':_0x5c4725[_0xef5ff6(0x1be)]};}},DeleteDataFromCache=async(_0x2e30ca,_0x19a2a7,_0x254304)=>{const _0x50ba36=a0_0x3426;try{if(typeof window===_0x50ba36(0x1bb)||!('caches'in window))return{'success':![],'message':_0x50ba36(0x1b8)};const _0x5c5389=_0x254304+'/'+_0x2e30ca,_0x20b894=await caches['open'](_0x19a2a7),_0x16a881=await _0x20b894[_0x50ba36(0x1c3)](_0x5c5389);return _0x16a881&&await _0x20b894[_0x50ba36(0x1c5)](_0x5c5389),{'success':!![]};}catch(_0xd653c9){return console[_0x50ba36(0x1c6)]('Failed\x20to\x20delete\x20cache\x20data:',_0xd653c9),{'success':![],'error':_0xd653c9['message']};}},ClearWholeCacheData=async _0x301d66=>{const _0x16b211=a0_0x3426;try{if(typeof window===_0x16b211(0x1bb)||!(_0x16b211(0x1bd)in window))return{'success':![],'message':_0x16b211(0x1b8)};const _0x46c4d2=await caches['delete'](_0x301d66);return{'success':_0x46c4d2};}catch(_0x2ea8f2){return console['error'](_0x16b211(0x1ba),_0x2ea8f2),{'success':![],'error':_0x2ea8f2['message']};}};function a0_0x4fa3(){const _0x382ad8=['11119797duBWaS','5192016oEmNKf','10HOUjNb','Data\x20not\x20found\x20in\x20cache','open','Cache\x20expired','data','1717350yLEXnl','now','118616hpvTQS','Failed\x20to\x20retrieve\x20cache\x20data:','stringify','put','12vFmsLv','Cache\x20API\x20not\x20supported','Failed\x20to\x20add\x20data\x20to\x20cache:','Failed\x20to\x20clear\x20cache:','undefined','9512832sRiDqD','caches','message','json','137685aPutwb','Failed\x20to\x20update\x20cache\x20data:','toString','match','apply','delete','error','30xLUHrg','7775000aDDyhn','search'];a0_0x4fa3=function(){return _0x382ad8;};return a0_0x4fa3();}function a0_0x3426(_0x4c24b5,_0x514974){const _0x4f8f45=a0_0x4fa3();return a0_0x3426=function(_0x2f000c,_0x4d4c6f){_0x2f000c=_0x2f000c-0x1ac;let _0x4fa3d4=_0x4f8f45[_0x2f000c];return _0x4fa3d4;},a0_0x3426(_0x4c24b5,_0x514974);}export{AddDataIntoCache,GetDataFromCache,DeleteDataFromCache,UpdateDataInCache,ClearWholeCacheData};