JSPM

eventemitter-strict

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 214
  • Score
    100M100P100Q83648F
  • License MIT

A eventemitter with typescript full support

Package Exports

  • eventemitter-strict
  • eventemitter-strict/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eventemitter-strict) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

eventemitter-strict

A eventemitter with typescript full support

eventemitter-strict is a eventemitter with typescript full support. The module is API compatible with the EventEmitter that ships by default with Node.js.

Allow to type safe definition your eventemitter

Feature

  • typesafe
  • compatible with nodejs
  • simple but strong

Install

npm install eventemitter-strict

Usage

import { EventEmitter } from 'eventemitter-strict';

interface FooEventMap {
  eventA: () => void;
  eventB: (num: number) => void;
}

const ee = new EventEmitter<FooEventMap>();
ee.emit('eventA');
ee.emit('eventB', 1);
ee.emit('eventB', "Any"); // this will throw error in ts

or use with extends

import { EventEmitter } from 'eventemitter-strict';

interface FooEventMap {
  eventA: () => void;
  eventB: (num: number) => void;
}

class Foo extends EventEmitter<FooEventMap> {
  bar() {
    this.emit('eventA');
    this.emit('eventB', 1);
    this.emit('eventB', "Any"); // this will throw error in ts
  }
}

License

MIT