@whatwg-node/node-fetch
Advanced tools
Comparing version 0.0.1-alpha-20221225160313-0935cfd to 0.0.1-alpha-20221225172458-8684a84
28
index.js
@@ -57,5 +57,7 @@ 'use strict'; | ||
function createController(desiredSize, readable) { | ||
let enqueued = false; | ||
return { | ||
desiredSize, | ||
enqueue(chunk) { | ||
enqueued = true; | ||
readable.push(chunk); | ||
@@ -69,2 +71,5 @@ }, | ||
}, | ||
get enqueued() { | ||
return enqueued; | ||
} | ||
}; | ||
@@ -106,10 +111,23 @@ } | ||
else { | ||
let waitingForPull = false; | ||
this.readable = new stream.Readable({ | ||
read(desiredSize) { | ||
async read(desiredSize) { | ||
var _a, _b; | ||
if (!started) { | ||
started = true; | ||
(_a = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.start) === null || _a === void 0 ? void 0 : _a.call(underlyingSource, createController(desiredSize, this)); | ||
if (waitingForPull) { | ||
return; | ||
} | ||
(_b = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.pull) === null || _b === void 0 ? void 0 : _b.call(underlyingSource, createController(desiredSize, this)); | ||
waitingForPull = true; | ||
try { | ||
const controller = createController(desiredSize, this); | ||
if (!started) { | ||
started = true; | ||
await ((_a = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.start) === null || _a === void 0 ? void 0 : _a.call(underlyingSource, controller)); | ||
} | ||
if (!controller.enqueued) { | ||
await ((_b = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.pull) === null || _b === void 0 ? void 0 : _b.call(underlyingSource, controller)); | ||
} | ||
} | ||
finally { | ||
waitingForPull = false; | ||
} | ||
}, | ||
@@ -116,0 +134,0 @@ async destroy(err, callback) { |
{ | ||
"name": "@whatwg-node/node-fetch", | ||
"version": "0.0.1-alpha-20221225160313-0935cfd", | ||
"version": "0.0.1-alpha-20221225172458-8684a84", | ||
"description": "Fetch API implementation for Node", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58063
1581