"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,a;for(;r<n;)a=r+t,yield e.slice(r,a),r=a},s=async function*(e,t){for await(const n of w(e))yield*d(n,t)},w=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},h=(e,t,n,r)=>{const a=s(e,t);let u=0,c,o=l=>{c||(c=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:i,value:y}=await a.next();if(i){o(),l.close();return}let f=y.byteLength;if(n){let b=u+=f;n(b)}l.enqueue(new Uint8Array(y))}catch(i){throw o(i),i}},cancel(l){return o(l),a.return()}},{highWaterMark:2})};exports.readBytes=s;exports.streamChunk=d;exports.trackStream=h;
//# sourceMappingURL=index.cjs386.js.map
