New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ee-typed

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-typed

EventEmitter with type information

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

ee-typed

TypeScript version of the nodejs events module.

Usage

This is just the built-in nodejs event emitter with type information added, so you can use it like the official docs:

// Add the -ts suffix to the imported module
import { EventEmitter } from 'ee-typed';

// Specify the types of all your events
type Events = {
  event(): void;
};

// Include the Events type as a generic below
class MyEmitter extends EventEmitter<Events> {}

const myEmitter = new MyEmitter();
myEmitter.on('event', () => {
  console.log('an event occurred!');
});
myEmitter.emit('event');

myEmitter.emit(42);
// Error: Argument of type '42' is not assignable to parameter of
//        type '"event"'. ts(2345)

Based on typed-emitter

This package builds on typed-emitter.

typed-emitter has the advantage of being a type-only library, so it adds zero bytes to your bundle. However, that approach requires you to import the regular events library and then cast to the provided type.

This library provides the actual class with the appropriate cast, which I feel is simpler. Worthy of the few dozen bytes it adds to your bundle I'd say.

Keywords

FAQs

Package last updated on 14 Jan 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc