Skip to content

Commit

Permalink
Merge pull request #2 from jaredwray/updating-version-and-testing-rel…
Browse files Browse the repository at this point in the history
…ease

updating version and testing release
  • Loading branch information
jaredwray authored Sep 3, 2024
2 parents 1cbf075 + a6b6812 commit 2f35e59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ 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.
This was built because we constantly wanted hooks and events extended on libraires we are building such as [Keyv](https://keyv.org). This is a simple way to add hooks and events (via [emittery](https://npmjs.com/package/emittery)) to your libraries.

```javascript
import { Hookified } from 'hookified';
Expand All @@ -30,18 +30,16 @@ class MyClass extends Hookified {
super();
}

async myMethod() {
await this.emit('before:myMethod');
// do something
await this.emit('after:myMethod');
async myMethodEmittingEvent() {
await this.emit('message', 'Hello World');
}

async myMethod2() Promise<any> {
//with hooks you can pass data in and if they are subscribed via onHook they can modify the data
async myMethodWithHooks() Promise<any> {
let data = { some: 'data' };
// do something
await this.hook('before:myMethod2', data);
// do something
await this.hook('after:myMethod2', data);

return data;
}
}
Expand Down
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "hookified",
"version": "0.5.0",
"version": "0.5.1",
"description": "Event and Middleware Hooks",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "./dist/index.js",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"engines": {
"node": ">=20"
},
"scripts": {
"test": "xo --fix && vitest run --coverage",
"test:ci": "xo && vitest run --coverage",
Expand Down Expand Up @@ -57,5 +61,9 @@
"typescript": "^5.5.4",
"vitest": "^2.0.5",
"xo": "^0.59.3"
}
},
"files": [
"dist",
"LICENSE"
]
}

0 comments on commit 2f35e59

Please sign in to comment.