moll / node-mitm

Intercept and mock outgoing Node.js network TCP connections and HTTP requests for testing. Intercepts and gives you a Net.Socket, Http.IncomingMessage and Http.ServerResponse to test and respond with. Super useful when testing code that hits remote servers.
Other
636 stars 48 forks source link

Add the EventEmitter.addListener function to resolve a compatibility problem with the continuation-local-storage module #11

Closed alexkwolfe closed 9 years ago

alexkwolfe commented 9 years ago

The continuation-local-storage module includes a function to bind an EventEmitter to a continuation-local namespace.

Before binding, the EventEmitter is checked for a minimum number of required functions. Among them is the addListener() function.

Because the mitm module does not implement the addListener() function, it is incompatible with the continuation-local-storage module.

This PR makes the addListener() function available so that it can be wrapped by the contination-local-storage bindEmitter() function.

moll commented 9 years ago

Hey!

Thanks for the well prepped PR! Would you mind adding one little tweak for me? :innocent: That would be removing the extra empty line in the test file and perhaps reversing the order of addListener and removeListener in the both the main and the test file. Thanks!

If you don't have the time for that, I'll do so when merging.

Cheers!

alexkwolfe commented 9 years ago

No problem.

alexkwolfe commented 9 years ago

Done. Let me know if there's anything else.

moll commented 9 years ago

Thank you very much for your receptiveness to my pedantry! :-)

moll commented 9 years ago

Oh, and v1.0.3 is on NPM so you can update your package.jsons if you hard-coded your repo in somewhere. ;-)