http-browserify
Advanced tools
Comparing version 0.0.3 to 0.1.0
57
index.js
@@ -1,1 +0,56 @@ | ||
module.exports = require('http'); | ||
var http = module.exports; | ||
var EventEmitter = require('events').EventEmitter; | ||
var Request = require('./lib/request'); | ||
http.request = function (params, cb) { | ||
if (!params) params = {}; | ||
if (!params.host) params.host = window.location.host.split(':')[0]; | ||
if (!params.port) params.port = window.location.port; | ||
var req = new Request(new xhrHttp, params); | ||
if (cb) req.on('response', cb); | ||
return req; | ||
}; | ||
http.get = function (params, cb) { | ||
params.method = 'GET'; | ||
var req = http.request(params, cb); | ||
req.end(); | ||
return req; | ||
}; | ||
var xhrHttp = (function () { | ||
if (typeof window === 'undefined') { | ||
throw new Error('no window object present'); | ||
} | ||
else if (window.XMLHttpRequest) { | ||
return window.XMLHttpRequest; | ||
} | ||
else if (window.ActiveXObject) { | ||
var axs = [ | ||
'Msxml2.XMLHTTP.6.0', | ||
'Msxml2.XMLHTTP.3.0', | ||
'Microsoft.XMLHTTP' | ||
]; | ||
for (var i = 0; i < axs.length; i++) { | ||
try { | ||
var ax = new(window.ActiveXObject)(axs[i]); | ||
return function () { | ||
if (ax) { | ||
var ax_ = ax; | ||
ax = null; | ||
return ax_; | ||
} | ||
else { | ||
return new(window.ActiveXObject)(axs[i]); | ||
} | ||
}; | ||
} | ||
catch (e) {} | ||
} | ||
throw new Error('ajax not supported in this browser') | ||
} | ||
else { | ||
throw new Error('ajax not supported in this browser'); | ||
} | ||
})(); |
{ | ||
"name" : "http-browserify", | ||
"version" : "0.0.3", | ||
"version" : "0.1.0", | ||
"description" : "http module compatability for browserify", | ||
"main" : "index.js", | ||
"browserify" : "browser.js", | ||
"browserify" : "index.js", | ||
"directories" : { | ||
@@ -8,0 +8,0 @@ "lib" : ".", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
13830
129
4
17
331