@whatwg-node/fetch 0.5.1 → 0.5.2-alpha-20221111153639-062b25b

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @whatwg-node/fetch
2
2
 
3
+ ## 0.5.2-alpha-20221111153639-062b25b
4
+
5
+ ### Patch Changes
6
+
7
+ - [#179](https://github.com/ardatan/whatwg-node/pull/179) [`1e7b5ec`](https://github.com/ardatan/whatwg-node/commit/1e7b5ecfcf9a35b0a46357389f1410e4b3150f2a) Thanks [@ardatan](https://github.com/ardatan)! - Fix destroy method for ReadableStream to Readable conversion
8
+
3
9
  ## 0.5.1
4
10
 
5
11
  ### Patch Changes
@@ -1,20 +1,25 @@
1
1
  const streams = require('stream');
2
2
 
3
3
  module.exports = function readableStreamToReadable(readableStream) {
4
- return streams.Readable.from({
5
- [Symbol.asyncIterator]() {
6
- const reader = readableStream.getReader();
7
- return {
8
- next() {
9
- return reader.read();
10
- },
11
- async return() {
4
+ const reader = readableStream.getReader();
5
+ return new streams.Readable({
6
+ read() {
7
+ reader.read().then(({ done, value }) => {
8
+ if (done) {
9
+ this.push(null);
10
+ } else {
11
+ this.push(value);
12
+ }
13
+ })
14
+ },
15
+ async destroy() {
16
+ try {
12
17
  reader.cancel();
13
18
  reader.releaseLock();
14
19
  await readableStream.cancel();
15
- return { done: true };
16
- }
20
+ } catch (error) {
21
+ console.log(error);
17
22
  }
18
23
  }
19
- });
24
+ })
20
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/fetch",
3
- "version": "0.5.1",
3
+ "version": "0.5.2-alpha-20221111153639-062b25b",
4
4
  "description": "Cross Platform Smart Fetch Ponyfill",
5
5
  "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
6
6
  "repository": {