Skip to content

Commit

Permalink
Merge pull request #10 from jaredwray/removing-emittery-to-support-CJ…
Browse files Browse the repository at this point in the history
…S-and-ESM

removing emittery to support CJS and ESM
  • Loading branch information
jaredwray authored Sep 23, 2024
2 parents 00d8ec8 + a8aacf6 commit e1012fa
Show file tree
Hide file tree
Showing 7 changed files with 9,579 additions and 15 deletions.
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
[![npm](https://img.shields.io/npm/v/hookified)](https://npmjs.com/package/hookified)

## Features
- Emit Events via [Emittery](https://npmjs.com/package/emittery)
- Simple replacement for EventEmitter
- Async Middleware Hooks for Your Methods
- ESM / CJS and Nodejs 20+
- Maintained on a regular basis!

Special thanks to [@sindresorhus](https://github.com/sindresorhus) for the [Emittery](https://npmjs.com/package/emittery) library. 🍻

## Installation
```bash
npm install hookified --save
Expand Down Expand Up @@ -70,8 +68,6 @@ class MyClass extends Hookified {

## API

Please see the [Emittery](https://npmjs.com/package/emittery) documentation for more information on the event emitter.

### .onHook(eventName, handler)

Subscribe to a hook event.
Expand All @@ -94,6 +90,30 @@ Get all hooks for an event.

### .clearHooks(eventName)

### .on(eventName, handler)

Subscribe to an event.

### .off(eventName, handler)

Unsubscribe from an event.

### .emit(eventName, ...args)

Emit an event.

## .listeners(eventName)

Get all listeners for an event.

## .removeAllListeners(eventName)

Remove all listeners for an event.

## .setMaxListeners(maxListeners: number)

Set the maximum number of listeners and will truncate if there are already too many.

## Development and Testing

Hookified is written in TypeScript and tests are written in `vitest`. To run the tests, use the following command:
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hookified",
"version": "1.0.0",
"version": "1.1.0",
"description": "Event and Middleware Hooks",
"type": "module",
"main": "./dist/index.cjs",
Expand Down Expand Up @@ -57,9 +57,6 @@
"url": "https://github.com/jaredwray/hookified/issues"
},
"homepage": "https://github.com/jaredwray/hookified#readme",
"dependencies": {
"emittery": "^1.0.3"
},
"devDependencies": {
"@vitest/coverage-v8": "^2.1.1",
"docula": "^0.9.0",
Expand Down
Loading

0 comments on commit e1012fa

Please sign in to comment.