Installations
npm install sub-events
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=18.0.0
Node Version
20.16.0
NPM Version
10.8.1
Score
85
Supply Chain
99.4
Quality
79.4
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.61%)
CSS (0.39%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
691,594
Last Day
1,163
Last Week
5,735
Last Month
23,781
Last Year
252,574
GitHub Statistics
MIT License
38 Stars
320 Commits
2 Forks
3 Watchers
4 Branches
1 Contributors
Updated on Oct 15, 2024
Bundle Size
6.97 kB
Minified
1.96 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.10.1
Package Id
sub-events@1.10.1
Unpacked Size
108.15 kB
Size
23.16 kB
File Count
28
NPM Version
10.8.1
Node Version
20.16.0
Published on
Oct 15, 2024
Total Downloads
Cumulative downloads
Total Downloads
691,594
Last Day
9.7%
1,163
Compared to previous day
Last Week
7.7%
5,735
Compared to previous week
Last Month
45%
23,781
Compared to previous month
Last Year
44.8%
252,574
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Strongly-Typed Events
Lightweight, strongly-typed events, with monitored subscriptions.
Install
1npm i sub-events
Usage
- On event-provider side:
1import {SubEvent} from 'sub-events'; 2 3// creating a strongly-typed event: 4const e: SubEvent<string> = new SubEvent(); 5 6// triggering the event when needed: 7e.emit('hello');
- On event-consumer side:
1// subscribing to the event: 2const sub = e.subscribe((data: string) => { 3 // data = 'hello' 4}); 5 6// cancel the subscription when no longer needed: 7sub.cancel();
API: Subscription, subscribe, cancel
Monitoring Subscriptions
Class SubEventCount extends SubEvent with event onCount, to observe the number of subscriptions:
1import {SubEventCount, ISubCountChange} from 'sub-events'; 2 3// creating a strongly-typed event: 4const e: SubEventCount<string> = new SubEventCount(); 5 6e.onCount.subscribe((info: ISubCountChange) => { 7 // number of subscriptions has changed; 8 // info = {newCount, prevCount} 9}); 10 11// any subscription will trigger event onCount: 12const sub = e.subscribe(data => {}); 13 14// cancelling a subscription will trigger onCount: 15sub.cancel();
API: SubEventCount, onCount
Browser
When including directly from HTML, you can access all types under subEvents
namespace:
1<script src="./node_modules/sub-events/dist"></script> 2<script> 3 const e = new subEvents.SubEvent(); 4 e.subscribe(data => { 5 // data received 6 }); 7</script>
Note that pre-built script includes only the core library, without the Extras, which you can bundle yourself as needed.

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities 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
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/vitaly-t/sub-events/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/vitaly-t/sub-events/ci.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:26
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
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 4 are checked with a SAST tool
Score
3.4
/10
Last Scanned on 2025-02-03
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 sub-events
eventemitter3
EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.
eventemitter2
A feature-rich Node.js event emitter implementation with namespaces, wildcards, TTL, async listeners and browser/worker support.
nanoevents
Simple and tiny (107 bytes) event emitter library
@pixi/runner
A simple alternative to events and signals with an emphasis on performance.