diff --git a/package-lock.json b/package-lock.json index de717340..9571087c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3289,7 +3289,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", - "dev": true + "dev": true, + "optional": true }, "handlebars": { "version": "4.7.7", @@ -3760,6 +3761,7 @@ "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", "dev": true, + "optional": true, "requires": { "is-docker": "^2.0.0" } @@ -5711,9 +5713,9 @@ } }, "mmdb-lib": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mmdb-lib/-/mmdb-lib-1.2.0.tgz", - "integrity": "sha512-3XYebkStxqCgWJjsmT9FCaE19Yi4Tvs2SBPKhUks3rJJh52oF1AKAd9kei+LTutud3a6RCZ0o2Um96Fn7o3zVA==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mmdb-lib/-/mmdb-lib-1.3.0.tgz", + "integrity": "sha512-KrRrAuC+X9ZkkPZNsqgHUGrop28vcmqISILyUXG0xOYt82ObU9d9XowVsjOVOr5CegyjrkmxEN5ut9r576vq2g==" }, "modify-values": { "version": "1.0.1", @@ -5826,6 +5828,7 @@ "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz", "integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==", "dev": true, + "optional": true, "requires": { "growly": "^1.3.0", "is-wsl": "^2.2.0", @@ -5840,6 +5843,7 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", "dev": true, + "optional": true, "requires": { "lru-cache": "^6.0.0" } @@ -5849,6 +5853,7 @@ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, + "optional": true, "requires": { "isexe": "^2.0.0" } @@ -9220,7 +9225,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", - "dev": true + "dev": true, + "optional": true }, "signal-exit": { "version": "3.0.2", @@ -10299,7 +10305,8 @@ "version": "8.3.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==", - "dev": true + "dev": true, + "optional": true }, "v8-to-istanbul": { "version": "7.0.0", diff --git a/package.json b/package.json index cf13aa5c..4e911cb5 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "Gregory Oschwald @oschwald" ], "dependencies": { - "mmdb-lib": "1.2.0", + "mmdb-lib": "1.3.0", "tiny-lru": "7.0.6" }, "devDependencies": { diff --git a/src/index.ts b/src/index.ts index 3e2e70cd..3d9d4302 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,7 +33,7 @@ export const open = async ( } const cache = lru((opts && opts.cache && opts.cache.max) || 6000); - let reader = new Reader(database, { cache }); + const reader = new Reader(database, { cache }); if (opts && !!opts.watchForUpdates) { if ( @@ -63,9 +63,9 @@ export const open = async ( if (!(await waitExists())) { return; } - const updateDatabase = await fs.readFile(filepath); + const updatedDatabase = await fs.readFile(filepath); cache.clear(); - reader = new Reader(updateDatabase, { cache }); + reader.load(updatedDatabase); if (opts.watchForUpdatesHook) { opts.watchForUpdatesHook(); } @@ -94,4 +94,4 @@ export default { validate: ip.validate, }; -export { Reader }; \ No newline at end of file +export { Reader }; diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000..db1ad1f2 --- /dev/null +++ b/test/README.md @@ -0,0 +1,7 @@ +# Test data + +Test data is installed via _git submodule_ from https://github.com/maxmind/MaxMind-DB.git. Execute following command in the project root: + +```shell +git submodule update --init +```