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.
@antv/event-emitter
Advanced tools
@antv/event-emitter is a lightweight and efficient event emitter library that allows you to create and manage custom events in JavaScript applications. It is part of the AntV visualization suite and is designed to be simple yet powerful, making it easy to integrate event-driven architecture into your projects.
Event Emission
This feature allows you to emit events with a specific name and optional data payload. The emitted event can then be listened to by any registered listeners.
const EventEmitter = require('@antv/event-emitter');
const emitter = new EventEmitter();
emitter.emit('eventName', { key: 'value' });
Event Listening
This feature allows you to register listeners for specific events. When the event is emitted, the registered listeners are called with the event data.
const EventEmitter = require('@antv/event-emitter');
const emitter = new EventEmitter();
emitter.on('eventName', (data) => {
console.log('Event received:', data);
});
emitter.emit('eventName', { key: 'value' });
Removing Event Listeners
This feature allows you to remove specific listeners for an event. This is useful for cleaning up and preventing memory leaks in your application.
const EventEmitter = require('@antv/event-emitter');
const emitter = new EventEmitter();
const listener = (data) => {
console.log('Event received:', data);
};
emitter.on('eventName', listener);
emitter.off('eventName', listener);
emitter.emit('eventName', { key: 'value' });
The 'events' package is the standard Node.js event emitter library. It provides a similar API for emitting and listening to events. It is widely used and well-documented, making it a reliable choice for event-driven programming in Node.js.
The 'eventemitter3' package is a high-performance event emitter library for Node.js and the browser. It offers a similar API to @antv/event-emitter but is optimized for speed and memory efficiency. It is a popular choice for applications that require a fast and lightweight event emitter.
The 'mitt' package is a tiny, functional event emitter library. It provides a minimal API for emitting and listening to events, making it easy to use and integrate into projects. It is a good alternative for developers looking for a simple and lightweight event emitter.
event-emitter for @antvis.
npm i --save @antv/event-emitter
import EE from '@antv/event-emitter';
const ee = new EE();
ee.on('mouseover', () => {});
ee.once('click', () => {});
ee.on('*', () => {});
ee.emit('click', 1, 'hello', true);
ee.off('click');
Simple and similar with event-emitter
.
on(evt: string, callback: Function)
: listen an event.once(evt: string, callback: Function)
: listen a event only once.emit(evt: string, ...parameters: any[])
: emit / trigger an event with parameters.off(evt?: string, callback?: Function)
: unsubscribe an event.getEvents()
: get all the exist events.FAQs
event emitter for antvis.
The npm package @antv/event-emitter receives a total of 155,382 weekly downloads. As such, @antv/event-emitter popularity was classified as popular.
We found that @antv/event-emitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 57 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.