Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geoip2

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geoip2 - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

circle.yml

80

node-geoip2.js

@@ -11,66 +11,54 @@

exports.init = function(path) {
_defaultDB = new mmdb.MMDB(path || _defaultPath);
return _defaultDB;
_defaultDB = new mmdb.MMDB(path || _defaultPath);
return _defaultDB;
}
exports.cleanup = function() {
_defaultDB = null;
_defaultDB = null;
}
exports.lookup = function(address, callback) {
if (!_defaultDB) {
console.log("WARNING: ipgeo2 database not initialized, initializing default now.");
exports.init();
}
_defaultDB.lookup(address, callback);
if (!_defaultDB) {
console.log("WARNING: ipgeo2 database not initialized, initializing default now.");
exports.init();
}
_defaultDB.lookup(address, callback);
}
exports.lookupSync = function(address) {
if (!_defaultDB) {
console.log("WARNING: ipgeo2 database not initialized, initializing default now.");
exports.init();
}
return _defaultDB.lookupSync(address);
if (!_defaultDB) {
console.log("WARNING: ipgeo2 database not initialized, initializing default now.");
exports.init();
}
return _defaultDB.lookupSync(address);
}
function parseResult(result) {
return {
country: result.country ? result.country.iso_code : undefined,
continent: result.continent ? result.continent.code : undefined,
postal: result.postal ? result.postal.code : undefined,
city: result.city && result.city.names ? result.city.names.en : undefined,
location: result.location,
subdivision: result.subdivisions ? result.subdivisions[0].iso_code : undefined
};
return {
country: result.country ? result.country.iso_code : undefined,
continent: result.continent ? result.continent.code : undefined,
postal: result.postal ? result.postal.code : undefined,
city: result.city && result.city.names ? result.city.names.en : undefined,
location: result.location,
subdivision: result.subdivisions ? result.subdivisions[0].iso_code : undefined
};
}
exports.lookupSimple = function(address, callback) {
exports.lookup(address, function(error, result) {
if (result) {
callback(null, parseResult(result));
}
else {
callback(error, null);
}
});
exports.lookup(address, function(error, result) {
if (result) {
callback(null, parseResult(result));
}
else {
callback(error, null);
}
});
}
exports.lookupSimpleSync = function(address) {
var result = exports.lookupSync(address);
if (result) {
return parseResult(result);
}
return null;
var result = exports.lookupSync(address);
if (result) {
return parseResult(result);
}
return null;
}
{
"name": "geoip2",
"version": "1.0.3",
"version": "1.0.4",
"description": "Maxmind GeoIP2 database reader for geolocating ip addresses. Fast native implementation by wrapping libmaxminddb.",

@@ -9,11 +9,13 @@ "main": "./node-geoip2.js",

"keywords": [
"geoip",
"geoip2",
"geolocation",
"maxmind",
"mmdb",
"maxminddb",
"geoip",
"geoip2",
"geo",
"geolocation",
"ip"
],
"scripts": {
"test": "./node_modules/.bin/mocha"
},
"repository": {

@@ -25,3 +27,7 @@ "type": "git",

"nan": "2.3.3"
},
"devDependencies": {
"mocha": "^2.5.1",
"chai": "^3.5.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc