Comparing version 2.6.0 to 2.7.0
@@ -34,3 +34,4 @@ 'use strict'; | ||
} | ||
fs.watch(filepath, function() { | ||
var watcherOptions = {persistent: opts.watchForUpdatesNonPersistent !== true}; | ||
fs.watch(filepath, watcherOptions, function() { | ||
fs.readFile(filepath, function(err, database) { | ||
@@ -55,3 +56,4 @@ if (err) return cb(err); | ||
} | ||
fs.watch(filepath, function() { | ||
var watcherOptions = {persistent: opts.watchForUpdatesNonPersistent !== true}; | ||
fs.watch(filepath, watcherOptions, function() { | ||
reader.load(fs.readFileSync(filepath), opts); | ||
@@ -58,0 +60,0 @@ if (opts.watchForUpdatesHook) { |
{ | ||
"name": "maxmind", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"homepage": "https://github.com/runk/node-maxmind", | ||
@@ -26,13 +26,13 @@ "description": "IP lookup using Maxmind databases", | ||
"dependencies": { | ||
"big-integer": "^1.6.27", | ||
"tiny-lru": "^1.5.1" | ||
"big-integer": "^1.6.31", | ||
"tiny-lru": "^1.6.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^2.13.1", | ||
"github-publish-release": "^4.0.0", | ||
"github-publish-release": "^4.2.1", | ||
"ip-address": "^5.8.8", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^5.0.5", | ||
"nyc": "^11.4.1", | ||
"sinon": "^4.4.2" | ||
"mocha": "^5.2.0", | ||
"nyc": "^11.9.0", | ||
"sinon": "^5.1.1" | ||
}, | ||
@@ -39,0 +39,0 @@ "repository": { |
node-maxmind [![Build Status](https://travis-ci.org/runk/node-maxmind.png)](https://travis-ci.org/runk/node-maxmind) | ||
======== | ||
Pure Javascript module for Geo IP lookup using Maxmind binary databases (aka mmdb or geoip2). | ||
@@ -75,2 +76,12 @@ Fastest Maxmind lookup library available - up to [17,000% faster](https://github.com/runk/node-maxmind-benchmark) than other libraries. Module has 100% test coverage with comprehensive test suite. It natively works with binary Maxmind database format and doesn't require any "CSV - {specific lib format}" conversions as some other modules do. Maxmind binary databases are highly optimized for size and performance so there's no point working with other than that format. | ||
You also can specify wether the watcher should be persistent or not. If it is persistent, a node process will be blocked in watching state if the watcher is the only thing still running in the program. You can use `watchForUpdatesNonPersistent` option (default `false`) to prevent this behavior. | ||
```javascript | ||
var lookup = maxmind.openSync('/path/to/GeoLite2.mmdb', { | ||
watchForUpdates: true, | ||
watchForUpdateNonPersistent: true, | ||
}); | ||
lookup.get('1.1.1.1'); | ||
``` | ||
Also, you can specify custom hook function on database update. | ||
@@ -77,0 +88,0 @@ |
@@ -17,4 +17,4 @@ 'use strict'; | ||
beforeEach(function() { | ||
sandbox = sinon.sandbox.create(); | ||
sandbox.stub(fs, 'watch').callsFake(function(path, cb) { watchHandler = cb; }); | ||
sandbox = sinon.createSandbox(); | ||
sandbox.stub(fs, 'watch').callsFake(function(path, options, cb) { watchHandler = cb; }); | ||
sandbox.spy(fs, 'readFile'); | ||
@@ -80,2 +80,3 @@ sandbox.spy(fs, 'readFileSync'); | ||
watchForUpdatesHook: hook, | ||
watchForUpdatesNonPersistent: false, | ||
}; | ||
@@ -82,0 +83,0 @@ maxmind.open(dbPath, options, function(err, lookup) { |
Sorry, the diff of this file is not supported yet
2116677
62760
128
80
Updatedbig-integer@^1.6.31
Updatedtiny-lru@^1.6.1