-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchunk-GWKXUGLE.js
More file actions
4 lines (3 loc) · 1.15 KB
/
chunk-GWKXUGLE.js
File metadata and controls
4 lines (3 loc) · 1.15 KB
1
2
3
4
import{n as h}from"./chunk-GUHHCQYK.js";import{a as c,b as f,i as m,j as l}from"./chunk-OW75ZOQB.js";var T=`
`,d=`
`,p=":",u=e=>(e??"").trim()!=="";function A(){let e="";return new TransformStream({transform(r,o){e+=r;let t=e.split(T);t.slice(0,-1).forEach(n=>{u(n)&&o.enqueue(n)}),e=t[t.length-1]},flush(r){u(e)&&r.enqueue(e)}})}function E(){return new TransformStream({transform(e,r){let t=e.split(d).reduce((n,s)=>{let a=s.indexOf(p);if(a===-1)throw new Error(`The key-value separator "${p}" is not found in the sse line chunk!`);let i=s.slice(0,a);if(!u(i))return n;let S=s.slice(a+1);return f(c({},n),{[i]:S})},{});Object.keys(t).length!==0&&r.enqueue(t)}})}function R(e){let{readableStream:r,transformStream:o}=e;if(!(r instanceof ReadableStream))throw new Error("The options.readableStream must be an instance of ReadableStream.");let t=new TextDecoderStream,n=o?r.pipeThrough(t).pipeThrough(o):r.pipeThrough(t).pipeThrough(A()).pipeThrough(E());return n[Symbol.asyncIterator]=function(){return l(this,null,function*(){let s=this.getReader();for(;;){let{done:a,value:i}=yield new m(s.read());if(a)break;i&&(yield i)}})},n}function g(e){return h(R(e))}export{R as a,g as b};