@opennetwork/progressive-merge
TypeScript icon, indicating that this package has built-in type declarations

5.5.0 • Public • Published

Progressive Merge

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 async function *merge<T>(iterables: AsyncIterable<AsyncIterable<T>>): AsyncIterable<ReadonlyArray<T | undefined>> {

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

import { merge } from "@opennetwork/progressive-merge";

for await (const set of merge([[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 ]

Readme

Keywords

none

Package Sidebar

Install

npm i @opennetwork/progressive-merge

Weekly Downloads

4

Version

5.5.0

License

MIT

Unpacked Size

54.6 kB

Total Files

47

Last publish

Collaborators

  • virtualstate-user
  • shipper