A library for making RxJS support async-await for-await loops via AsyncIterables
Installations
npm install rxjs-for-await
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
14.15.4
NPM Version
7.7.6
Score
87.7
Supply Chain
99.7
Quality
75.5
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (73.89%)
JavaScript (26.11%)
Developer
benlesh
Download Statistics
Total Downloads
101,451,867
Last Day
4,824
Last Week
159,262
Last Month
657,844
Last Year
11,234,630
GitHub Statistics
198 Stars
29 Commits
2 Forks
6 Watching
4 Branches
3 Contributors
Package Meta Information
Latest Version
1.0.0
Package Id
rxjs-for-await@1.0.0
Unpacked Size
141.96 kB
Size
26.51 kB
File Count
23
NPM Version
7.7.6
Node Version
14.15.4
Publised On
10 Nov 2021
Total Downloads
Cumulative downloads
Total Downloads
101,451,867
Last day
-14.5%
4,824
Compared to previous day
Last week
-4.5%
159,262
Compared to previous week
Last month
-15.8%
657,844
Compared to previous month
Last year
-57.9%
11,234,630
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
rxjs-for-await
A library for making RxJS support async-await for-await loops via AsyncIterables
Four Strategies
This library exposes 4 different ways to consume an RxJS observable with an async/await for await..of
loop using AsyncIterable
. Each of these strategies has pros and cons, so be aware of those as you choose the one that suits your needs.
eachValueFrom (lossless)
1async function example() { 2 const source$ = interval(100); 3 4 for await (const value of eachValueFrom(source$)) { 5 console.log(value); 6 } 7}
This strategy will yield every single value the observable source emits, one at a time, until the observable completes or errors.
Pros
- All values are yielded
- You get each value one at a time
Cons
- Creates more memory pressure if the body of the
for await
loop takes longer to come back around than the time between emissions from the observable source. If the observable emits faster than your loop can consume them, this may result in a memory leak.
bufferedValuesFrom (lossless)
1async function example() { 2 const source$ = interval(10); 3 4 for await (const buffer of bufferedValuesFrom(source$)) { 5 console.log(buffer); 6 await wait(1000); 7 } 8}
Keep an internal buffer of values emitted by the observable source, and yield the entire buffer to the for await
loop. Continue this until the observable source completes or errors.
Pros
- All values are yielded
- Lower memory pressure than
eachValueFrom
- Provides snapshots of what has happened since the last loop
Cons
- May still cause out of memory errors if the body of the
for await
loop is extremely slow. - Perhaps less intuitive than
eachValueFrom
.
latestValueFrom (lossy)
1async function example() { 2 const source$ = interval(100); 3 4 for await (const value of latestValueFrom(source$)) { 5 console.log(value); 6 } 7}
This strategy will immediately yield the most recently arrived value, or the very next one, if the for await
loop is waiting and one has not arrived yet. Will continue
to do so until the source observable completes or errors.
Pros
- No chance of memory leaks
- Quick entry to the loop if a value is already available
Cons
- Will lose values if more than one value arrives while the loop body is being processed.
nextValueFrom (lossy)
1async function example() { 2 const source$ = interval(100); 3 4 for await (const value of nextValueFrom(source$)) { 5 console.log(value); 6 } 7}
Will wait for the very next value to arrive, then yield it. Will continue to do so until the source observable completes or errors.
Pros
- No chance of memory leaks
Cons
- Loop must wait for the next value to arrive, perhaps slowing down the process
- Will lose values if values arrive while the loop is being processed.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/benlesh/rxjs-for-await/node.js.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/benlesh/rxjs-for-await/node.js.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/node.js.yml:1
- Info: no jobLevel write permissions found
Reason
Found 2/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Reason
15 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.7
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to rxjs-for-await
evt
Type safe replacement for node's EventEmitter
async-await-rx
Extension for rxjs library
@nathanpb/rxjs-async-iterator
Converts async iterators from RxJS observables to consume in for-await-of loops
rxjs-async-iterator
Converts async iterators from RxJS observables to consume in for-await-of loops