-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
15,237 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,7 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# site | ||
site/README.md | ||
site/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.