forked from runk/node-maxmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (23 loc) · 771 Bytes
/
index.js
File metadata and controls
30 lines (23 loc) · 771 Bytes
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
'use strict';
var assert = require('assert');
var fs = require('fs');
var Reader = require('./lib/reader');
var ip = require('./lib/ip');
var utils = require('./lib/utils');
exports.Reader = Reader;
exports.open = function(filepath, opts, cb) {
if (!cb) cb = opts;
assert.equal(typeof cb, 'function', 'Callback function must be provided. \
If you want to open library synchronously, use maxmind.openSync function.');
fs.readFile(filepath, function(err, database) {
if (err) cb(err);
else cb(null, new Reader(database, opts));
});
};
exports.openSync = function(filepath, opts) {
return new Reader(fs.readFileSync(filepath), opts);
};
exports.init = function() {
throw new Error(utils.legacyErrorMessage);
};
exports.validate = ip.validate;