@whatwg-node/node-fetch 0.4.5 → 0.4.6-alpha-20230613174518-6c0120e
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/cjs/Body.js +11 -4
- package/esm/Body.js +11 -4
- package/package.json +1 -1
package/cjs/Body.js
CHANGED
@@ -232,14 +232,21 @@ function processBodyInit(bodyInit) {
|
|
232
232
|
};
|
233
233
|
}
|
234
234
|
if (typeof bodyInit === 'string') {
|
235
|
-
|
236
|
-
const contentLength = buffer.byteLength;
|
235
|
+
let contentLength;
|
237
236
|
return {
|
238
237
|
bodyType: BodyInitType.String,
|
239
238
|
contentType: 'text/plain;charset=UTF-8',
|
240
|
-
contentLength
|
239
|
+
get contentLength() {
|
240
|
+
if (contentLength == null) {
|
241
|
+
contentLength = Buffer.byteLength(bodyInit);
|
242
|
+
}
|
243
|
+
return contentLength;
|
244
|
+
},
|
245
|
+
set contentLength(value) {
|
246
|
+
contentLength = value;
|
247
|
+
},
|
241
248
|
bodyFactory() {
|
242
|
-
const readable = stream_1.Readable.from(
|
249
|
+
const readable = stream_1.Readable.from(bodyInit);
|
243
250
|
return new ReadableStream_js_1.PonyfillReadableStream(readable);
|
244
251
|
},
|
245
252
|
};
|
package/esm/Body.js
CHANGED
@@ -227,14 +227,21 @@ function processBodyInit(bodyInit) {
|
|
227
227
|
};
|
228
228
|
}
|
229
229
|
if (typeof bodyInit === 'string') {
|
230
|
-
|
231
|
-
const contentLength = buffer.byteLength;
|
230
|
+
let contentLength;
|
232
231
|
return {
|
233
232
|
bodyType: BodyInitType.String,
|
234
233
|
contentType: 'text/plain;charset=UTF-8',
|
235
|
-
contentLength
|
234
|
+
get contentLength() {
|
235
|
+
if (contentLength == null) {
|
236
|
+
contentLength = Buffer.byteLength(bodyInit);
|
237
|
+
}
|
238
|
+
return contentLength;
|
239
|
+
},
|
240
|
+
set contentLength(value) {
|
241
|
+
contentLength = value;
|
242
|
+
},
|
236
243
|
bodyFactory() {
|
237
|
-
const readable = Readable.from(
|
244
|
+
const readable = Readable.from(bodyInit);
|
238
245
|
return new PonyfillReadableStream(readable);
|
239
246
|
},
|
240
247
|
};
|