@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 +6 -0
- package/dist/readableStreamToReadable.js +16 -11
- package/package.json +1 -1
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
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
|
-
|
|
16
|
-
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.log(error);
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
|
-
})
|
|
24
|
+
})
|
|
20
25
|
}
|