npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ts-event-target

v0.1.5

Published

[![NPM version](https://badge.fury.io/js/ts-event-target.png)](http://badge.fury.io/js/ts-event-target) [![NPM downloads](http://img.shields.io/npm/dm/ts-event-target.svg)](https://npmjs.org/package/ts-event-target) [![Build Status](https://app.travis-ci.

Downloads

103

Readme

ts-event-target

NPM version NPM downloads Build Status

nodejs event target with full typescript type support.

usage

import { Event, EventTarget} from 'ts-event-target';

class MyEvent extends Event<'my'> {
  data: { x: number } = { x: 0 };
  constructor() {
    super('my');
  }
}

class MyEvent2 extends Event<'my2'> {
  data: { y: number } = { y: 0 };
  constructor() {
    super('my2');
  }
}

const target = new EventTarget<[MyEvent, MyEvent2]>();

target.addEventListener('my',(e)=>{

});

const event = new MyEvent();
target.dispatchEvent(event);

API

interface UserEventOptions {
    composed?: boolean;
    bubbles?: boolean;
    cancelable?: boolean;
}
interface UserListenerOptions {
    once?: boolean;
    capture?: boolean;
    passive?: boolean;
}
export declare class Event<T> {
    constructor(type: T, options?: UserEventOptions);
    stopImmediatePropagation(): void;
    preventDefault(): void;
    get target(): any;
    get currentTarget(): any;
    get srcElement(): any;
    get type(): T;
    get cancelable(): boolean;
    get defaultPrevented(): boolean;
    get timeStamp(): number;
    get returnValue(): boolean;
    get bubbles(): boolean;
    get composed(): boolean;
    get eventPhase(): number;
    get cancelBubble(): boolean;
    set cancelBubble(value: boolean);
    stopPropagation(): void;
}
declare type ListenerFunction<EventType> = (event: EventType) => any;
declare type UserListener<EventType> = ListenerFunction<EventType> | {
    handleEvent: ListenerFunction<EventType>;
};
interface ListenerRoot<EventType> {
    size: number;
    next: ListenerNode<EventType> | undefined;
}
declare class ListenerNode<EventType> {
    next: ListenerNode<EventType> | undefined;
    previous: ListenerNode<EventType> | ListenerRoot<EventType> | undefined;
    listener: UserListener<EventType>;
    once?: boolean;
    capture?: boolean;
    passive?: boolean;
    callback: (event: EventType) => any;
    constructor(previous: ListenerNode<EventType> | ListenerRoot<EventType>, listener: UserListener<EventType>, once?: boolean, capture?: boolean, passive?: boolean);
    same(listener: UserListener<EventType>, capture: boolean): boolean;
    remove(): void;
}
declare type Unpacked<T> = T extends Array<infer U> ? U : T;
declare type ExtractEventType<EventUnion, K> = Extract<EventUnion, {
    type: K;
}>;
export declare class EventTarget<Events extends Array<Event<any>>, K extends Events[number]['type'] = Events[number]['type'], EventUnion extends Unpacked<Events> = Unpacked<Events>> {
    constructor();
    addEventListener<T extends K>(type: T, listener: UserListener<ExtractEventType<EventUnion, T>>, options?: UserListenerOptions): void;
    removeEventListener<T extends K>(type: T, listener: UserListener<ExtractEventType<EventUnion, T>>, options?: UserListenerOptions): void;
    dispatchEvent<T extends K>(event: ExtractEventType<EventUnion, T>): boolean;
    eventNames(): K[];
    listenerCount<T extends K>(type: T): number;
    removeAllEventListeners<T extends K>(type: T): this;
}

type coverage

818 / 848 96.46%