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