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.0 to 0.1.1

2

package.json
{
"name": "stream-to-it",
"version": "0.1.0",
"version": "0.1.1",
"description": "Convert Node.js streams to streaming iterables",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -89,2 +89,7 @@ # stream-to-it

## Related
* [`it-to-stream`](https://www.npmjs.com/package/it-to-stream) Convert streaming iterables to Node.js streams
* [`it-pipe`](https://www.npmjs.com/package/it-pipe) Utility to "pipe" async iterables together
## Contribute

@@ -91,0 +96,0 @@

@@ -33,2 +33,11 @@ const getIterator = require('get-iterator')

const getNext = async () => {
try {
return source.next()
} catch (err) {
writable.destroy(err)
return errPromise.promise
}
}
try {

@@ -42,3 +51,3 @@ while (true) {

finishPromise.promise,
source.next()
getNext()
])

@@ -45,0 +54,0 @@

@@ -130,1 +130,25 @@ const test = require('ava')

})
test('should destroy writable stream if source throws', async t => {
const input = Array.from(Array(randomInt(5, 10)), () => randomBytes(1, 512))
const output = []
const source = {
[Symbol.iterator]: function * () {
yield * input[Symbol.iterator]()
throw new Error('boom')
}
}
const stream = new Writable({
write (chunk, enc, cb) {
output.push(chunk)
cb()
}
})
const err = await t.throwsAsync(pipe(source, toIterable.sink(stream)))
t.is(err.message, 'boom')
t.true(stream.destroyed)
})
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