Installations
npm install geoip-native-lite
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.18.1
NPM Version
6.13.4
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
chill117
Download Statistics
Total Downloads
45,601
Last Day
2
Last Week
24
Last Month
71
Last Year
671
GitHub Statistics
15 Stars
55 Commits
3 Forks
4 Watching
1 Branches
1 Contributors
Bundle Size
44.28 kB
Minified
14.39 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.1
Package Id
geoip-native-lite@1.0.1
Size
2.88 MB
NPM Version
6.13.4
Node Version
10.18.1
Publised On
25 Mar 2020
Total Downloads
Cumulative downloads
Total Downloads
45,601
Last day
0%
2
Compared to previous day
Last week
-7.7%
24
Compared to previous week
Last month
2.9%
71
Compared to previous month
Last year
-35.4%
671
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
geoip-native-lite
Super-fast IP to country lookups with minimal RAM usage.
Goals
- Fast IP address to country lookup:
- 1,000,000+ ops/second for IPv4 addresses
- 500,000+ ops/second for IPv6 addresses
- Minimal RAM usage
- Native JavaScript implementation for ease-of-use and portability
Installation
Add to your application via npm
:
npm install geoip-native-lite --save
This will install geoip-native-lite
and add it to your application's package.json
file.
Update Data Files
This module ships with pre-built data files. If you'd like to update the data files for yourself, run the update script like this:
npm run updatedata
How to Use
lookup
lookup(ip)
Lookup the country in which the IP address is located. Supports both ipv4 and ipv6.
Usage:
1var GeoIpNativeLite = require('geoip-native-lite'); 2 3// Must load data before lookups can be performed. 4GeoIpNativeLite.loadDataSync(); 5 6// Data loaded successfully. 7// Ready for lookups. 8var ip = '128.21.16.34'; 9var country = GeoIpNativeLite.lookup(ip); 10 11if (country) { 12 console.log(ip, 'is geo-located in', country.toUpperCase()); 13} else { 14 console.log('Failed to geo-locate the IP address:', ip); 15}
loadData
loadData([options, ]cb)
Asynchronously loads geoip data.
Usage:
1var GeoIpNativeLite = require('geoip-native-lite');
2
3GeoIpNativeLite.loadData(options, function(error, data) {
4
5 if (error) {
6 // Something went wrong.
7 } else {
8 // Data loaded successfully.
9 // Ready for lookups.
10 }
11});
Options:
1var options = { 2 3 /* 4 Set to TRUE to load ipv4 geoip data. 5 6 Default value is TRUE. 7 */ 8 ipv4: true, 9 10 /* 11 Set to TRUE to load ipv6 geoip data. 12 13 Default value is FALSE. 14 */ 15 ipv6: false, 16 17 /* 18 Set to TRUE to cache data in memory. 19 20 Default value is TRUE. 21 */ 22 cache: true 23};
loadDataSync
loadDataSync([options])
Synchronously loads geoip data.
Usage:
1var GeoIpNativeLite = require('geoip-native-lite'); 2 3GeoIpNativeLite.loadDataSync(options); 4 5var country = GeoIpNativeLite.lookup('198.169.246.30');
Options:
1var options = { 2 3 /* 4 Set to TRUE to load ipv4 geoip data. 5 6 Default value is TRUE. 7 */ 8 ipv4: true, 9 10 /* 11 Set to TRUE to load ipv6 geoip data. 12 13 Default value is FALSE. 14 */ 15 ipv6: false, 16 17 /* 18 Set to TRUE to cache data in memory. 19 20 Default value is TRUE. 21 */ 22 cache: true 23};
Contributing
There are a number of ways you can contribute:
- Improve or correct the documentation - All the documentation is in this
readme.md
file. If you see a mistake, or think something should be clarified or expanded upon, please submit a pull request - Report a bug - Please review existing issues before submitting a new one; to avoid duplicates. If you can't find an issue that relates to the bug you've found, please create a new one.
- Request a feature - Again, please review the existing issues before posting a feature request. If you can't find an existing one that covers your feature idea, please create a new one.
- Fix a bug - Have a look at the existing issues for the project. If there's a bug in there that you'd like to tackle, please feel free to do so. I would ask that when fixing a bug, that you first create a failing test that proves the bug. Then to fix the bug, make the test pass. This should hopefully ensure that the bug never creeps into the project again. After you've done all that, you can submit a pull request with your changes.
Tests
To run all tests (except benchmarks):
npm test
To run benchmarks:
npm run test:benchmarks
To run only unit tests:
npm run test:unit
To run only code-style checks:
npm run lint
Licensing
All the code in this project is MIT licensed.
The geoip data used in this project is licensed separately.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
20 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
1.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to geoip-native-lite
geoip-lite
A light weight native JavaScript implementation of GeoIP API from MaxMind
@codebet/geoip-lite-auto-update
A light weight native JavaScript implementation of GeoIP API from MaxMind
@basicer/geoip-lite
A light weight native JavaScript implementation of GeoIP API from MaxMind
geoip-lite2
A light weight native JavaScript implementation of GeoIP API from MaxMind. Improved and faster version by Sefinek.