Merge pull request #11914 from geoffreak/maxmind-2.0

Updating maxmind to version 2.0 [Types-2.0]
This commit is contained in:
Arthur Ozga 2016-10-12 16:41:37 -07:00 committed by GitHub
commit 2d5d310e05
2 changed files with 8 additions and 6 deletions

6
maxmind/index.d.ts vendored
View File

@ -1,9 +1,11 @@
// Type definitions for maxmind v1.3
// Type definitions for maxmind v2.0
// Project: https://github.com/runk/node-maxmind
// Definitions by: Joshua DeVinney <https://github.com/geoffreak>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export declare function open(database: string, opts?: Options): Reader;
export declare function open(database: string, cb: (err: Error, reader: Reader) => void): void;
export declare function open(database: string, opts: Options, cb: (err: Error, reader: Reader) => void): void;
export declare function openSync(database: string, opts?: Options): Reader;
export declare function validate(ip: string): boolean;
export declare interface Reader {

View File

@ -3,18 +3,18 @@ import * as maxmind from 'maxmind';
// Examples from https://github.com/runk/node-maxmind/blob/master/README.md
// Example 1
var cityLookup = maxmind.open('/path/to/GeoLite2-City.mmdb');
var cityLookup = maxmind.openSync('/path/to/GeoLite2-City.mmdb');
var city = cityLookup.get('66.6.44.4');
var orgLookup = maxmind.open('/path/to/GeoOrg.mmdb');
var orgLookup = maxmind.openSync('/path/to/GeoOrg.mmdb');
var organization = orgLookup.get('66.6.44.4');
// Example 2
var lookup = maxmind.open('/path/to/GeoLite2.mmdb');
var lookup = maxmind.openSync('/path/to/GeoLite2.mmdb');
var location = lookup.get('2001:4860:0:1001::3004:ef68');
// Example 3
var lookup = maxmind.open('/path/to/GeoLite2.mmdb', {
var lookup = maxmind.openSync('/path/to/GeoLite2.mmdb', {
cache: {
max: 1000, // max items in cache
maxAge: 1000 * 60 * 60 // life time in milliseconds