Installations
npm install @elegantdb/events
Developer Guide
Typescript
No
Module System
ESM
Min. Node Version
>=15.0.0
Node Version
20.2.0
NPM Version
9.6.6
Score
68.2
Supply Chain
94.5
Quality
75.4
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
Nicat-dcw
Download Statistics
Total Downloads
571
Last Day
1
Last Week
2
Last Month
8
Last Year
125
GitHub Statistics
1 Stars
13 Commits
1 Watching
2 Branches
1 Contributors
Package Meta Information
Latest Version
1.0.1
Package Id
@elegantdb/events@1.0.1
Unpacked Size
6.34 kB
Size
2.37 kB
File Count
5
NPM Version
9.6.6
Node Version
20.2.0
Publised On
19 Aug 2023
Total Downloads
Cumulative downloads
Total Downloads
571
Last day
0%
1
Compared to previous day
Last week
-33.3%
2
Compared to previous week
Last month
33.3%
8
Compared to previous month
Last year
-72%
125
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
No dependencies detected.
1# ElegantDB EventEmitter
2
3`ElegantDB EventEmitter` is a lightweight and simple event emitter module designed specifically for the `elegantdb` module.
4
5## Installation
6
7You can install the `elegantdb` module using npm:
8
9```bash
10npm install @elegantdb/events
Usage
Here's how you can use the ElegantDB EventEmitter
in your project:
1const { EventEmitter } = require('@elegantdb/events'); 2 3// Create a new instance of ElegantDB EventEmitter 4const emitter = new EventEmitter(); 5 6// Define event listeners 7const onConnect = () => { 8 console.log('Connected to the database'); 9}; 10 11const onDataReceived = data => { 12 console.log('Received data:', data); 13}; 14 15// Register event listeners 16emitter.on('connect', onConnect); 17emitter.on('data', onDataReceived); 18 19// Emit events 20emitter.emit('connect'); // Outputs: Connected to the database 21emitter.emit('data', 'Sample data'); // Outputs: Received data: Sample data 22 23// Check if a specific listener is registered for an event 24console.log(emitter.hasListener('connect', onConnect)); // Outputs: true 25console.log(emitter.hasListener('disconnect', onConnect)); // Outputs: false 26 27// Remove an event listener 28emitter.off('connect', onConnect); 29emitter.emit('connect'); // No output, as the listener was removed
API
on(event, listener)
Registers an event listener for the specified event.
event
: A string representing the event name.listener
: A function that will be called when the event is emitted.
emit(event, ...args)
Emits an event with the provided arguments.
event
: A string representing the event name....args
: Arguments to be passed to the event listeners.
off(event, listener)
Removes a specific event listener.
event
: A string representing the event name.listener
: The listener function to remove.
hasListener(event, listener)
Checks if a specific listener is registered for the event.
event
: A string representing the event name.listener
: The listener function to check.- Returns
true
if the listener is registered,false
otherwise.
License
This module is licensed under the MIT License - see the LICENSE file for details.
Bu `readme.md` dosyası, `ElegantDB EventEmitter` modülünün nasıl kullanılacağına dair temel bilgileri içerir. Lütfen gerekli düzenlemeleri ve modülün gerçek kullanımına uygun şekilde ayarlamayı unutmayın.
No vulnerabilities found.
No security vulnerabilities found.
Gathering detailed insights and metrics for @elegantdb/events