@whatwg-node/node-fetch 0.4.17 → 0.4.18

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/Blob.js CHANGED
@@ -104,16 +104,21 @@ class PonyfillBlob {
104
104
  },
105
105
  });
106
106
  }
107
- let partQueue = [];
107
+ let blobPartIterator;
108
108
  return new ReadableStream_js_1.PonyfillReadableStream({
109
109
  start: controller => {
110
- partQueue = [...this.blobParts];
111
- if (partQueue.length === 0) {
110
+ if (this.blobParts.length === 0) {
112
111
  controller.close();
112
+ return;
113
113
  }
114
+ blobPartIterator = this.blobParts[Symbol.iterator]();
114
115
  },
115
116
  pull: controller => {
116
- const blobPart = partQueue.pop();
117
+ const { value: blobPart, done } = blobPartIterator.next();
118
+ if (done) {
119
+ controller.close();
120
+ return;
121
+ }
117
122
  if (blobPart) {
118
123
  if (isBlob(blobPart)) {
119
124
  return blobPart.arrayBuffer().then(arrayBuffer => {
@@ -126,9 +131,6 @@ class PonyfillBlob {
126
131
  controller.enqueue(buf);
127
132
  }
128
133
  }
129
- else {
130
- controller.close();
131
- }
132
134
  },
133
135
  });
134
136
  }
package/esm/Blob.js CHANGED
@@ -101,16 +101,21 @@ export class PonyfillBlob {
101
101
  },
102
102
  });
103
103
  }
104
- let partQueue = [];
104
+ let blobPartIterator;
105
105
  return new PonyfillReadableStream({
106
106
  start: controller => {
107
- partQueue = [...this.blobParts];
108
- if (partQueue.length === 0) {
107
+ if (this.blobParts.length === 0) {
109
108
  controller.close();
109
+ return;
110
110
  }
111
+ blobPartIterator = this.blobParts[Symbol.iterator]();
111
112
  },
112
113
  pull: controller => {
113
- const blobPart = partQueue.pop();
114
+ const { value: blobPart, done } = blobPartIterator.next();
115
+ if (done) {
116
+ controller.close();
117
+ return;
118
+ }
114
119
  if (blobPart) {
115
120
  if (isBlob(blobPart)) {
116
121
  return blobPart.arrayBuffer().then(arrayBuffer => {
@@ -123,9 +128,6 @@ export class PonyfillBlob {
123
128
  controller.enqueue(buf);
124
129
  }
125
130
  }
126
- else {
127
- controller.close();
128
- }
129
131
  },
130
132
  });
131
133
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.4.17",
3
+ "version": "0.4.18",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {