Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
1.6 KiB
Plaintext
1 line
1.6 KiB
Plaintext
{"version":3,"sources":["../../../src/uploads/fetchAPI-stream-file/index.ts"],"sourcesContent":["import fs from 'fs'\n\nexport function iteratorToStream(iterator: AsyncIterator<Uint8Array>) {\n return new ReadableStream({\n async pull(controller) {\n const { done, value } = await iterator.next()\n if (done) {\n controller.close()\n } else {\n controller.enqueue(value)\n }\n },\n })\n}\n\nexport async function* nodeStreamToIterator(stream: fs.ReadStream) {\n for await (const chunk of stream) {\n yield new Uint8Array(chunk)\n }\n}\n\nexport function streamFile({\n filePath,\n options,\n}: {\n filePath: string\n options?: { end?: number; start?: number }\n}): ReadableStream {\n const nodeStream = fs.createReadStream(filePath, options)\n const data: ReadableStream = iteratorToStream(nodeStreamToIterator(nodeStream))\n return data\n}\n"],"names":["fs","iteratorToStream","iterator","ReadableStream","pull","controller","done","value","next","close","enqueue","nodeStreamToIterator","stream","chunk","Uint8Array","streamFile","filePath","options","nodeStream","createReadStream","data"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AAEnB,OAAO,SAASC,iBAAiBC,QAAmC;IAClE,OAAO,IAAIC,eAAe;QACxB,MAAMC,MAAKC,UAAU;YACnB,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAG,MAAML,SAASM,IAAI;YAC3C,IAAIF,MAAM;gBACRD,WAAWI,KAAK;YAClB,OAAO;gBACLJ,WAAWK,OAAO,CAACH;YACrB;QACF;IACF;AACF;AAEA,OAAO,gBAAgBI,qBAAqBC,MAAqB;IAC/D,WAAW,MAAMC,SAASD,OAAQ;QAChC,MAAM,IAAIE,WAAWD;IACvB;AACF;AAEA,OAAO,SAASE,WAAW,EACzBC,QAAQ,EACRC,OAAO,EAIR;IACC,MAAMC,aAAalB,GAAGmB,gBAAgB,CAACH,UAAUC;IACjD,MAAMG,OAAuBnB,iBAAiBU,qBAAqBO;IACnE,OAAOE;AACT"} |