Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ip2region

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip2region

ip to geo database, IP 地址到区域运营商

  • 1.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
791
decreased by-17.52%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version build status Test coverage David deps node version npm download npm license Greenkeeper badge

node-ip2region

IP 地址到区域运营商 IP to region on Node.js

安装使用使用

$ npm install ip2region --save
const IP2Region = require('ip2region');
const query = new IP2Region();
const res = query.search('120.24.78.68');
console.log(res);
> { id: 2163, country: '中国', region: '华南', province: '广东省', city: '深圳市', isp: '阿里云' }

性能

库中实现了四种搜索方法,包括基于内存和基于文件的 BinarySearchBtreeSearch

从 benmark 可以看出效果最好的是 inMemoryBtreeSearch,所以默认的 search 方法使用这个。

测试结果如下:

$ node test/benchmark.js

search x 742,123 ops/sec ±0.78% (86 runs sampled)
inMemoryBinarySearch x 168,323 ops/sec ±1.05% (89 runs sampled)
inMemoryBtreeSearch x 163,726 ops/sec ±2.11% (81 runs sampled)
binarySearchSync x 15,210 ops/sec ±1.00% (87 runs sampled)
btreeSearchSync x 63,495 ops/sec ±1.80% (76 runs sampled)
Fastest is search

需要其他方法可以参考 test/index.js 调用。

Keywords

FAQs

Package last updated on 30 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc