bbq
AOP with Promises
usage example
var bbq = { // return a promise}
api
bbq: (promiser: () => Promise, advice?: {before: Function, after: Function}) => Promise
before
and after
are AOP advice, functions which can modify the control flow of the promiser
.
- Advice can modify the return value by returning other than undefined or a Promise of undefined.
- Advice is called in the
this
context of astate
object, which can be used to keep track of state between before and after advice for thatpromiser
invocation. - If
before
advice returns a value, it will short-circuit thepromiser
from being called. after
advice hasthis.val
set to the return value of thepromiser
. Ifafter
returns a value other than undefined or a Promise of undefined, it will be the ultimate resolved value; otherwisethis.val
will be used.
installation
$ npm install bbq
running the tests
From package root:
$ npm install
$ npm test
contributors
- jden jason@denizac.org
license
MIT. (c) MMXIII jden jason@denizac.org. See LICENSE.md