update, text, response
This commit is contained in:
30
node_modules/readable-web-to-node-stream/lib/index.js
generated
vendored
30
node_modules/readable-web-to-node-stream/lib/index.js
generated
vendored
@@ -11,7 +11,7 @@ const readable_stream_1 = require("readable-stream");
|
||||
class ReadableWebToNodeStream extends readable_stream_1.Readable {
|
||||
/**
|
||||
*
|
||||
* @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
|
||||
* @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
|
||||
*/
|
||||
constructor(stream) {
|
||||
super();
|
||||
@@ -25,24 +25,28 @@ class ReadableWebToNodeStream extends readable_stream_1.Readable {
|
||||
* the implementation should begin pushing that data into the read queue
|
||||
* https://nodejs.org/api/stream.html#stream_readable_read_size_1
|
||||
*/
|
||||
async _read() {
|
||||
_read() {
|
||||
// Should start pushing data into the queue
|
||||
// Read data from the underlying Web-API-readable-stream
|
||||
if (this.released) {
|
||||
this.push(null); // Signal EOF
|
||||
return;
|
||||
}
|
||||
this.pendingRead = this.reader.read();
|
||||
const data = await this.pendingRead;
|
||||
// clear the promise before pushing pushing new data to the queue and allow sequential calls to _read()
|
||||
delete this.pendingRead;
|
||||
if (data.done || this.released) {
|
||||
this.push(null); // Signal EOF
|
||||
}
|
||||
else {
|
||||
this.bytesRead += data.value.length;
|
||||
this.push(data.value); // Push new data to the queue
|
||||
}
|
||||
this.pendingRead = this.reader
|
||||
.read()
|
||||
.then((data) => {
|
||||
delete this.pendingRead;
|
||||
if (data.done || this.released) {
|
||||
this.push(null); // Signal EOF
|
||||
}
|
||||
else {
|
||||
this.bytesRead += data.value.length;
|
||||
this.push(data.value); // Push new data to the queue
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.destroy(err);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* If there is no unresolved read call to Web-API ReadableStream immediately returns;
|
||||
|
||||
Reference in New Issue
Block a user