aku

1.0.3 • Public • Published

aku


aku

Last version Build Status Dependency status Dev Dependencies Status NPM Status Donate

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

Package Sidebar

Install

npm i aku

Weekly Downloads

10

Version

1.0.3

License

MIT

Last publish

Collaborators

  • kikobeats