Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bbq

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bbq

AOP with Promises

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bbq

AOP with Promises

usage example

var bbq = require('bbq')

function foo(){
  // return a promise
}

bbq(foo, {
  before: function () {
    this.start = Date.now()
  },
  after: function () {
    this.end = Date.now()
    this.elapsed = this.end - this.start
    console.log('promise resolved in ' + this.elapsed + 'ms')
  }
})
.then(function (resolvedValOfFoo) {
  // stuff
})

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 a state object, which can be used to keep track of state between before and after advice for that promiser invocation.
  • If before advice returns a value, it will short-circuit the promiser from being called.
  • after advice has this.val set to the return value of the promiser. If after returns a value other than undefined or a Promise of undefined, it will be the ultimate resolved value; otherwise this.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

FAQs

Package last updated on 06 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc