@k03mad/ip2geo 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,9 @@
9
9
  npm i @k03mad/ip2geo -g
10
10
  ip2geo --help
11
11
 
12
+ ip2geo
13
+ # your IP info
14
+
12
15
  ip2geo 1.1.1.1
13
16
  # {
14
17
  # ip: '1.1.1.1',
@@ -42,7 +45,7 @@ const info = await ip2geo('1.1.1.1', {
42
45
  cacheFileSeparator: ';;',
43
46
  cacheFileNewline: '\n',
44
47
  cacheMap: new Map(),
45
- rps: 5, // useful in Promise.all with big IPs array
48
+ rps: 3, // useful in Promise.all with IPs array
46
49
  });
47
50
 
48
51
  // info {
package/app/cli.js CHANGED
@@ -7,6 +7,7 @@ import {codeText, nameText} from './helpers/colors.js';
7
7
  import {ip2geo} from './index.js';
8
8
 
9
9
  const args = process.argv.slice(2);
10
+ const argsIps = args.filter(arg => !arg.startsWith('-'));
10
11
 
11
12
  if (args.includes('-h') || args.includes('--help')) {
12
13
  const prefix = codeText('$');
@@ -26,9 +27,9 @@ if (args.includes('-h') || args.includes('--help')) {
26
27
  ]);
27
28
  }
28
29
 
29
- const output = await Promise.all(args
30
- .filter(arg => !arg.startsWith('-'))
31
- .map(arg => Promise.all(arg.split(',').map(elem => ip2geo(elem)))));
30
+ const output = argsIps.length === 0
31
+ ? [await ip2geo()]
32
+ : await Promise.all(argsIps.map(arg => Promise.all(arg.split(',').map(ip => ip2geo(ip)))));
32
33
 
33
34
  const flatten = output.flat();
34
35
 
package/app/lib/ip2geo.js CHANGED
@@ -26,7 +26,7 @@ const DEFAULT_CACHE_FILE_DIR = path.join(os.tmpdir(), '.ip2geo');
26
26
  const DEFAULT_CACHE_FILE_NAME = 'ips.log';
27
27
  const DEFAULT_CACHE_FILE_SEPARATOR = ';;';
28
28
  const DEFAULT_CACHE_FILE_NEWLINE = '\n';
29
- const DEFAULT_RPS = 5;
29
+ const DEFAULT_RPS = 3;
30
30
 
31
31
  export const cacheStorage = new Map();
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k03mad/ip2geo",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "GeoIP library",
5
5
  "maintainers": [
6
6
  "Kirill Molchanov <k03.mad@gmail.com"