Maxmind DB (MMDB) Library
Last updated a month ago by runk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mmdb-lib 
SYNC missed versions from official npm registry.

mmdb-lib Build Status

Javascript library for working with Maxmind binary databases (aka mmdb or geoip2).

Library is designed to be agnostic to environment and works equally well in node.js and browser. Module is fully compatible with IPv6. There are no differences in API between IPv4 and IPv6.


npm i mmdb-lib


import fs from 'fs';
import Reader from 'mmdb-lib';

// Get a buffer with mmdb database, from file system or whereever.
const db = fs.readFileSync('/path/to/GeoLite2-City.mmdb');

const reader = new Reader<CityResponse>(db);
console.log(reader.get('')); // inferred type `CityResponse`
console.log(reader.getWithPrefixLength('')); // tuple with inferred type `[CityResponse|null, number]`

Supported response types:

- CountryResponse
- CityResponse
- AnonymousIPResponse
- AsnResponse
- ConnectionTypeResponse
- DomainResponse
- IspResponse

Usage in browser-like environments

Library expects to receive an instance of Buffer during instantiation of Reader. Since there is no direct alternative of node's Buffer in browser, you can use that mimics native Buffer interface. Neither ArrayBuffer nor Uint8Array is supported right now. Another requirement is BigInt object available.


Reader(db:Buffer, [options])

  • options: <Object>
    • cache: <Object> Cache helper. tiny-lru is great basic option. Only two methods expected: get(key: string | number): any and set(key: string | number, val: any): void.





add a link

Current Tags

  • 1.0.0                                ...           latest (a month ago)

1 Versions

  • 1.0.0                                ...           a month ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 9
Dependencies (0)
Dev Dependencies (11)
Dependents (0)

Copyright 2014 - 2016 © |