-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.js
40 lines (32 loc) · 1.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
var Reader = require('./lib/Reader.js');
module.exports = MaxmindDBReader;
function MaxmindDBReader() {
// allow creation without 'new' keyword
if (!(this instanceof MaxmindDBReader))
return new MaxmindDBReader();
}
MaxmindDBReader.open = function openAsync(database, callback) {
Reader.open(database, function(err, reader){
if(err){
return callback(err);
}
var mmdbreader = MaxmindDBReader();
mmdbreader.reader = reader;
callback(null,mmdbreader);
});
};
MaxmindDBReader.openSync = function openSync(database) {
var mmdbreader = MaxmindDBReader();
mmdbreader.reader = Reader.openSync(database);
return mmdbreader;
};
MaxmindDBReader.prototype.getGeoData = function getGeoData(ipAddress, callback) {
this.reader.get(ipAddress, callback);
};
MaxmindDBReader.prototype.getGeoDataSync = function getGeoDataSync(ipAddress) {
return this.reader.getSync(ipAddress);
};
MaxmindDBReader.prototype.getDatabaseMetadata = function getDatabaseMetadata() {
return this.reader.getMetadata();
};