Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@types/events
Advanced tools
TypeScript definitions for events
The @types/events package provides TypeScript type definitions for the Node.js 'events' module, which is used for handling events in an application. This package does not contain functionality by itself but offers type annotations for TypeScript developers to ensure type safety and better development experience when working with event-driven programming in Node.js.
EventEmitter Type Definitions
Provides type definitions for creating and using an EventEmitter to handle custom events. The code sample demonstrates how to create an EventEmitter, subscribe to an event with a specific type of listener function, and emit an event.
import { EventEmitter } from 'events';
const emitter: EventEmitter = new EventEmitter();
emitter.on('event', (message: string) => {
console.log(`Received message: ${message}`);
});
emitter.emit('event', 'Hello World!');
EventEmitter3 is a high-performance EventEmitter. It provides similar functionality to Node.js's native EventEmitter from which @types/events derives its types. EventEmitter3 is often chosen for its performance optimizations and is compatible with a broader range of environments, including those where native EventEmitters are not available.
This package is another alternative to the native EventEmitter, offering similar functionalities with additional features like namespaces, wildcards, and times to listen. It does not have built-in TypeScript support, unlike @types/events, but can be more flexible in complex event handling scenarios.
npm install --save @types/events
This package contains type definitions for events (https://github.com/Gozala/events).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/events.
export type Listener = (...args: any[]) => void;
export class EventEmitter {
static listenerCount(emitter: EventEmitter, type: string | number): number;
static defaultMaxListeners: number;
eventNames(): Array<string | number>;
setMaxListeners(n: number): this;
getMaxListeners(): number;
emit(type: string | number, ...args: any[]): boolean;
addListener(type: string | number, listener: Listener): this;
on(type: string | number, listener: Listener): this;
once(type: string | number, listener: Listener): this;
prependListener(type: string | number, listener: Listener): this;
prependOnceListener(type: string | number, listener: Listener): this;
removeListener(type: string | number, listener: Listener): this;
off(type: string | number, listener: Listener): this;
removeAllListeners(type?: string | number): this;
listeners(type: string | number): Listener[];
listenerCount(type: string | number): number;
rawListeners(type: string | number): Listener[];
}
These definitions were written by Yasunori Ohoka, and Shenwei Wang.
FAQs
TypeScript definitions for events
We found that @types/events 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.