Comparing version 1.0.3 to 1.0.4
@@ -1,1 +0,1 @@ | ||
var phin=require("./lib/phin.js");module.exports=phin; | ||
const phin=require("./lib/phin.js");module.exports=phin; |
@@ -1,1 +0,1 @@ | ||
var http=require("http"),https=require("https"),url=require("url");module.exports=function(a,b){if("string"!=typeof a&&!a.hasOwnProperty("url"))throw"Missing url option from options for request method.";if(!b)throw"Missing callback for request method.";var c;if("string"==typeof a){c=url.parse(a);var d={hostname:c.hostname,port:Number(c.port)||("http:"===c.protocol.toLowerCase()?80:443),path:c.path,method:"GET",headers:{},auth:null}}else{c=url.parse(a.url);var d={hostname:c.hostname,port:Number(a.port)||Number(c.port)||("http:"===c.protocol.toLowerCase()?80:443),path:c.path,method:a.method||"GET",headers:a.headers||{},auth:a.auth||c.auth||null}}var e,f=function(a){a.setEncoding("utf8");var c="";a.on("data",function(a){c+=a}),a.on("end",function(){b(null,c,a)})};switch(c.protocol.toLowerCase()){case"http:":e=http.request(d,f);break;case"https:":e=https.request(d,f);break;default:return void b("Invalid / unknown address protocol. (Expected HTTP or HTTPS.)",null,null)}a.hasOwnProperty("data")&&("object"==typeof a.data?e.write(JSON.stringify(a.data)):e.write(a.data.toString())),e.end()}; | ||
const http=require("http");const https=require("https");const url=require("url");module.exports=function(opts,cb){if(typeof(opts)!=="string"&&!opts.hasOwnProperty("url"))throw"Missing url option from options for request method.";if(!cb)throw"Missing callback for request method.";var addr;if(typeof(opts)==="string"){addr=url.parse(opts);var options={"hostname":addr.hostname,"port":(Number(addr.port)||(addr.protocol.toLowerCase()==="http:"?80:443)),"path":addr.path,"method":"GET","headers":{},"auth":null}}else{addr=url.parse(opts.url);var options={"hostname":addr.hostname,"port":(Number(opts.port)||Number(addr.port)||(addr.protocol.toLowerCase()==="http:"?80:443)),"path":addr.path,"method":(opts.method||"GET"),"headers":(opts.headers||{}),"auth":(opts.auth||addr.auth||null)}}var req;var resHandler=(res)=>{res.setEncoding("utf8");var resBody="";res.on("data",(chunk)=>{resBody+=chunk});res.on("end",()=>{cb(null,resBody,res)})};switch(addr.protocol.toLowerCase()){case"http:":req=http.request(options,resHandler);break;case"https:":req=https.request(options,resHandler);break;default:cb("Invalid / unknown address protocol. (Expected HTTP or HTTPS.)",null,null);return}req.on("error",(err)=>{cb(err,null,null)});if(opts.hasOwnProperty("data")){if(typeof(opts.data)==="object"){req.write(JSON.stringify(opts.data))}else{req.write(opts.data.toString())}}req.end()}; |
{ | ||
"name": "phin", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Ultra-simple, lightweight, dependency-free Node.JS HTTP request client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
5549