Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
EventEmitter
Advanced tools
EventEmitter is an implementation of the Event-based architecture in JavaScript.
The code is written using the ES2015 approaches, including creation of private property through WeakMap that allows you to not to check for clearing memory, and let it do to the garbage collector.
The module contains the most basic and necessary things: subscription to an event, unsubscribing from the events, running event only once, setting the maximum number of listeners.
The focus is on code readability, speed of execution, getting rid of all the excess.
You can use this library in browser either at the server as within the node.js.
There are no dependencies. You need only npm installed and just run npm install
to grab the development dependencies.
let EM = new EventEmitter();
EM.on('foo', () => {
// some code...
});
EM.emit('foo');
let EM = new EventEmitter();
EM.once('foo', () => {
// some code...
});
EM.emit('foo');
let EM = new EventEmitter();
EM.once('foo', (bar, baz) => {
// some code...
});
EM.emit('foo', 'var 1 for bar', 'var 2 for baz');
let EM = new EventEmitter();
EM.on('foo', () => {
// some code...
});
// Note: you can use chaining.
EM
.emit('foo')
.emit('foo')
.off('foo');
// You can set maxNumberOfListeners as a parameter when creating new object.
let EM = new EventEmitter(1);
EM.on('foo', () => {
// some code...
});
// Note: it will show notification in console.
EM.on('foo', () => {
// some other code...
});
Tests are performed using mocha and expect library.
You can use JSDoc comments found within the source code.
You can grab minified versions of EventEmitter from /dist path after running gulp build
.
EM.on('foo.*', () => {
// some code...
});
EM.on('foo,bar,baz', () => {
// some code...
});
EM.onAny(() => {
// some code...
});
FAQs
Javascript Event Emitter
The npm package EventEmitter receives a total of 1,415 weekly downloads. As such, EventEmitter popularity was classified as popular.
We found that EventEmitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.