Why are you returning new created objects? module.exports.XMLHttpRequest will be called anyways with new, so you could be able to return directly the constructor function... Also, since this module try to mimics the behaviour of XMLHttpRequest it should be enough to just return it's constructor, without needing to add all this glue code to check for Internet Explorer or other constructors since it's implemented in all recent browsers since several years ago.