File tree Expand file tree Collapse file tree 5 files changed +1082
-44
lines changed Expand file tree Collapse file tree 5 files changed +1082
-44
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,26 @@ Load the IP2Location BIN database for lookup.
12
12
:param str binPath: (Required) The file path links to IP2Location BIN databases.
13
13
```
14
14
15
+ ``` {py:function} openAsync(binPath)
16
+ Load the IP2Location BIN database for lookup asynchronously.
17
+
18
+ :param str binPath: (Required) The file path links to IP2Location BIN databases.
19
+ ```
20
+
15
21
``` {py:function} getAll(ipAddress)
16
22
Retrieve geolocation information for an IP address.
17
23
18
24
:param str ipAddress: (Required) The IP address (IPv4 or IPv6).
19
25
:return: Returns the geolocation information in array. Refer below table for the fields avaliable in the array
20
26
:rtype: array
21
27
28
+ {py:function} getAllAsync(ipAddress)
29
+ Retrieve geolocation information for an IP address asynchronously.
30
+
31
+ :param str ipAddress: (Required) The IP address (IPv4 or IPv6).
32
+ :return: Returns the geolocation information in a Promise of an array. Refer below table for the fields avaliable in the array
33
+ :rtype: Promise of an array
34
+
22
35
**RETURN FIELDS**
23
36
24
37
| Field Name | Description |
Original file line number Diff line number Diff line change @@ -52,6 +52,30 @@ for (var x = 0; x < testip.length; x++) {
52
52
ip2location .close ();
53
53
```
54
54
55
+ ### Query geolocation information from BIN database asynchronously
56
+
57
+ You can asynchronously query the geolocation information from the IP2Location BIN database as below:
58
+
59
+ ``` javascript
60
+
61
+ const {IP2Location } = require (" ip2location-nodejs" );
62
+
63
+ let ip2location = new IP2Location ();
64
+
65
+ testip = [' 8.8.8.8' , ' 2404:6800:4001:c01::67' ];
66
+
67
+ ip2location .openAsync (" ./DB26.BIN" ).then (() => {
68
+ for (var x = 0 ; x < testip .length ; x++ ) {
69
+ ip2location .getAllAsync (testip[x]).then (result => {
70
+ for (var key in result) {
71
+ console .log (key + " : " + result[key]);
72
+ }
73
+ console .log (" --------------------------------------------------------------" );
74
+ });
75
+ }
76
+ });
77
+ ```
78
+
55
79
### Processing IP address using IP Tools class
56
80
57
81
You can manupulate IP address, IP number and CIDR as below:
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " ip2location-nodejs" ,
3
- "version" : " 9.5 .0" ,
3
+ "version" : " 9.6 .0" ,
4
4
"description" : " IP2Location geolocation component" ,
5
5
"keywords" : [
6
6
" ip2location" ,
You can’t perform that action at this time.
0 commit comments