Snippets

Steele Parker Intercept and debug all events emitted by an Object (Node.js)

Created by Steele Parker
      function debugEvents(obj) {
          var emitFunc = obj.emit;

          obj.emit = function() {
              var emitArgs = arguments;

              //Do something else to emitArgs here

              console.log("Emitting [" + JSON.stringify(arguments) + "].");

              emitFunc.apply(obj, arguments);
          }
      }

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.