@oschwald/maxminddb 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +9 -1
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.js +29 -2
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-arm64-msvc.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.1] - 2026-07-03
|
|
9
|
+
|
|
10
|
+
* Test fix. No other changes.
|
|
11
|
+
|
|
12
|
+
## [0.2.0] - 2026-07-03
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Updated the Rust `maxminddb` dependency to 0.29.0 and refreshed Rust and npm
|
|
17
|
+
development dependencies.
|
|
18
|
+
- Coalesced watched file reload events so bursts trigger fewer duplicate reloads
|
|
19
|
+
and hook calls while preserving serialized reloads.
|
|
20
|
+
|
|
21
|
+
### Performance
|
|
22
|
+
|
|
23
|
+
- Decoded path lookup results directly into JavaScript values to reduce
|
|
24
|
+
intermediate allocations for `getPath()`, `getManyPath()`, and compiled path
|
|
25
|
+
lookups.
|
|
26
|
+
- Decoded network iteration records directly into JavaScript values to reduce
|
|
27
|
+
intermediate allocations for `networks()`, `within()`, and paginated network
|
|
28
|
+
iteration.
|
|
29
|
+
|
|
8
30
|
## [0.1.0] - 2026-06-14
|
|
9
31
|
|
|
10
32
|
### Added
|
|
@@ -61,4 +83,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
61
83
|
- Added Rust formatting, `cargo check`, clippy, TypeScript, Node test, npm pack,
|
|
62
84
|
and packed-package smoke-test validation.
|
|
63
85
|
|
|
86
|
+
[0.2.0]: https://github.com/oschwald/maxminddb-node/releases/tag/v0.2.0
|
|
64
87
|
[0.1.0]: https://github.com/oschwald/maxminddb-node/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -16,8 +16,11 @@ npm install @oschwald/maxminddb
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
+
These examples use ES modules. Save them as `.mjs`, or set `"type": "module"`
|
|
20
|
+
in your `package.json`.
|
|
21
|
+
|
|
19
22
|
```js
|
|
20
|
-
|
|
23
|
+
import maxmind from '@oschwald/maxminddb';
|
|
21
24
|
|
|
22
25
|
const reader = await maxmind.open('/path/to/GeoIP2-City.mmdb');
|
|
23
26
|
|
|
@@ -26,6 +29,9 @@ console.log(reader.getWithPrefixLength('8.8.8.8'));
|
|
|
26
29
|
console.log(reader.getPath('8.8.8.8', ['country', 'iso_code']));
|
|
27
30
|
```
|
|
28
31
|
|
|
32
|
+
CommonJS `require()` is also supported for compatibility with existing
|
|
33
|
+
`node-maxmind` users.
|
|
34
|
+
|
|
29
35
|
## Compatibility API
|
|
30
36
|
|
|
31
37
|
- `open(filepath, options?)`
|
|
@@ -116,6 +122,8 @@ Use `MODE_BUFFER` if you want `open()` to read the file into a Node `Buffer`
|
|
|
116
122
|
before constructing the reader.
|
|
117
123
|
|
|
118
124
|
```js
|
|
125
|
+
import maxmind from '@oschwald/maxminddb';
|
|
126
|
+
|
|
119
127
|
const reader = await maxmind.open('/path/to/db.mmdb', {
|
|
120
128
|
mode: maxmind.MODE_MEMORY,
|
|
121
129
|
});
|
package/index.darwin-arm64.node
CHANGED
|
Binary file
|
package/index.darwin-x64.node
CHANGED
|
Binary file
|
package/index.js
CHANGED
|
@@ -337,6 +337,8 @@ class Reader {
|
|
|
337
337
|
this._filepath = null;
|
|
338
338
|
this._watchFilepath = null;
|
|
339
339
|
this._watchListener = null;
|
|
340
|
+
this._watchReloadActive = false;
|
|
341
|
+
this._watchReloadPending = false;
|
|
340
342
|
this._watchReloadPromise = Promise.resolve();
|
|
341
343
|
this._lastReloadError = null;
|
|
342
344
|
this._cacheCapacity = normalizeCacheCapacity(options);
|
|
@@ -352,6 +354,8 @@ class Reader {
|
|
|
352
354
|
reader._filepath = filepath;
|
|
353
355
|
reader._watchFilepath = null;
|
|
354
356
|
reader._watchListener = null;
|
|
357
|
+
reader._watchReloadActive = false;
|
|
358
|
+
reader._watchReloadPending = false;
|
|
355
359
|
reader._watchReloadPromise = Promise.resolve();
|
|
356
360
|
reader._lastReloadError = null;
|
|
357
361
|
reader._cacheCapacity = normalizeCacheCapacity(options);
|
|
@@ -400,12 +404,35 @@ class Reader {
|
|
|
400
404
|
this._watchFilepath = null;
|
|
401
405
|
this._watchListener = null;
|
|
402
406
|
}
|
|
407
|
+
this._watchReloadPending = false;
|
|
403
408
|
this._reader.close();
|
|
404
409
|
}
|
|
405
410
|
|
|
406
411
|
_queueWatchedReload(filepath, mode, hook) {
|
|
407
|
-
|
|
408
|
-
|
|
412
|
+
this._watchReloadPending = true;
|
|
413
|
+
if (this._watchReloadActive) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
this._watchReloadActive = true;
|
|
418
|
+
const drainReloads = async () => {
|
|
419
|
+
try {
|
|
420
|
+
while (this._watchReloadPending) {
|
|
421
|
+
this._watchReloadPending = false;
|
|
422
|
+
await this._reloadWatchedFile(filepath, mode, hook);
|
|
423
|
+
}
|
|
424
|
+
} finally {
|
|
425
|
+
this._watchReloadActive = false;
|
|
426
|
+
if (this._watchReloadPending) {
|
|
427
|
+
this._queueWatchedReload(filepath, mode, hook);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
this._watchReloadPromise = this._watchReloadPromise.then(
|
|
433
|
+
drainReloads,
|
|
434
|
+
drainReloads
|
|
435
|
+
);
|
|
409
436
|
}
|
|
410
437
|
|
|
411
438
|
async _reloadWatchedFile(filepath, mode, hook) {
|
|
Binary file
|
package/index.linux-x64-gnu.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oschwald/maxminddb",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Rust-backed Node.js reader for MaxMind DB files",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"license": "ISC",
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@napi-rs/cli": "^3.7.2",
|
|
55
|
-
"@types/node": "^
|
|
56
|
-
"typescript": "^
|
|
55
|
+
"@types/node": "^26.1.0",
|
|
56
|
+
"typescript": "^6.0.3"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=20"
|