@nodeart/event_emitter
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -0,0 +0,0 @@ /** |
{ | ||
"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" |
@@ -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 | ||
@@ -0,0 +0,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
35
0
7901