Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredwray committed Sep 3, 2024
1 parent bc44bae commit a65ccdc
Show file tree
Hide file tree
Showing 11 changed files with 15,237 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# site
site/README.md
site/.DS_Store
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
# hookified
![Hookified](site/logo.svg)

# Hookified
Event and Middleware Hooks

## Features
- Emit Events via [Emittery](https://npmjs.com/package/emittery)
- Middleware Hooks - Easily add middleware to your library for additional functionality
- TypeScript, ESM, and Nodejs 20+

## Installation
```bash
npm install hookified --save
```

## Usage
this is primarily a library for creating hooks and middleware for your own libraries. Here is an example of a class that is extended using hookified.

```javascript
import { Hookified } from 'hookified';

class MyClass extends Hookified {
constructor() {
super();
}

async myMethod() {
await this.emit('before:myMethod');
// do something
await this.emit('after:myMethod');
}

async myMethod2() Promise<any> {
let data = { some: 'data' };
// do something
await this.exec('before:myMethod2', data);
// do something
await this.exec('after:myMethod2', data);
return data;
}
}


Loading

0 comments on commit a65ccdc

Please sign in to comment.