aku
Guardian Spirit. It Interceps a function and exec a handler based on the result.
Last updated 4 years ago by kikobeats .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install aku 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.3                                ...           latest (4 years ago)

4 Versions

  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |