Skip to content

Commit

Permalink
Reduced complexity of module.exports
Browse files Browse the repository at this point in the history
  • Loading branch information
fvdm committed Mar 25, 2016
1 parent 49072d3 commit f1a478b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions geoip2ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,23 @@ function doLookup (serviceName, ip, callback) {
*/

module.exports = function moduleExports (userId, licenseKey, service, requestTimeout) {
var key;

if (userId instanceof Object) {
service = userId.service || api.service;
requestTimeout = userId.requestTimeout || api.requestTimeout;
api.endpoint = userId.endpoint || api.endpoint;
licenseKey = userId.licenseKey || null;
userId = userId.userId || null;
}
for (key in userId) {
api [key] = userId [key];
}

api.userId = userId;
api.licenseKey = licenseKey;
return doLookup;
}

if (typeof service === 'number') {
api.requestTimeout = service;
} else {
api.service = service || api.service;
api.requestTimeout = requestTimeout || api.requestTimeout;
return doLookup;
}

api.service = service || api.service;
api.requestTimeout = requestTimeout || api.requestTimeout;

return doLookup;
};

0 comments on commit f1a478b

Please sign in to comment.