Skip to content

Commit 74d1c4d

Browse files
committed
Merge pull request DefinitelyTyped#5976 from yuce/geoip-lite
Added definitions for geoip-lite
2 parents 4fc438e + 99ceaf2 commit 74d1c4d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

geoip-lite/geoip-lite-tests.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path="geoip-lite.d.ts"/>
2+
3+
// require geoip-lite
4+
import geoip = require('geoip-lite');
5+
6+
// lookup an IP addres
7+
var geo = geoip.lookup('199.16.156.125');
8+
9+
// convert the ip block range to string
10+
if (geo) {
11+
let rangeStart = geoip.pretty(geo.range[0]);
12+
let rangeEnd = geoip.pretty(geo.range[1]);
13+
}
14+
15+
// start the data update watcher
16+
geoip.startWatchingDataUpdate();
17+
18+
// stop the data update watcher
19+
geoip.stopWatchingDataUpdate();

geoip-lite/geoip-lite.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Type definitions for GeoIP-lite 1.1.6
2+
// Project: https://github.com/bluesmoon/node-geoip
3+
// Definitions by: Yuce Tekol <http://yuce.me/>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
declare module 'geoip-lite' {
7+
module mod {
8+
export interface Lookup {
9+
range: Array<number>; // range start, end
10+
country: string;
11+
region: string;
12+
city: string;
13+
ll: Array<number>; // latitude, longitude
14+
}
15+
16+
export function lookup(ip: string): Lookup;
17+
export function pretty(ip: number): string;
18+
export function startWatchingDataUpdate(): void;
19+
export function stopWatchingDataUpdate(): void;
20+
}
21+
export = mod;
22+
}

0 commit comments

Comments
 (0)