Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@nodeart/event_emitter

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodeart/event_emitter - npm Package Compare versions

Comparing version
1.2.0
to
1.2.1
+1
-2
package.json
{
"name": "@nodeart/event_emitter",
"version": "1.2.0",
"version": "1.2.1",
"description": "Simple EventEmitter pattern",

@@ -19,3 +19,2 @@ "main": "./index.js",

],
"devDependencies": {},
"engines": {

@@ -22,0 +21,0 @@ "node": ">=6.0.0"

+24
-13

@@ -9,16 +9,27 @@ [![bitHound Overall Score](https://www.bithound.io/github/NodeArt/EventEmitter/badges/score.svg)](https://www.bithound.io/github/NodeArt/EventEmitter)

const events = new EventEmitter();
events.on('eventName', ...fns);
events.once('eventName', ...fns);
events.off('eventName', ...fns);
events.offAll();
events.emit('eventName', {
ctx: true
}, ...args);
events.on('eventName', ...fns)
.once('eventName', ...fns)
.off('eventName', ...fns)
.emit('eventName', {
ctx: true
}, ...args)
.times('eventName2', 3, ...fns)
.offAll();
const inherited = {};
// reset prototype
EventEmitter
.inherit(inherited)
.on('smth', ...fns);
const extended = {};
// add EventEmitter functionality as mixin
EventEmitter
.extend(extended)
.on('smth', ...fns);
// One can remove some functions from listeners array by passing them to .off method,
// but to remove particular event use .off with eventName only;
// but to remove all listeners event use .off with eventName only;
```
Features:
1) any number of functions can be put as listeners
2) chaining available
3) can be used in node.js and in browser

Sorry, the diff of this file is not supported yet