mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Added definitions for geoip-lite
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
/// <reference path="geoip-lite.d.ts"/>
|
||||
|
||||
// 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();
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for GeoIP-lite 1.1.6
|
||||
// Project: https://github.com/bluesmoon/node-geoip
|
||||
// Definitions by: Yuce Tekol <http://yuce.me/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'geoip-lite' {
|
||||
module mod {
|
||||
export interface Lookup {
|
||||
range: Array<number>; // range start, end
|
||||
country: string;
|
||||
region: string;
|
||||
city: string;
|
||||
ll: Array<number>; // latitude, longitude
|
||||
}
|
||||
|
||||
export function lookup(ip: string): Lookup;
|
||||
export function pretty(ip: number): string;
|
||||
export function startWatchingDataUpdate(): void;
|
||||
export function stopWatchingDataUpdate(): void;
|
||||
}
|
||||
export = mod;
|
||||
}
|
||||
Reference in New Issue
Block a user