Gathering detailed insights and metrics for @async-generators/subject
Gathering detailed insights and metrics for @async-generators/subject
Gathering detailed insights and metrics for @async-generators/subject
Gathering detailed insights and metrics for @async-generators/subject
npm install @async-generators/subject
Typescript
Module System
Min. Node Version
Node Version
NPM Version
73.9
Supply Chain
97.3
Quality
75.3
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
424,875
Last Day
65
Last Week
688
Last Month
2,971
Last Year
30,783
MIT License
3 Stars
17 Commits
2 Forks
1 Watchers
1 Branches
2 Contributors
Updated on Jan 28, 2023
Minified
Minified + Gzipped
Latest Version
0.5.0
Package Id
@async-generators/subject@0.5.0
Size
6.38 kB
NPM Version
5.6.0
Node Version
9.4.0
Cumulative downloads
Total Downloads
Last Day
-35%
65
Compared to previous day
Last Week
11.5%
688
Compared to previous week
Last Month
2.1%
2,971
Compared to previous month
Last Year
-0.5%
30,783
Compared to previous year
push items to pulling iterators
npm install @async-generators/subject --save
yarn add @async-generators/subject
This package's main
entry points to a commonjs
dist.
The module
entry points to a es2015
module dist. Both require native async-generator support, or be down-compiled with a webpack loader.
Subject
that provides three methods: next(item)
, error(err)
, and done()
to push data and events. When [Symbol.asyncIterator]
is called an internal subscription is created. pushed items are buffered (per iterator) until they are pulled by the consuming iterator. If the consuming iterator pulls items slower than the speed they are pushed to the subject, then the internal buffer will continue to grow in size. error(err)
will cause the iterator to rethrow the given error to the consumer and dispose of the subject.
example.js
1const {Subject} = require('@async-generators/subject'); 2 3let subject = new Subject<number>(); 4 5async function* source(){ 6 yield 1; yield 2; yield 3; yield 4; 7} 8 9async function main() { 10 let reader = async function () { 11 for await (let item of subject) { 12 console.log("PULL:", item); 13 } 14 }; 15 16 let readers = [reader(), reader()]; 17 18 let writer = async function () { 19 for await (let item of source()){ 20 console.log("PUSH:", item); 21 subject.next(item); 22 } 23 subject.done(); 24 } 25 26 await writer(); 27 await Promise.all(readers); 28} 29 30main().catch(console.log);
Execute with the latest node.js 9:
node --harmony example.js
output:
PUSH: 1
PUSH: 2
PULL: 1
PULL: 1
PUSH: 3
PULL: 2
PULL: 2
PUSH: 4
PULL: 3
PULL: 3
PULL: 4
PULL: 4
This library is fully typed and can be imported using:
1import {Subject} from '@async-generators/subject');
It is also possible to directly execute your properly configured typescript with ts-node:
ts-node --harmony foo.ts
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/16 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
55 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
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 More