one more try catch for node5/6

This commit is contained in:
barisusakli
2016-10-16 17:51:35 +03:00
parent 4a8b3dcd4c
commit d1fb4909ba
3 changed files with 10 additions and 4 deletions

View File

@@ -10,8 +10,13 @@ try {
require('xmlhttprequest-ssl');
}
var name;
try {
name = require.resolve(xhrPath);
} catch(e) {
name = require.resolve('xmlhttprequest-ssl');
}
var name = require.resolve(xhrPath);
// Get cached version.
var cachedXhr = require.cache[name];
var stdXhr = cachedXhr.exports;
@@ -21,7 +26,7 @@ var callbacks = {};
var newXhr = function () {
stdXhr.apply(this, arguments);
for (method in callbacks) {
for (var method in callbacks) {
if (typeof callbacks[method] == "function") {
callbacks[method].apply(this, arguments);
}