Hooki
⚓️ An advanced Javascript hook system.
Installation
npm install hooki --save
Usage
// product.class.js ;; { thisname = name; thisprice = price; thisstock = stock; } { console; } ;
// hooks.js const before = buy: { if contextparamsquantity > contextselfquantity throw Error'Amount exceeds stock!'; return context; } ; const after = buy: { contextselfquantity -= contextparamsquantity; return context } ;
// app.js ; const bag = 'bag' 1043 5; bag; // -> bag x4console; // -> 1bag; // -> Error: Amount exceeds stock!
Roadmap
Tests
- tests
target types
- object
- class
- function
action types
- function
- get
- set
- getter
- setter
- construct
hook types
- after
- before
- errors
features
- plugin system
- async hooks (promises, callback)
- extended hooks methods (
target.after([hook])
,target.before([hooks])
)
plugins
- hooki-events
- hooki-validator
- hooki-errors
- hooki-lifecycle
- hooki-modules