Gathering detailed insights and metrics for @teamteanpm2024/sequi-molestias-recusandae
Gathering detailed insights and metrics for @teamteanpm2024/sequi-molestias-recusandae
Gathering detailed insights and metrics for @teamteanpm2024/sequi-molestias-recusandae
Gathering detailed insights and metrics for @teamteanpm2024/sequi-molestias-recusandae
npm install @teamteanpm2024/sequi-molestias-recusandae
Typescript
Module System
Node Version
NPM Version
49.2
Supply Chain
32.1
Quality
79.8
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
-75%
2
Compared to previous week
Last month
20%
12
Compared to previous month
Last year
0%
417
Compared to previous year
37
Combine async iterators into an object that conforms to theasync iterable and async iterator protocol.
npm i @teamteanpm2024/sequi-molestias-recusandae
Yields an array (method
: all
or allSettled
) or a single value (method
: race
or any
) when the passed promise concurrency method returns a value.
Return when the first async iterator returns (lazy
: true
) or return when the last async iterator returns (lazy
: false
)
1new AsyncIteratorsCombine( 2 iterable, 3 { 4 returnAsyncIterators = Array.from(iterable), 5 method = 'all', 6 lazy = false, 7 initialValue = undefined, 8 } = {} 9)
iterable
(required): AsyncIterator[]
options
(optional): an object that has the following optional properties:
method
: 'all'
, 'allSettled'
, 'race'
, 'any'
(default: all
)`
lazy
: true
, false
(default: false
)
initialValue
: any
(default: undefined
)
returnAsyncIterators
: AsyncIterator[]
(default: all async iterators that are passed into iterable
)
returnAsyncIterators
are returned when the combined async iterator is returned.Yields an array of all latest yielded values for every async iterator.
Start when the first async iterator yields (eager
: true
) or start when all async iterators have yielded (eager
: false
).
1new CombineLatest( 2 iterable, 3 { 4 returnAsyncIterators = Array.from(iterable), 5 eager = false, 6 lazy = false, 7 initialValue = undefined, 8 } = {} 9)
1import { AsyncIteratorsCombine } from '@teamteanpm2024/sequi-molestias-recusandae'; 2 3async function* generator1() { 4 yield 1; 5 yield 2; 6 yield 3; 7} 8 9async function* generator2() { 10 yield 'a'; 11 yield 'b'; 12 yield 'c'; 13 yield 'd'; 14 yield 'e'; 15} 16 17const combination = new AsyncIteratorsCombine([generator1, generator2]); 18 19for await (const output of combination) { 20 console.log(output); // -> [1, 'a'], [2, 'b'], [3, 'c'], [3, 'd'], [3, 'e'] 21} 22 23const combination2 = new AsyncIteratorsCombine([generator1, generator2], { lazy: true }); 24 25for await (const output of combination2) { 26 console.log(output); // -> [1, 'a'], [2, 'b'], [3, 'c'] 27}
1import { AsyncIteratorsCombine } from '@teamteanpm2024/sequi-molestias-recusandae'; 2 3async function* generator1() { 4 await new Promise((resolve) => { 5 setTimeout(resolve, 100); 6 }); 7 yield 1; 8 await new Promise((resolve) => { 9 setTimeout(resolve, 100); 10 }); 11 yield 2; 12 await new Promise((resolve) => { 13 setTimeout(resolve, 100); 14 }); 15 yield 3; 16} 17 18async function* generator2() { 19 await new Promise((resolve) => { 20 setTimeout(resolve, 50); 21 }); 22 yield 'a'; 23 await new Promise((resolve) => { 24 setTimeout(resolve, 20); 25 }); 26 yield 'b'; 27 await new Promise((resolve) => { 28 setTimeout(resolve, 100); 29 }); 30 yield 'c'; 31} 32 33const combination = new AsyncIteratorsCombine([generator1, generator2], { method: 'race' }); 34 35for await (const output of combination) { 36 console.log(output); // -> 'a', 'b', 1, 'c', 2, 3 37} 38 39const combination2 = new AsyncIteratorsCombine([generator1, generator2], { 40 method: 'race', 41 lazy: true, 42}); 43 44for await (const output of combination2) { 45 console.log(output); // -> 'a', 'b', 1, 'c' 46}
1import { CombineLatest } from '@teamteanpm2024/sequi-molestias-recusandae'; 2 3async function* generator1() { 4 await new Promise((resolve) => { 5 setTimeout(resolve, 100); 6 }); 7 yield 1; 8 await new Promise((resolve) => { 9 setTimeout(resolve, 100); 10 }); 11 yield 2; 12 await new Promise((resolve) => { 13 setTimeout(resolve, 100); 14 }); 15 yield 3; 16} 17 18async function* generator2() { 19 await new Promise((resolve) => { 20 setTimeout(resolve, 50); 21 }); 22 yield 'a'; 23 await new Promise((resolve) => { 24 setTimeout(resolve, 20); 25 }); 26 yield 'b'; 27 await new Promise((resolve) => { 28 setTimeout(resolve, 100); 29 }); 30 yield 'c'; 31} 32 33const combination = new CombineLatest([generator1, generator2]); 34 35for await (const output of combination) { 36 console.log(output); // -> [1, 'a'], [1, 'b'], [1, 'c'], [2, 'c'], [3, 'c'] 37} 38 39const combination2 = new CombineLatest([generator1, generator2], { 40 eager: true, 41}); 42 43for await (const output of combination2) { 44 console.log(output); // -> [undefined, 'a'], [undefined, 'b'], [1, 'c'], [2, 'c'], [3, 'c'] 45}
No vulnerabilities found.
No security vulnerabilities found.