Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Declarations #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* EvEmitter
*
* Adds publish/subscribe pattern to a browser class. It's a smaller
* version of [olical/EventEmitter](https://github.com/Olical/EventEmitter).
* That EventEmitter is full featured, widely used, and great.
* This EvEmitter has just the base event functionality to power the event API
* in libraries like [isotope](https://isotope.metafizzy.co/),
* [flickity](https://flickity.metafizzy.co/), [masonry](https://masonry.desandro.com/),
* and [imagesLoaded](https://imagesloaded.desandro.com/).
*/
declare module "ev-emitter" {
/**
* EvEmitter
*
* Lil' event emitter — Add a little pub/sub
*/
export default class EvEmitter {
/**
* Add an event listener.
*
* @param {eventName} eventName Name of the event
* @param {listener} listener Function to trigger
*/
on(eventName: string, listener: Function): this;
/**
* Add an event listener to be triggered only once.
*
* @param {eventName} eventName Name of the event
* @param {listener} listener Function to trigger
*/
once(eventName: string, listener: Function): this;
/**
* Remove an event listener.
*
* @param {eventName} eventName Name of the event
* @param {listener} listener Function to trigger
*/
off(eventName: string, listener: Function): this;
/**
* Trigger an event.
*
* @param {eventName} eventName Name of the event
* @param {args} args Arguments passed to listeners
*/
emitEvent(eventName: string, args?: any[]): this;
/**
* Removes all event listeners.
*/
allOff(): this;
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.1.2",
"description": "lil' event emitter",
"main": "ev-emitter.js",
"types": "index.d.ts",
"devDependencies": {
"ava": "^3.15.0",
"eslint": "^7.30.0",
Expand Down