https://github.com/luxass/hooxs
Build a powerful project with typed hooks for a smooth plugin API. ✨
https://github.com/luxass/hooxs
hook hooks tapable
Last synced: 3 months ago
JSON representation
Build a powerful project with typed hooks for a smooth plugin API. ✨
- Host: GitHub
- URL: https://github.com/luxass/hooxs
- Owner: luxass
- License: mit
- Created: 2023-09-02T13:41:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T15:53:50.000Z (3 months ago)
- Last Synced: 2025-03-11T16:39:44.838Z (3 months ago)
- Topics: hook, hooks, tapable
- Language: TypeScript
- Homepage:
- Size: 396 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# hooxs
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]Effortlessly empower your project with typed hooks, enabling you to easily construct a plugin API for your needs.
## 📦 Installation
```sh
npm install hooxs
```## 📚 Usage
```ts
import { createHooks } from "hooxs";interface RuntimeHooks {
"build:before": () => void;
"build:after": (files: string[]) => void;
// can either be registered inside the hooks object or registered at a later point
"config:load"?: (config: Record) => void;
}const hooks = createHooks({
"build:before": () => {
console.log("before build");
},
"build:after": (files) => {
console.log("after build", files);
},
});
// or initialize hooks at a later point
const hooks = createHooks();hooks.on("config:load", (config) => {
console.log("config loaded", config);
});await hooks.call("build:before");
const files = ["index.js", "index.css"];await hooks.call("build:after", files);
```## 📄 License
Published under [MIT License](./LICENSE).
[npm-version-src]: https://img.shields.io/npm/v/hooxs?style=flat&colorA=18181B&colorB=4169E1
[npm-version-href]: https://npmjs.com/package/hooxs
[npm-downloads-src]: https://img.shields.io/npm/dm/hooxs?style=flat&colorA=18181B&colorB=4169E1
[npm-downloads-href]: https://npmjs.com/package/hooxs