Add dynamic instrumentation to emitters
shimmer does a bunch of the work necessary to wrap other methods in
a wrapper you provide:
var EventEmitter = EventEmitter;var wrapEmitter = ;var ee = ;var id = 0;;
wrapEmitter(emitter, mark, prepare)
Wrap an EventEmitter's event listeners. Each listener will be passed to
mark when it is registered with
.on(), and then
each listener is passed to
prepare to be wrapped before it's called
wrapListener deals with the single listener
vs array of listeners logic, and also ensures that edge cases like
.removeListener() being called from within an
.emit() for the same
event type is handled properly.
The wrapped EE can be restored to its pristine state by using emitter.__unwrap(), but this should only be used if you really know what you're doing.