ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
5 lines (3 loc) • 1.14 kB
JavaScript
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=`
`,h=`
`,c=":",u=e=>(e??"").trim()!=="";function d(){let e="";return new TransformStream({transform(t,o){e+=t;const r=e.split(f);r.slice(0,-1).forEach(n=>{u(n)&&o.enqueue(n)}),e=r[r.length-1]},flush(t){u(e)&&t.enqueue(e)}})}function m(){return new TransformStream({transform(e,t){const r=e.split(h).reduce((n,s)=>{const a=s.indexOf(c);if(a===-1)throw new Error(`The key-value separator "${c}" is not found in the sse line chunk!`);const i=s.slice(0,a);if(!u(i))return n;const l=s.slice(a+1);return{...n,[i]:l}},{});Object.keys(r).length!==0&&t.enqueue(r)}})}function S(e){const{readableStream:t,transformStream:o}=e;if(!(t instanceof ReadableStream))throw new Error("The options.readableStream must be an instance of ReadableStream.");const r=new TextDecoderStream,n=o?t.pipeThrough(r).pipeThrough(o):t.pipeThrough(r).pipeThrough(d()).pipeThrough(m());return n[Symbol.asyncIterator]=async function*(){const s=this.getReader();for(;;){const{done:a,value:i}=await s.read();if(a)break;i&&(yield i)}},n}exports.default=S;
;