Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-iterator-to-pull-stream

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-iterator-to-pull-stream - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

8

index.js
module.exports = iterator => {
if (!iterator.next) {
if (iterator[Symbol.asyncIterator]) {
iterator = iterator[Symbol.asyncIterator]()
} else if (iterator[Symbol.iterator]) {
iterator = iterator[Symbol.iterator]()
}
}
return async (end, cb) => {

@@ -3,0 +11,0 @@ if (end) return cb(end)

2

package.json
{
"name": "async-iterator-to-pull-stream",
"version": "1.0.1",
"version": "1.1.0",
"description": "Convert a (async) iterator to a pull stream",

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

@@ -66,1 +66,33 @@ const test = require('ava')

})
test.cb('should accept iterable', t => {
const sourceValues = [1, 2, 3, 4, 5]
pull(
toPull(sourceValues),
pull.collect((err, values) => {
t.falsy(err)
t.deepEqual(values, sourceValues)
t.end()
})
)
})
test.cb('should accept async iterable', t => {
const sourceValues = [1, 2, 3, 4, 5]
const iterator = async function * () {
for (let i = 0; i < sourceValues.length; i++) {
yield await futureValue(sourceValues[i], sourceValues[i])
}
}
pull(
toPull({ [Symbol.asyncIterator]: () => iterator() }),
pull.collect((err, values) => {
t.falsy(err)
t.deepEqual(values, sourceValues)
t.end()
})
)
})
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