From 230ab6270189d3c6bb23edc7e4c10653975b99d7 Mon Sep 17 00:00:00 2001 From: Joshua DeVinney Date: Tue, 11 Oct 2016 15:35:26 -0500 Subject: [PATCH] Updating maxmind to version 2.0 --- maxmind/index.d.ts | 6 ++++-- maxmind/maxmind-tests.ts | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/maxmind/index.d.ts b/maxmind/index.d.ts index 3444d9eaa6..da45eb907b 100644 --- a/maxmind/index.d.ts +++ b/maxmind/index.d.ts @@ -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 // 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 { diff --git a/maxmind/maxmind-tests.ts b/maxmind/maxmind-tests.ts index 79fe2e47b6..943cd9a5d1 100644 --- a/maxmind/maxmind-tests.ts +++ b/maxmind/maxmind-tests.ts @@ -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