From 99ceaf2b88d5226a6cfd13114bf560a97ca2707d Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Wed, 23 Sep 2015 23:19:26 +0300 Subject: [PATCH] Added definitions for geoip-lite --- geoip-lite/geoip-lite-tests.ts | 19 +++++++++++++++++++ geoip-lite/geoip-lite.d.ts | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 geoip-lite/geoip-lite-tests.ts create mode 100644 geoip-lite/geoip-lite.d.ts diff --git a/geoip-lite/geoip-lite-tests.ts b/geoip-lite/geoip-lite-tests.ts new file mode 100644 index 000000000..fb809369b --- /dev/null +++ b/geoip-lite/geoip-lite-tests.ts @@ -0,0 +1,19 @@ +/// + +// require geoip-lite +import geoip = require('geoip-lite'); + +// lookup an IP addres +var geo = geoip.lookup('199.16.156.125'); + +// convert the ip block range to string +if (geo) { + let rangeStart = geoip.pretty(geo.range[0]); + let rangeEnd = geoip.pretty(geo.range[1]); +} + +// start the data update watcher +geoip.startWatchingDataUpdate(); + +// stop the data update watcher +geoip.stopWatchingDataUpdate(); diff --git a/geoip-lite/geoip-lite.d.ts b/geoip-lite/geoip-lite.d.ts new file mode 100644 index 000000000..7e5057d49 --- /dev/null +++ b/geoip-lite/geoip-lite.d.ts @@ -0,0 +1,22 @@ +// Type definitions for GeoIP-lite 1.1.6 +// Project: https://github.com/bluesmoon/node-geoip +// Definitions by: Yuce Tekol +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'geoip-lite' { + module mod { + export interface Lookup { + range: Array; // range start, end + country: string; + region: string; + city: string; + ll: Array; // latitude, longitude + } + + export function lookup(ip: string): Lookup; + export function pretty(ip: number): string; + export function startWatchingDataUpdate(): void; + export function stopWatchingDataUpdate(): void; + } + export = mod; +}