Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The 'propagate' npm package is used to propagate events from one event emitter to another. This is particularly useful in scenarios where you want to forward events from one object to another seamlessly without manually emitting events from the second object.
Event Propagation
This feature allows you to forward all events from one EventEmitter to another. In the provided code, events from 'emitter1' are propagated to 'emitter2', so when 'emitter1' emits an 'event', 'emitter2' also handles and logs the event.
const EventEmitter = require('events');
const propagate = require('propagate');
let emitter1 = new EventEmitter();
let emitter2 = new EventEmitter();
// Propagate all events from emitter1 to emitter2
propagate(emitter1, emitter2);
emitter1.on('event', () => console.log('Handled by emitter1'));
emitter2.on('event', () => console.log('Handled by emitter2'));
emitter1.emit('event'); // Logs from both emitter1 and emitter2
EventEmitter2 is an implementation of EventEmitter with additional features like namespaces, wildcards, and timesToListen. It offers more flexibility and functionality compared to 'propagate' which mainly focuses on forwarding events.
EventEmitter3 is a high performance EventEmitter primarily focused on performance. While it does not offer direct event propagation like 'propagate', it is optimized for a high number of events and listeners, making it suitable for performance-critical applications.
Propagate events from one event emitter into another
$ npm install propagate
var ee1 = new EventEmitter();
var ee2 = new EventEmitter();
propagate(ee1, ee2);
ee2.on('event', function(a, b) {
console.log('got propagated event', a, b);
});
ee1.emit('event', 'a', 'b');
You can unpropagate by ending the propagation like this:
var ee1 = new EventEmitter();
var ee2 = new EventEmitter();
var p = propagate(ee1, ee2);
// ...
p.end();
var ee1 = new EventEmitter();
var ee2 = new EventEmitter();
var p = propagate(['event1', 'event2'], ee1, ee2);
MIT
FAQs
Propagate events from one event emitter into another
The npm package propagate receives a total of 2,717,272 weekly downloads. As such, propagate popularity was classified as popular.
We found that propagate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.