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

merge-async-iterators

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge-async-iterators

Merge multiple async iterators

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
172
decreased by-68.15%
Maintainers
1
Weekly downloads
 
Created
Source

merge-async-iterators

A simple async iterators merger

Requires ES2018 Async Iteration

Install

npm i merge-async-iterators

Usage

API

merge([...iterators], opts)

  • iterators Array of async iterables

  • opts

    • yieldIterator[=false] Yields {iterator, value} (instead of value)

      Useful if you wanna know which iterator yielded the value

  • Returns A single merged async iterable

Example

const merge = require('merge-async-iterators');

const array = [1,2];
const iterable = (function*(){
  yield 3
  yield 4
})()
const asyncIterable = (async function*(){
  yield 5
  yield 6
})()

for await (const value of merge([array, iterable, asyncIterable])) {
  console.log(value)
}
1
2          // order isn't guaranteed
undefined  // finished iterators' returns will yield as well
3
4
undefined
5          // async wil almost always come after normal ones
6

Alternatives

FAQs

Package last updated on 18 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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