New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@virtualstate/union

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@virtualstate/union

Concurrent union

latest
Source
npmnpm
Version
2.48.1
Version published
Weekly downloads
227
163.95%
Maintainers
1
Weekly downloads
 
Created
Source

union

  • CodeSandbox Demo 1
  • CodeSandbox Demo 2

Take a set of async iterations and turn them into an array of the latest values for that iterator.

This is the general function signature to achieve this:

export type Input<T> = AsyncIterable<T> | Iterable<T>;
export type UnionInput<T> = Input<Input<T>>;
export async function *union<T>(input: UnionInput<T>): AsyncIterable<(T | undefined)[]> {

This allows us to take multiple functions producing values and group an update set together.

import { union } from "@virtualstate/union";

for await (const set of union([[1, 2, 3, 4], [5, 6, 7, 8, 9]])) {
    console.log(set);
}

The above logs:

[ 1, 5 ]
[ 2, 6 ]
[ 3, 7 ]
[ 4, 8 ]
[ 4, 9 ]

Keywords

virtual-state

FAQs

Package last updated on 05 Apr 2022

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