0.1.0 • Published 8 years ago

traps v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

traps

Trap me if you can!

travis codecov

traps leverages proxies and allows to easily create chainable apis. You can register traps which will be invoked when a specific method is invoked or capture all method invocations in a sink.

Install

npm install --save traps

Usage

import traps from 'traps'

// capture all method invocations
const api = traps(console.log)
api.foo('bar').baz('qux')
// =>
// foo, ['bar']
// baz, ['qux']

// register a trap
api('woot', (name, params) => console.log('WOOT!', params))
api.woot('a wombat')
// => WOOT!, ['a wombat']

// invoke an lambda trap
api.trap(() => console.log('I do not have a name.'))
// => I do not have a name.

License

MIT © Nicolas Gryman