@whatwg-node/node-fetch 0.0.7-alpha-20230209162208-3a05ba1 → 0.0.7-alpha-20230209162718-3d431bf

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.
Files changed (3) hide show
  1. package/index.js +4 -4
  2. package/index.mjs +4 -4
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -229,7 +229,7 @@ function getBlobPartAsBuffer(blobPart) {
229
229
  }
230
230
  }
231
231
  function isBlob(obj) {
232
- return obj != null && typeof obj === 'object' && obj.stream != null;
232
+ return obj != null && typeof obj === 'object' && obj.arrayBuffer != null;
233
233
  }
234
234
  // Will be removed after v14 reaches EOL
235
235
  // Needed because v14 doesn't have .stream() implemented
@@ -301,9 +301,9 @@ class PonyfillBlob {
301
301
  const blobPart = partQueue.pop();
302
302
  if (blobPart) {
303
303
  if (isBlob(blobPart)) {
304
- for await (const chunk of blobPart.stream()) {
305
- controller.enqueue(chunk);
306
- }
304
+ const arrayBuffer = await blobPart.arrayBuffer();
305
+ const buf = Buffer.from(arrayBuffer, undefined, blobPart.size);
306
+ controller.enqueue(buf);
307
307
  }
308
308
  else {
309
309
  const buf = getBlobPartAsBuffer(blobPart);
package/index.mjs CHANGED
@@ -223,7 +223,7 @@ function getBlobPartAsBuffer(blobPart) {
223
223
  }
224
224
  }
225
225
  function isBlob(obj) {
226
- return obj != null && typeof obj === 'object' && obj.stream != null;
226
+ return obj != null && typeof obj === 'object' && obj.arrayBuffer != null;
227
227
  }
228
228
  // Will be removed after v14 reaches EOL
229
229
  // Needed because v14 doesn't have .stream() implemented
@@ -295,9 +295,9 @@ class PonyfillBlob {
295
295
  const blobPart = partQueue.pop();
296
296
  if (blobPart) {
297
297
  if (isBlob(blobPart)) {
298
- for await (const chunk of blobPart.stream()) {
299
- controller.enqueue(chunk);
300
- }
298
+ const arrayBuffer = await blobPart.arrayBuffer();
299
+ const buf = Buffer.from(arrayBuffer, undefined, blobPart.size);
300
+ controller.enqueue(buf);
301
301
  }
302
302
  else {
303
303
  const buf = getBlobPartAsBuffer(blobPart);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.0.7-alpha-20230209162208-3a05ba1",
3
+ "version": "0.0.7-alpha-20230209162718-3d431bf",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {