@whatwg-node/node-fetch 0.0.1-alpha-20221225160313-0935cfd → 0.0.1-alpha-20221225173053-f9310f6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +24 -8
- package/index.mjs +24 -8
- package/package.json +1 -1
package/index.js
CHANGED
@@ -54,9 +54,11 @@ class PonyfillAbortController {
|
|
54
54
|
}
|
55
55
|
|
56
56
|
function createController(desiredSize, readable) {
|
57
|
+
let enqueued = false;
|
57
58
|
return {
|
58
59
|
desiredSize,
|
59
60
|
enqueue(chunk) {
|
61
|
+
enqueued = true;
|
60
62
|
readable.push(chunk);
|
61
63
|
},
|
62
64
|
close() {
|
@@ -65,6 +67,9 @@ function createController(desiredSize, readable) {
|
|
65
67
|
error(error) {
|
66
68
|
readable.destroy(error);
|
67
69
|
},
|
70
|
+
get enqueued() {
|
71
|
+
return enqueued;
|
72
|
+
}
|
68
73
|
};
|
69
74
|
}
|
70
75
|
class PonyfillReadableStream {
|
@@ -101,14 +106,27 @@ class PonyfillReadableStream {
|
|
101
106
|
});
|
102
107
|
}
|
103
108
|
else {
|
109
|
+
let waitingForPull = false;
|
104
110
|
this.readable = new stream.Readable({
|
105
|
-
read(desiredSize) {
|
111
|
+
async read(desiredSize) {
|
106
112
|
var _a, _b;
|
107
|
-
if (
|
108
|
-
|
109
|
-
|
113
|
+
if (waitingForPull) {
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
waitingForPull = true;
|
117
|
+
try {
|
118
|
+
const controller = createController(desiredSize, this);
|
119
|
+
if (!started) {
|
120
|
+
started = true;
|
121
|
+
await ((_a = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.start) === null || _a === void 0 ? void 0 : _a.call(underlyingSource, controller));
|
122
|
+
}
|
123
|
+
if (!controller.enqueued) {
|
124
|
+
await ((_b = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.pull) === null || _b === void 0 ? void 0 : _b.call(underlyingSource, controller));
|
125
|
+
}
|
126
|
+
}
|
127
|
+
finally {
|
128
|
+
waitingForPull = false;
|
110
129
|
}
|
111
|
-
(_b = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.pull) === null || _b === void 0 ? void 0 : _b.call(underlyingSource, createController(desiredSize, this));
|
112
130
|
},
|
113
131
|
async destroy(err, callback) {
|
114
132
|
var _a;
|
@@ -435,9 +453,7 @@ class PonyfillHeaders {
|
|
435
453
|
if (this.map.has(key)) {
|
436
454
|
value = this.map.get(key) + ', ' + value;
|
437
455
|
}
|
438
|
-
|
439
|
-
this.map.set(key, value);
|
440
|
-
}
|
456
|
+
this.map.set(key, value);
|
441
457
|
}
|
442
458
|
get(name) {
|
443
459
|
const key = name.toLowerCase();
|
package/index.mjs
CHANGED
@@ -50,9 +50,11 @@ class PonyfillAbortController {
|
|
50
50
|
}
|
51
51
|
|
52
52
|
function createController(desiredSize, readable) {
|
53
|
+
let enqueued = false;
|
53
54
|
return {
|
54
55
|
desiredSize,
|
55
56
|
enqueue(chunk) {
|
57
|
+
enqueued = true;
|
56
58
|
readable.push(chunk);
|
57
59
|
},
|
58
60
|
close() {
|
@@ -61,6 +63,9 @@ function createController(desiredSize, readable) {
|
|
61
63
|
error(error) {
|
62
64
|
readable.destroy(error);
|
63
65
|
},
|
66
|
+
get enqueued() {
|
67
|
+
return enqueued;
|
68
|
+
}
|
64
69
|
};
|
65
70
|
}
|
66
71
|
class PonyfillReadableStream {
|
@@ -97,14 +102,27 @@ class PonyfillReadableStream {
|
|
97
102
|
});
|
98
103
|
}
|
99
104
|
else {
|
105
|
+
let waitingForPull = false;
|
100
106
|
this.readable = new Readable({
|
101
|
-
read(desiredSize) {
|
107
|
+
async read(desiredSize) {
|
102
108
|
var _a, _b;
|
103
|
-
if (
|
104
|
-
|
105
|
-
|
109
|
+
if (waitingForPull) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
waitingForPull = true;
|
113
|
+
try {
|
114
|
+
const controller = createController(desiredSize, this);
|
115
|
+
if (!started) {
|
116
|
+
started = true;
|
117
|
+
await ((_a = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.start) === null || _a === void 0 ? void 0 : _a.call(underlyingSource, controller));
|
118
|
+
}
|
119
|
+
if (!controller.enqueued) {
|
120
|
+
await ((_b = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.pull) === null || _b === void 0 ? void 0 : _b.call(underlyingSource, controller));
|
121
|
+
}
|
122
|
+
}
|
123
|
+
finally {
|
124
|
+
waitingForPull = false;
|
106
125
|
}
|
107
|
-
(_b = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.pull) === null || _b === void 0 ? void 0 : _b.call(underlyingSource, createController(desiredSize, this));
|
108
126
|
},
|
109
127
|
async destroy(err, callback) {
|
110
128
|
var _a;
|
@@ -431,9 +449,7 @@ class PonyfillHeaders {
|
|
431
449
|
if (this.map.has(key)) {
|
432
450
|
value = this.map.get(key) + ', ' + value;
|
433
451
|
}
|
434
|
-
|
435
|
-
this.map.set(key, value);
|
436
|
-
}
|
452
|
+
this.map.set(key, value);
|
437
453
|
}
|
438
454
|
get(name) {
|
439
455
|
const key = name.toLowerCase();
|
package/package.json
CHANGED