@whatwg-node/node-fetch 0.7.0 → 0.7.1-rc-20241109111058-bd38077b07868e822050d730897ea8c60aa6d77e

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.
@@ -181,14 +181,26 @@ class PonyfillReadableStream {
181
181
  }
182
182
  }
183
183
  pipeThrough({ writable, readable, }) {
184
- this.pipeTo(writable);
184
+ this.pipeTo(writable).catch(err => {
185
+ this.readable.destroy(err);
186
+ });
187
+ if (isPonyfillReadableStream(readable)) {
188
+ readable.readable.once('error', err => this.readable.destroy(err));
189
+ readable.readable.once('finish', () => this.readable.push(null));
190
+ }
185
191
  return readable;
186
192
  }
187
193
  static [Symbol.hasInstance](instance) {
188
194
  return isReadableStream(instance);
189
195
  }
196
+ static from(iterable) {
197
+ return new PonyfillReadableStream(stream_1.Readable.from(iterable));
198
+ }
190
199
  }
191
200
  exports.PonyfillReadableStream = PonyfillReadableStream;
201
+ function isPonyfillReadableStream(obj) {
202
+ return obj?.readable != null;
203
+ }
192
204
  function isPonyfillWritableStream(obj) {
193
205
  return obj?.writable != null;
194
206
  }
@@ -178,12 +178,24 @@ export class PonyfillReadableStream {
178
178
  }
179
179
  }
180
180
  pipeThrough({ writable, readable, }) {
181
- this.pipeTo(writable);
181
+ this.pipeTo(writable).catch(err => {
182
+ this.readable.destroy(err);
183
+ });
184
+ if (isPonyfillReadableStream(readable)) {
185
+ readable.readable.once('error', err => this.readable.destroy(err));
186
+ readable.readable.once('finish', () => this.readable.push(null));
187
+ }
182
188
  return readable;
183
189
  }
184
190
  static [Symbol.hasInstance](instance) {
185
191
  return isReadableStream(instance);
186
192
  }
193
+ static from(iterable) {
194
+ return new PonyfillReadableStream(Readable.from(iterable));
195
+ }
196
+ }
197
+ function isPonyfillReadableStream(obj) {
198
+ return obj?.readable != null;
187
199
  }
188
200
  function isPonyfillWritableStream(obj) {
189
201
  return obj?.writable != null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.7.0",
3
+ "version": "0.7.1-rc-20241109111058-bd38077b07868e822050d730897ea8c60aa6d77e",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -16,4 +16,5 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
16
16
  readable: ReadableStream<T2>;
17
17
  }): ReadableStream<T2>;
18
18
  static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
19
+ static from<T>(iterable: AsyncIterable<T> | Iterable<T>): PonyfillReadableStream<T>;
19
20
  }
@@ -16,4 +16,5 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
16
16
  readable: ReadableStream<T2>;
17
17
  }): ReadableStream<T2>;
18
18
  static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
19
+ static from<T>(iterable: AsyncIterable<T> | Iterable<T>): PonyfillReadableStream<T>;
19
20
  }