MCPcopy Create free account
hub / github.com/amasad/debug_utils / debugEvent

Function debugEvent

du.js:77–112  ·  view source on GitHub ↗

* Adds a debugger or logger `event` handler to `object. * * @param {object} object * @param {string} event * @param {boolean} isLog * @private * @return {*} Whatever is returned from the event listener method.

(object, event, isLog)

Source from the content-addressed store, hash-verified

75 */
76
77function debugEvent(object, event, isLog) {
78 assert(
79 object && typeof object === 'object' && typeof event === 'string',
80 'Need an object to listen to and an event to listen on.'
81 );
82
83 var ret, handler;
84
85 if (isLog) {
86 handler = function() {
87 console.log(
88 'Event %s fired on object %O with arguments',
89 event, object, arguments
90 );
91 };
92 } else {
93 handler = function() {
94 debugger;
95 };
96 }
97
98 ret = applyOne(
99 object,
100 listenMethods,
101 [event, handler],
102 dontKnowHowToListenMsg
103 );
104
105 listeners.push({
106 event: event,
107 object: object,
108 handler: handler
109 });
110
111 return ret;
112}
113
114/**
115 * Adds a debugger `event` handler to `object

Callers 2

$duvFunction · 0.85
$duvlFunction · 0.85

Calls 2

assertFunction · 0.85
applyOneFunction · 0.85

Tested by

no test coverage detected