{"mappings":";;kwBAAA,IAAAA,EAAAC,EAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CAAE,MAAO,EAAK,CAAC,EAC5DA,EAAQ,wBAA0B,OAClC,IAAMC,EAAoB,EAAQ,iBAAiB,EAO7CC,EAAN,cAAsCD,EAAkB,QAAS,CAK7D,YAAYE,EAAQ,CAChB,MAAM,EACN,KAAK,UAAY,EACjB,KAAK,SAAW,GAChB,KAAK,OAASA,EAAO,UAAU,CACnC,CAOA,MAAM,OAAQ,CAGV,GAAI,KAAK,SAAU,CACf,KAAK,KAAK,IAAI,EACd,MACJ,CACA,KAAK,YAAc,KAAK,OAAO,KAAK,EACpC,IAAMC,EAAO,MAAM,KAAK,YAExB,OAAO,KAAK,YACRA,EAAK,MAAQ,KAAK,SAClB,KAAK,KAAK,IAAI,GAGd,KAAK,WAAaA,EAAK,MAAM,OAC7B,KAAK,KAAKA,EAAK,KAAK,EAE5B,CAKA,MAAM,uBAAwB,CACtB,KAAK,aACL,MAAM,KAAK,WAEnB,CAIA,MAAM,OAAQ,CACV,MAAM,KAAK,eAAe,CAC9B,CACA,MAAM,gBAAiB,CACnB,KAAK,SAAW,GAChB,MAAM,KAAK,sBAAsB,EACjC,MAAM,KAAK,OAAO,YAAY,CAClC,CACJ,EACAJ,EAAQ,wBAA0BE,ICnElC,IAAAG,EAAsB,OAA2C,CAAE,WAAAC,EAAW,wBAAAC,CAAwB,EAAIF,EAAYG,EAAa,WAAWH","names":["require_lib","__commonJSMin","exports","readable_stream_1","ReadableWebToNodeStream","stream","data","cjsm","__esModule","ReadableWebToNodeStream","endpoint_default"],"sources":["../esm/npm/readable-web-to-node-stream@3.0.2/node_modules/readable-web-to-node-stream/lib/index.js","endpoint.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ReadableWebToNodeStream = void 0;\nconst readable_stream_1 = require(\"readable-stream\");\n/**\n * Converts a Web-API stream into Node stream.Readable class\n * Node stream readable: https://nodejs.org/api/stream.html#stream_readable_streams\n * Web API readable-stream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream\n * Node readable stream: https://nodejs.org/api/stream.html#stream_readable_streams\n */\nclass ReadableWebToNodeStream extends readable_stream_1.Readable {\n    /**\n     *\n     * @param stream Readable​Stream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream\n     */\n    constructor(stream) {\n        super();\n        this.bytesRead = 0;\n        this.released = false;\n        this.reader = stream.getReader();\n    }\n    /**\n     * Implementation of readable._read(size).\n     * When readable._read() is called, if data is available from the resource,\n     * the implementation should begin pushing that data into the read queue\n     * https://nodejs.org/api/stream.html#stream_readable_read_size_1\n     */\n    async _read() {\n        // Should start pushing data into the queue\n        // Read data from the underlying Web-API-readable-stream\n        if (this.released) {\n            this.push(null); // Signal EOF\n            return;\n        }\n        this.pendingRead = this.reader.read();\n        const data = await this.pendingRead;\n        // clear the promise before pushing pushing new data to the queue and allow sequential calls to _read()\n        delete this.pendingRead;\n        if (data.done || this.released) {\n            this.push(null); // Signal EOF\n        }\n        else {\n            this.bytesRead += data.value.length;\n            this.push(data.value); // Push new data to the queue\n        }\n    }\n    /**\n     * If there is no unresolved read call to Web-API Readable​Stream immediately returns;\n     * otherwise will wait until the read is resolved.\n     */\n    async waitForReadToComplete() {\n        if (this.pendingRead) {\n            await this.pendingRead;\n        }\n    }\n    /**\n     * Close wrapper\n     */\n    async close() {\n        await this.syncAndRelease();\n    }\n    async syncAndRelease() {\n        this.released = true;\n        await this.waitForReadToComplete();\n        await this.reader.releaseLock();\n    }\n}\nexports.ReadableWebToNodeStream = ReadableWebToNodeStream;\n//# sourceMappingURL=index.js.map","import * as cjsm from \"readable-web-to-node-stream\";export const { __esModule,ReadableWebToNodeStream } = cjsm;export default cjsm.default ?? cjsm;"],"version":3}
