Socket
Socket
Sign inDemoInstall

stream-to-it

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-to-it - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

duplex.js

8

package.json
{
"name": "stream-to-it",
"version": "0.1.1",
"version": "0.2.0",
"description": "Convert Node.js streams to streaming iterables",
"main": "src/index.js",
"main": "index.js",
"scripts": {

@@ -26,7 +26,7 @@ "test": "ava test/*.test.js --verbose",

"ava": "^2.2.0",
"bl": "^3.0.0",
"bl": "^4.0.0",
"it-pipe": "^1.0.1",
"nyc": "^14.1.1",
"p-fifo": "^1.0.0",
"standard": "^13.1.0",
"standard": "^14.3.1",
"streaming-iterables": "^4.1.0"

@@ -33,0 +33,0 @@ },

@@ -33,2 +33,12 @@ # stream-to-it

Also works with browser [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream):
```js
const res = fetch('http://example.org/file.jpg')
for await (const chunk of toIterable.source(res.body)) {
console.log(chunk.toString())
}
```
### Convert writable stream to sink iterable

@@ -35,0 +45,0 @@

@@ -22,1 +22,23 @@ const test = require('ava')

})
test('should convert browser ReadableStream to source iterable', async t => {
const input = Array.from(Array(randomInt(5, 10)), () => randomBytes(1, 512))
let i = 0
// Like a Response object you get from a call to fetch() in the browser
const response = {
body: {
getReader () {
return {
read () {
const value = input[i++]
return value == null ? { done: true } : { value }
},
releaseLock () {}
}
}
}
}
const output = await collect(toIterable.source(response.body))
t.deepEqual(input, output)
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc