async-iterator-to-pull-stream
Advanced tools
Comparing version 1.0.1 to 1.1.0
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) |
{ | ||
"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", |
32
test.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() | ||
}) | ||
) | ||
}) |
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
5542
102