aku
v1.0.3
Published
Guardian Spirit. It Interceps a function and exec a handler based on the result.
Downloads
30
Maintainers
Readme
aku
Guardian Spirit. It Interceps a function and exec a handler based on the result.
Bind a handler to exec under error and bind another for non error. Simple!
Similar to jif but for functions.
Install
$ npm install aku --save
API
We distinguish between sync or async methods:
- aku(fn, handler, [errHandler])
- aku.sync(fn, handler, [errHandler])
As you can see the library expose the async method by default.
fn
Required
Type: function
Input sync/async function to be handled.
handler
Required
Type: function
Handle that will be hooked under non error result.
errHandler
Type: function
Defaults: noop
Handle that will be hooked under error result.
As you can see it is an optional handled.
If you provided a sync method, then it throws an error after errHandler
execution.
License
MIT © Kiko Beats