Installation
npm install --save @types/node-ip2region
Summary
This package contains type definitions for node-ip2region (https://github.com/lionsoul2014/ip2region).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-ip2region.
index.d.ts
/// <reference types="node" />
type SearchResult = {
city: number;
region: string;
} | null;
type SearchCallback = (err: NodeJS.ErrnoException, result: SearchResult) => void;
declare class IP2Region {
// #region Static Functions
// Single Instance
static create(dbPath?: string): IP2Region;
/**
* For backward compatibility
*/
static destroy(): void;
// #endregion
constructor(options?: { dbPath: string });
// #region Public Functions
/**
* Destroy the current file by closing it.
*/
destroy(): void;
/**
* Sync of binarySearch.
* @param ip The IP address to search for.
* @return A result something like `{ city: 2163, region: '中国|0|广东省|深圳市|阿里云' }`
*/
binarySearchSync(ip: string): SearchResult;
/**
* Async of binarySearch.
* @param ip The IP address to search for.
* @param callBack The callBack function with two parameters, if successful,
* err is null and result is `{ city: 2163, region: '中国|0|广东省|深圳市|阿里云' }`
*/
binarySearch(ip: string, callBack: SearchCallback): void;
/**
* Sync of btreeSearch.
* @param ip The IP address to search for.
* @return A result something like `{ city: 2163, region: '中国|0|广东省|深圳市|阿里云' }`
*/
btreeSearchSync(ip: string): SearchResult;
/**
* Async of btreeSearch.
* @param ip The IP address to search for.
* @param callBack The callBack function with two parameters, if successful,
* err is null and result is `{ city: 2163, region: '中国|0|广东省|深圳市|阿里云' }`
*/
btreeSearch(ip: string, callBack: SearchCallback): void;
/**
* Sync of MemorySearch.
* @param ip
*/
memorySearchSync(ip: string): SearchResult;
/**
* Async of MemorySearch.
* @param ip
*/
memorySearch(ip: string, callBack: SearchCallback): void;
}
export = IP2Region;
Additional Details
- Last updated: Tue, 07 Nov 2023 09:09:39 GMT
- Dependencies: @types/node
Credits
These definitions were written by DCsunset.