event-intercept
Intercept event data before it reaches the listeners.
var intercept = var foo = // Map all data on 'hello' event to uppercase foo foo// WORLD FOO BAR
Useful for injecting where you want to view/change data before it reaches listeners. Like parsing, logging, debugging, etc.
Installation
$ npm install --save event-intercept
Usage
intercept(emitter, event, handler)
Intercepts an event and it's data. These are executed in the order they are added.
Parameters
emitter
(EventEmitter
): The emitter you want to add intercepting on.event
(String
): Name of the event you want to intercept.handler
(Function
): A mapping function with the signature(args, done)
.
Handler
The handler has the parameters (args, done)
, and you call done
with parameters (end, args)
. Where end
can be true
(abort safely) or an Error
.
Example
License
MIT © Jamen Marz