@whatwg-node/fetch
Advanced tools
Comparing version 0.5.1 to 0.5.2-alpha-20221111153639-062b25b
# @whatwg-node/fetch | ||
## 0.5.2-alpha-20221111153639-062b25b | ||
### Patch Changes | ||
- [#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 | ||
## 0.5.1 | ||
@@ -4,0 +10,0 @@ |
const streams = require('stream'); | ||
module.exports = function readableStreamToReadable(readableStream) { | ||
return streams.Readable.from({ | ||
[Symbol.asyncIterator]() { | ||
const reader = readableStream.getReader(); | ||
return { | ||
next() { | ||
return reader.read(); | ||
}, | ||
async return() { | ||
const reader = readableStream.getReader(); | ||
return new streams.Readable({ | ||
read() { | ||
reader.read().then(({ done, value }) => { | ||
if (done) { | ||
this.push(null); | ||
} else { | ||
this.push(value); | ||
} | ||
}) | ||
}, | ||
async destroy() { | ||
try { | ||
reader.cancel(); | ||
reader.releaseLock(); | ||
await readableStream.cancel(); | ||
return { done: true }; | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
}); | ||
}) | ||
} |
{ | ||
"name": "@whatwg-node/fetch", | ||
"version": "0.5.1", | ||
"version": "0.5.2-alpha-20221111153639-062b25b", | ||
"description": "Cross Platform Smart Fetch Ponyfill", | ||
@@ -5,0 +5,0 @@ "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26661
548