mtxuilib 0.0.381 → 0.0.382

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var y=(r,e,t)=>new Promise((n,a)=>{var s=i=>{try{o(t.next(i))}catch(l){a(l)}},c=i=>{try{o(t.throw(i))}catch(l){a(l)}},o=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,c);o((t=t.apply(r,e)).next())});import{LRUCache as u}from"lru-cache";import{sha256WithAlphabets as f}from"mtxuilib/lib/utils";const d={max:500,maxSize:5e3,sizeCalculation:(r,e)=>1,ttl:1e3*30,allowStale:!1,updateAgeOnGet:!1,updateAgeOnHas:!1},h=new u(d),g=(r,e)=>{const n=new Request(r,e).headers.get("authorization");let a="";return e!=null&&e.body&&(a=e.body.toString()),f(r+n+a)};function w(r){return(e,t)=>y(this,null,function*(){const n=yield g(e,t),a=h.get(n);if(a)return new Response(new Uint8Array(a));{const s=yield r(e,t);if(s.status==200&&s.body){const[c,o]=s.body.tee();return p(n,o),new Response(c,s)}return s.clone()}})}function p(r,e){return y(this,null,function*(){const t=[];let n=!1;const a=yield e.getReader();for(;!n;){const{value:c,done:o}=yield a.read();n=o,c&&t.push(c)}const s=new Uint8Array(t.reduce((c,o)=>[...c,...Array.from(o)],[]));s.buffer.byteLength>0&&h.set(r,s.buffer)})}export{w as fetchMiddleWithCache};
1
+ var y=(r,e,t)=>new Promise((n,a)=>{var s=l=>{try{o(t.next(l))}catch(u){a(u)}},c=l=>{try{o(t.throw(l))}catch(u){a(u)}},o=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,c);o((t=t.apply(r,e)).next())});import{LRUCache as f}from"lru-cache";import{sha256WithAlphabets as i}from"../../../utils";const d={max:500,maxSize:5e3,sizeCalculation:(r,e)=>1,ttl:1e3*30,allowStale:!1,updateAgeOnGet:!1,updateAgeOnHas:!1},h=new f(d),p=(r,e)=>{const n=new Request(r,e).headers.get("authorization");let a="";return e!=null&&e.body&&(a=e.body.toString()),i(r+n+a)};function w(r){return(e,t)=>y(this,null,function*(){const n=yield p(e,t),a=h.get(n);if(a)return new Response(new Uint8Array(a));{const s=yield r(e,t);if(s.status==200&&s.body){const[c,o]=s.body.tee();return b(n,o),new Response(c,s)}return s.clone()}})}function b(r,e){return y(this,null,function*(){const t=[];let n=!1;const a=yield e.getReader();for(;!n;){const{value:c,done:o}=yield a.read();n=o,c&&t.push(c)}const s=new Uint8Array(t.reduce((c,o)=>[...c,...Array.from(o)],[]));s.buffer.byteLength>0&&h.set(r,s.buffer)})}export{w as fetchMiddleWithCache};