
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
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
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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.