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

mergeiterator

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mergeiterator - npm Package Compare versions

Comparing version 1.1.0 to 1.1.3

2

package.json
{
"name": "mergeiterator",
"version": "1.1.0",
"version": "1.1.3",
"description": "merges async iterators",

@@ -5,0 +5,0 @@ "keywords": [

@@ -8,3 +8,3 @@ # mergeIterator

Pass it a collection of iterables and it'll return an iterator, which will contain all values from those iterables. Those iterables and the collection of them can be arrays, calls to generators, or any other kind of iterable, synchronous or async, finite or infinite.
Pass it a collection of iterables and it'll return an [async iterator](https://github.com/tc39/proposal-async-iteration), which will contain all values from those iterables. Those iterables and the collection of them can be arrays, calls to generators, or any other kind of iterable, synchronous or async, finite or infinite.

@@ -15,7 +15,12 @@ ```js

async function DoIt() {
for await (const v of merge([
[1,2,3],
(function *() { let i = 6; while (true) yield (i++) })(),
(async function *() { yield await Promise.resolve(4); yield Promise.resolve(5) })(),
])) {
const array = [1,2,3]
function *generator() {
let i = 6
while (true) yield (i++)
})
async function *asyncGenerator() {
yield await Promise.resolve(4)
yield Promise.resolve(5)
})
for await (const v of merge([array, generator(), asyncGenerator()])) {
console.log(v)

@@ -29,3 +34,3 @@ }

Be aware, that `mergeIterator` will wait for any promise yielded by some iterable to be resolved before yielding its value and before asking that iterable for the rest of new values.
If some iterable yields a promise, its value will be yielded, not a promise itself.

@@ -32,0 +37,0 @@ If some iterable throws an error, that error will be redirected to a caller and other iterables will be closed.

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