@adamlui/geolocate 1.0.4 → 2.0.1

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
@@ -2,9 +2,9 @@
2
2
 
3
3
  ### Fetch IP geolocation data from the CLI.
4
4
 
5
- <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-1.0.4"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.0.4-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
5
+ <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.0.1"><img height=31 src="https://img.shields.io/badge/Latest_Build-2.0.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
6
6
  <a href="https://www.npmjs.com/package/@adamlui/geolocate?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fgeolocate?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
7
- <a href="https://github.com/adamlui/js-utils/blob/geolocate-1.0.4/geolocate/dist/geolocate.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-1.0.4&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
7
+ <a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.1/geolocate/dist/geolocate.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.0.1&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
8
8
  <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:geolocate/src/geolocate.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ageolocate%2Fsrc%2Fgeolocate.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
9
9
 
10
10
  <br>
@@ -40,14 +40,14 @@ $ npm install @adamlui/geolocate
40
40
  The basic **global command** is:
41
41
 
42
42
  ```
43
- $ geolocate [ip]
43
+ $ geolocate [ip1] [ip2] [...]
44
44
  ```
45
45
 
46
46
  Sample output:
47
47
 
48
48
  <img src="https://github.com/adamlui/js-utils/blob/main/geolocate/media/images/screenshots/cli-geolocate-8.8.8.8.jpg">
49
49
 
50
- **💡 Note:** If no IPv4 address is passed, your own one will be used.
50
+ **📝 Note:** If no IPv4 address is passed, your own one will be used.
51
51
 
52
52
  ### Command line options
53
53
 
@@ -66,7 +66,7 @@ Info commands:
66
66
 
67
67
  ## 🔌 Importing the API
68
68
 
69
- You can also import **geolocate** into your app to use its API methods.
69
+ You can also import **geolocate** into your app to use its main API method.
70
70
 
71
71
  ### <img height=18 src="https://i.imgur.com/JIeAdsr.png"> Node.js
72
72
 
@@ -89,14 +89,14 @@ const geo = require('@adamlui/geolocate');
89
89
  #### <> HTML script tag:
90
90
 
91
91
  ```html
92
- <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.4/dist/geolocate.min.js"></script>
92
+ <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.1/dist/geolocate.min.js"></script>
93
93
  ```
94
94
 
95
95
  #### ES6:
96
96
 
97
97
  ```js
98
98
  (async () => {
99
- await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.4/dist/geolocate.min.js');
99
+ await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.1/dist/geolocate.min.js');
100
100
  // Your code here...
101
101
  })();
102
102
  ```
@@ -105,7 +105,7 @@ const geo = require('@adamlui/geolocate');
105
105
 
106
106
  ```js
107
107
  ...
108
- // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.4/dist/geolocate.min.js
108
+ // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.1/dist/geolocate.min.js
109
109
  // ==/UserScript==
110
110
 
111
111
  // Your code here...
@@ -113,7 +113,7 @@ const geo = require('@adamlui/geolocate');
113
113
 
114
114
  <br>
115
115
 
116
- 📝 **Note:** To always import the latest version (not recommended in production!) remove the `@1.0.4` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
116
+ **📝 Note:** To always import the latest version (not recommended in production!) remove the `@2.0.1` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
117
117
 
118
118
  <br>
119
119
 
@@ -121,9 +121,11 @@ const geo = require('@adamlui/geolocate');
121
121
 
122
122
  ## 📋 API usage
123
123
 
124
- ### `locate([ip])`
124
+ ### `locate([ips, options])`
125
125
 
126
- Asynchronous method to fetch geolocation data for the `ip` passed, returned as an object:
126
+ 💡 Asynchronous method to fetch geolocation data for each `ip` passed in an array, returned as an array of data objects.
127
+
128
+ Example:
127
129
 
128
130
  ```js
129
131
  // Using await syntax
@@ -138,7 +140,7 @@ geo.locate('8.8.8.8').then(location => {
138
140
  });
139
141
 
140
142
  /* outputs:
141
- {
143
+ [{
142
144
  ip: '8.8.8.8',
143
145
  country: 'United States',
144
146
  countryCode: 'US',
@@ -150,30 +152,17 @@ geo.locate('8.8.8.8').then(location => {
150
152
  lon: -77.5,
151
153
  timezone: 'America/New_York',
152
154
  isp: 'Google LLC'
153
- }
155
+ }]
154
156
  */
155
157
  ```
156
158
 
157
- **💡 Note:** If no `ip` is supplied, your own one will be used.
158
-
159
- #
160
-
161
- ### `getOwnIP()`
159
+ **📝 Note:** If no IPv4 address is passed, your own one will be used.
162
160
 
163
- Asynchronous method to fetch/return your own IP as a string:
161
+ Available options (passed as object properties):
164
162
 
165
- ```js
166
- // Using await syntax
167
- (async () => {
168
- const ip = await geo.getOwnIP();
169
- console.log(ip); // outputs your IP
170
- })();
171
-
172
- // Using .then() syntax
173
- geo.getOwnIP().then(ip => {
174
- console.log(ip); // outputs your IP
175
- });
176
- ```
163
+ Name | Type | Description | Default Value
164
+ ----------|---------|-----------------------------------|---------------
165
+ `verbose` | Boolean | Show logging in console/terminal. | `true`
177
166
 
178
167
  <br>
179
168
 
@@ -198,19 +187,19 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
198
187
  ### <img height=21px src="https://i.imgur.com/kvf7fXm.png"> [generate-ip](https://js-utils.com/generate-ip) <a href="https://github.com/toolleeo/cli-apps#networking"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
199
188
 
200
189
  > Randomly generate, format, and validate IPv4/IPv6 addresses.
201
- <br>[Install](https://github.com/adamlui/js-utils/tree/main/generate-ip#-installation) /
202
- [Readme](https://github.com/adamlui/js-utils/tree/main/generate-ip#readme) /
203
- [API usage](https://github.com/adamlui/js-utils/tree/main/generate-ip#-api-usage) /
204
- [CLI usage](https://github.com/adamlui/js-utils/tree/main/generate-ip#-command-line-usage) /
190
+ <br>[Install](https://docs.js-utils.com/generate-ip/#-installation) /
191
+ [Readme](https://docs.js-utils.com/generate-ip/#readme) /
192
+ [API usage](https://docs.js-utils.com/generate-ip/#-api-usage) /
193
+ [CLI usage](https://docs.js-utils.com/generate-ip/#-command-line-usage) /
205
194
  [Discuss](https://js-utils.com/discussions)
206
195
 
207
- ### [🔒 generate-pw](../generate-pw)
196
+ ### [🔒 generate-pw](../generate-pw) <a href="https://github.com/toolleeo/cli-apps#password-managers"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
208
197
 
209
198
  > Randomly generate, strengthen, and validate cryptographically-secure passwords.
210
- <br>[Install](https://github.com/adamlui/js-utils/tree/main/generate-pw#-installation) /
211
- [Readme](https://github.com/adamlui/js-utils/tree/main/generate-pw#readme) /
212
- [API usage](https://github.com/adamlui/js-utils/tree/main/generate-pw#-api-usage) /
213
- [CLI usage](https://github.com/adamlui/js-utils/tree/main/generate-pw#-command-line-usage) /
199
+ <br>[Install](https://docs.js-utils.com/generate-pw/#-installation) /
200
+ [Readme](https://docs.js-utils.com/generate-pw/#readme) /
201
+ [API usage](https://docs.js-utils.com/generate-pw/#-api-usage) /
202
+ [CLI usage](https://docs.js-utils.com/generate-pw/#-command-line-usage) /
214
203
  [Discuss](https://js-utils.com/discussions)
215
204
 
216
205
  <br>
package/dist/cli.min.js CHANGED
@@ -1,15 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * © 2024 Adam Lui under the MIT license.
4
- * Source: https://github.js-utils.com/tree/main/geolocate/src
5
- * Documentation: https://github.js-utils.com/tree/main/geolocate/docs
4
+ * Source: https://code.js-utils.com/geolocate
5
+ * Documentation: https://docs.js-utils.com/geolocate
6
6
  */
7
- (async()=>{const s="@adamlui/geolocate",e=require(__dirname.match(/src/)?"./geolocate":"./geolocate.min"),o=require("generate-ip")["ipv4"],n=require("fs"),i=require("path"),r=require("child_process")["execSync"],t="",a="",l="",c={},p={flags:{quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(o=>{var e,s;o.startsWith("-")&&(e=Object.keys(p.flags).find(e=>p.flags[e].test(o)),s=Object.keys(p.infoCmds).find(e=>p.infoCmds[e].test(o)),e?c[e]=!0:s||(console.error(`
7
+ (async()=>{const s="@adamlui/geolocate",e=require(__dirname.match(/src/)?"./geolocate":"./geolocate.min"),n=require("fs"),i=require("path"),r=require("child_process")["execSync"],o="",t="",l="",c={},a={flags:{quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(o=>{var e,s;o.startsWith("-")&&(e=Object.keys(a.flags).find(e=>a.flags[e].test(o)),s=Object.keys(a.infoCmds).find(e=>a.infoCmds[e].test(o)),e?c[e]=!0:s||(console.error(`
8
8
  ERROR: Arg [${o}] not recognized.`),console.info(`
9
- ${a}Valid arguments are below.`),v(["flags","infoCmds"]),$(),process.exit(1)))}),process.argv.some(e=>p.infoCmds.help.test(e)))v();else if(process.argv.some(e=>p.infoCmds.version.test(e))){var f=r(`npm view ${s} version`).toString().trim()||"none";let e,o=process.cwd();for(;"/"!=o;){var m=i.join(o,"package.json");if(n.existsSync(m)){m=require(m);e=(m.dependencies?.[s]||m.devDependencies?.[s])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}o=i.dirname(o)}console.info(`
10
- Global version: `+f),console.info("Local version: "+e)}else{var d,g=process.argv.slice(2),h=[];for(let e=0;e<g.length;e++)g[e].startsWith("-")||(d=g[e].replace(/\[|\]/g,""),o.validate(d,{verbose:!1})?h.push(d):(d=0==e?"st":1==e?"nd":"th",console.error(`ERROR: ${e+1+d} arg '${g[e]}' is not a valid IPv4 address.`),$(),process.exit(1)));0==h.length&&h.push(await e.getOwnIP()),h.forEach(e=>y(`Fetching geolocation data for ${e}...`));var u=[];for(const b of h)u.push(await e.locate(b));c.quietMode||1!=u.length||(console.info(`
11
- IP: `+l+h[0]+t),console.info("Country: "+l+u[0].country+t),console.info("Region: "+l+u[0].regionName+t),console.info("City: "+l+u[0].city+t),console.info("Latitude: "+l+u[0].lat+t),console.info("Longitude: "+l+u[0].lon+t),console.info(`ISP: ${l+u[0].isp+t}
12
- `)),y("Copying to clipboard..."),f=(f=JSON.stringify(u)).replace(/\s+$/,"").replace(/"/g,'""'),"darwin"==process.platform?r(`printf "${f}" | pbcopy`):"linux"==process.platform?r(`printf "${f}" | xclip -selection clipboard`):"win32"==process.platform&&r(`Set-Clipboard -Value "${f}"`,{shell:"powershell"})}function v(e=["cmdFormat","flags","infoCmds"]){const o={cmdFormat:[`
13
- ${a}geolocate [ip] [options|commands]`],flags:["\nBoolean options:"," -q, --quiet Suppress all logging except errors."],infoCmds:["\nInfo commands:"," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(e=>{o[e]?.forEach(e=>{{const n=process.stdout.columns||80,i=[],o=e.match(/\S+|\s+/g);let s="";o.forEach(e=>{var o=n-(0==i.length?0:29);s.length+e.length>o&&(i.push(0==i.length?s:s.trimStart()),s=""),s+=e}),i.push(0==i.length?s:s.trimStart()),i.forEach((e,o)=>console.info(0==o?e:" ".repeat(29)+e))}})})}function $(){console.info(`
14
- ${a}For more help, type 'minify-js --help' or visit
15
- https://github.com/adamlui/js-utils/tree/main/geolocate#-command-line-usage`)}function y(e){c.quietMode||console.info(e)}})();
9
+ ${t}Valid arguments are below.`),u(["flags","infoCmds"]),console.info(`
10
+ ${t}For more help, type 'minify-js --help' or visit
11
+ https://docs.js-utils.com/geolocate/#-command-line-usage`),process.exit(1)))}),process.argv.some(e=>a.infoCmds.help.test(e)))u();else if(process.argv.some(e=>a.infoCmds.version.test(e))){var p=r(`npm view ${s} version`).toString().trim()||"none";let e,o=process.cwd();for(;"/"!=o;){var m=i.join(o,"package.json");if(n.existsSync(m)){m=require(m);e=(m.dependencies?.[s]||m.devDependencies?.[s])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}o=i.dirname(o)}console.info(`
12
+ Global version: `+p),console.info("Local version: "+e)}else{var f,d=process.argv.slice(2),g=[];for(let e=0;e<d.length;e++)d[e].startsWith("-")||(f=d[e].replace(/\[|\]/g,""),g.push(f));p=await e.locate(g,{verbose:!c.quietMode});p||process.exit(1),c.quietMode||1!=p.length||(console.info(`
13
+ IP: `+l+p[0].ip+o),console.info("Country: "+l+p[0].country+o),console.info("Region: "+l+p[0].regionName+o),console.info("City: "+l+p[0].city+o),console.info("Latitude: "+l+p[0].lat+o),console.info("Longitude: "+l+p[0].lon+o),console.info("ISP: "+l+p[0].isp+o)),c.quietMode||console.info("\nCopying to clipboard..."),h=(h=JSON.stringify(p)).replace(/\s+$/,"").replace(/"/g,'""'),"darwin"==process.platform?r(`printf "${h}" | pbcopy`):"linux"==process.platform?r(`printf "${h}" | xclip -selection clipboard`):"win32"==process.platform&&r(`Set-Clipboard -Value "${h}"`,{shell:"powershell"})}var h;function u(e=["cmdFormat","flags","infoCmds"]){const o={cmdFormat:[`
14
+ ${t}geolocate [ip1] [ip2] [...] [options|commands]`],flags:["\nBoolean options:"," -q, --quiet Suppress all logging except errors."],infoCmds:["\nInfo commands:"," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(e=>{o[e]?.forEach(e=>{{const n=process.stdout.columns||80,i=[],o=e.match(/\S+|\s+/g);let s="";o.forEach(e=>{var o=n-(0==i.length?0:29);s.length+e.length>o&&(i.push(0==i.length?s:s.trimStart()),s=""),s+=e}),i.push(0==i.length?s:s.trimStart()),i.forEach((e,o)=>console.info(0==o?e:" ".repeat(29)+e))}})})}})();
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * © 2024 Adam Lui under the MIT license.
3
- * Source: https://github.js-utils.com/tree/main/geolocate/src
4
- * Documentation: https://github.js-utils.com/tree/main/geolocate/docs
3
+ * Source: https://code.js-utils.com/geolocate
4
+ * Documentation: https://docs.js-utils.com/geolocate
5
5
  */
6
- async function geolocate(t){let o;try{o=require("generate-ip").ipv4.validate}catch(e){await import("https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js"),o=ipv4.validate}if(o&&!o(t,{verbose:!1}))console.error("geolocate() » ERROR: Invalid IP address passed."),console.info("geolocate() » For more help, please visit https://github.com/adamlui/js-utils/tree/main/geolocate#locateip");else try{let e;if("undefined"!=typeof fetch)e=await fetch("http://ip-api.com/json/"+t);else{if("function"!=typeof require)return console.error("geolocate() » ERROR: Environment not supported.");e=await require("axios").get("http://ip-api.com/json/"+t)}const{status:i,org:r,as:n,query:c,...a}=await e.json();return{ip:t,...a}}catch(e){console.error("geolocate() »",e)}}async function getOwnIP(){return fetch("https://ifconfig.me/ip").then(e=>e.text()).catch(()=>fetch("http://ip-api.com/json/").then(e=>e.json()).then(e=>e.query)).catch(async()=>{try{var e=require("child_process")["exec"],t=require("util")["promisify"],{stdout:o,stderr:i}=await t(e)("curl -s ifconfig.me");return i?console.error("getOwnIP() »",i):o.trim()}catch(e){console.error("getOwnIP() »",e)}})}const apiFunctions={geolocate:geolocate,locate:geolocate,getOwnIP:getOwnIP};try{module.exports={...apiFunctions}}catch(e){}try{window.geo={...apiFunctions}}catch(e){}
6
+ async function geolocate(e,t={}){var o={verbose:!0};(e=Array.isArray(e)?e:[e])[0]=e[0]||await fetch("https://ifconfig.me/ip").then(e=>e.text()).catch(()=>fetch("http://ip-api.com/json/").then(e=>e.json()).then(e=>e.query)).catch(async()=>{try{var e=require("child_process")["exec"],o=require("util")["promisify"],{stdout:t,stderr:r}=await o(e)("curl -s ifconfig.me");return r?console.error("geolocate() »",r):t.trim()}catch(e){console.error("geolocate() »",e)}});for(const n of e){t.verbose&&console.info(`geolocate() » Validating ${n}...`);let o;try{o=require("generate-ip").ipv4.validate}catch(e){await import("https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js"),o=ipv4.validate}if(o&&!o(n,{verbose:!1}))return console.error(`geolocate() » ERROR: ${n} is not a valid IPv4 address.`)}if(validateOptions(t,o,"https://docs.js-utils.com/geolocate/#locateip","geolocate('8.8.8.8', { verbose: false })")){t={...o,...t};try{var r=[];for(const i of e){t.verbose&&console.info(`geolocate() » Fetching geolocation data for ${i}...`);let e;if("undefined"!=typeof fetch)e=await fetch("http://ip-api.com/json/"+i);else{if("function"!=typeof require)return console.error("geolocate() » ERROR: Environment not supported.");e=await require("axios").get("http://ip-api.com/json/"+i)}const{status:a,org:c,as:s,query:l,...p}=await e.json();r.push(p)}return!t.verbose||"undefined"!=typeof require&&/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("geolocate() » Success! Check returned array."),r}catch(e){console.error("geolocate() »",e)}}}function validateOptions(e,o,t,r){const n=JSON.stringify(o,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),i=Object.keys(o).join(", "),a=Object.keys(o).filter(e=>"boolean"==typeof o[e]);let c="validateOptions() » ";try{c=validateOptions.caller?.name+"() » "}catch(e){}var s=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,l=(s+=["st","nd","rd"][s-1]||"th",()=>{console.info(`${c}Valid options: [ ${i} ]`),console.info(c+"If omitted, default settings are: "+n)}),p=()=>{console.info(c+"For more help, please visit "+t)};if("object"!=typeof e)return console.error(c+`ERROR: ${"0th"==s?"[O":s+" arg [o"}ptions] can only be an object of key/values.`),console.info(c+"Example valid call: "+r),l(),p(),!1;for(const f in e){if(!Object.prototype.hasOwnProperty.call(o,f))return console.error(`${c}ERROR: \`${f}\` is an invalid option.`),l(),p(),!1;if(a.includes(f)&&"boolean"!=typeof e[f])return console.error(`${c}ERROR: [${f}] option can only be \`true\` or \`false\`.`),p(),!1}return!0}const apiFunctions={geolocate:geolocate,locate:geolocate};try{module.exports={...apiFunctions}}catch(e){}try{window.geo={...apiFunctions}}catch(e){}
package/docs/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  ### Fetch IP geolocation data from the CLI.
4
4
 
5
- <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-1.0.4"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.0.4-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
5
+ <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.0.1"><img height=31 src="https://img.shields.io/badge/Latest_Build-2.0.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
6
6
  <a href="https://www.npmjs.com/package/@adamlui/geolocate?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fgeolocate?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
7
- <a href="https://github.com/adamlui/js-utils/blob/geolocate-1.0.4/geolocate/dist/geolocate.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-1.0.4&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
7
+ <a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.1/geolocate/dist/geolocate.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.0.1&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
8
8
  <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:geolocate/src/geolocate.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ageolocate%2Fsrc%2Fgeolocate.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
9
9
 
10
10
  <br>
@@ -40,14 +40,14 @@ $ npm install @adamlui/geolocate
40
40
  The basic **global command** is:
41
41
 
42
42
  ```
43
- $ geolocate [ip]
43
+ $ geolocate [ip1] [ip2] [...]
44
44
  ```
45
45
 
46
46
  Sample output:
47
47
 
48
48
  <img src="https://github.com/adamlui/js-utils/blob/main/geolocate/media/images/screenshots/cli-geolocate-8.8.8.8.jpg">
49
49
 
50
- **💡 Note:** If no IPv4 address is passed, your own one will be used.
50
+ **📝 Note:** If no IPv4 address is passed, your own one will be used.
51
51
 
52
52
  ### Command line options
53
53
 
@@ -66,7 +66,7 @@ Info commands:
66
66
 
67
67
  ## 🔌 Importing the API
68
68
 
69
- You can also import **geolocate** into your app to use its API methods.
69
+ You can also import **geolocate** into your app to use its main API method.
70
70
 
71
71
  ### <img height=18 src="https://i.imgur.com/JIeAdsr.png"> Node.js
72
72
 
@@ -89,14 +89,14 @@ const geo = require('@adamlui/geolocate');
89
89
  #### <> HTML script tag:
90
90
 
91
91
  ```html
92
- <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.4/dist/geolocate.min.js"></script>
92
+ <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.1/dist/geolocate.min.js"></script>
93
93
  ```
94
94
 
95
95
  #### ES6:
96
96
 
97
97
  ```js
98
98
  (async () => {
99
- await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.4/dist/geolocate.min.js');
99
+ await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.1/dist/geolocate.min.js');
100
100
  // Your code here...
101
101
  })();
102
102
  ```
@@ -105,7 +105,7 @@ const geo = require('@adamlui/geolocate');
105
105
 
106
106
  ```js
107
107
  ...
108
- // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.4/dist/geolocate.min.js
108
+ // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.1/dist/geolocate.min.js
109
109
  // ==/UserScript==
110
110
 
111
111
  // Your code here...
@@ -113,7 +113,7 @@ const geo = require('@adamlui/geolocate');
113
113
 
114
114
  <br>
115
115
 
116
- 📝 **Note:** To always import the latest version (not recommended in production!) remove the `@1.0.4` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
116
+ **📝 Note:** To always import the latest version (not recommended in production!) remove the `@2.0.1` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
117
117
 
118
118
  <br>
119
119
 
@@ -121,9 +121,11 @@ const geo = require('@adamlui/geolocate');
121
121
 
122
122
  ## 📋 API usage
123
123
 
124
- ### `locate([ip])`
124
+ ### `locate([ips, options])`
125
125
 
126
- Asynchronous method to fetch geolocation data for the `ip` passed, returned as an object:
126
+ 💡 Asynchronous method to fetch geolocation data for each `ip` passed in an array, returned as an array of data objects.
127
+
128
+ Example:
127
129
 
128
130
  ```js
129
131
  // Using await syntax
@@ -138,7 +140,7 @@ geo.locate('8.8.8.8').then(location => {
138
140
  });
139
141
 
140
142
  /* outputs:
141
- {
143
+ [{
142
144
  ip: '8.8.8.8',
143
145
  country: 'United States',
144
146
  countryCode: 'US',
@@ -150,30 +152,17 @@ geo.locate('8.8.8.8').then(location => {
150
152
  lon: -77.5,
151
153
  timezone: 'America/New_York',
152
154
  isp: 'Google LLC'
153
- }
155
+ }]
154
156
  */
155
157
  ```
156
158
 
157
- **💡 Note:** If no `ip` is supplied, your own one will be used.
158
-
159
- #
160
-
161
- ### `getOwnIP()`
159
+ **📝 Note:** If no IPv4 address is passed, your own one will be used.
162
160
 
163
- Asynchronous method to fetch/return your own IP as a string:
161
+ Available options (passed as object properties):
164
162
 
165
- ```js
166
- // Using await syntax
167
- (async () => {
168
- const ip = await geo.getOwnIP();
169
- console.log(ip); // outputs your IP
170
- })();
171
-
172
- // Using .then() syntax
173
- geo.getOwnIP().then(ip => {
174
- console.log(ip); // outputs your IP
175
- });
176
- ```
163
+ Name | Type | Description | Default Value
164
+ ----------|---------|-----------------------------------|---------------
165
+ `verbose` | Boolean | Show logging in console/terminal. | `true`
177
166
 
178
167
  <br>
179
168
 
@@ -198,19 +187,19 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
198
187
  ### <img height=21px src="https://i.imgur.com/kvf7fXm.png"> [generate-ip](https://js-utils.com/generate-ip) <a href="https://github.com/toolleeo/cli-apps#networking"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
199
188
 
200
189
  > Randomly generate, format, and validate IPv4/IPv6 addresses.
201
- <br>[Install](https://github.com/adamlui/js-utils/tree/main/generate-ip#-installation) /
202
- [Readme](https://github.com/adamlui/js-utils/tree/main/generate-ip#readme) /
203
- [API usage](https://github.com/adamlui/js-utils/tree/main/generate-ip#-api-usage) /
204
- [CLI usage](https://github.com/adamlui/js-utils/tree/main/generate-ip#-command-line-usage) /
190
+ <br>[Install](https://docs.js-utils.com/generate-ip/#-installation) /
191
+ [Readme](https://docs.js-utils.com/generate-ip/#readme) /
192
+ [API usage](https://docs.js-utils.com/generate-ip/#-api-usage) /
193
+ [CLI usage](https://docs.js-utils.com/generate-ip/#-command-line-usage) /
205
194
  [Discuss](https://js-utils.com/discussions)
206
195
 
207
- ### [🔒 generate-pw](../generate-pw)
196
+ ### [🔒 generate-pw](../generate-pw) <a href="https://github.com/toolleeo/cli-apps#password-managers"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
208
197
 
209
198
  > Randomly generate, strengthen, and validate cryptographically-secure passwords.
210
- <br>[Install](https://github.com/adamlui/js-utils/tree/main/generate-pw#-installation) /
211
- [Readme](https://github.com/adamlui/js-utils/tree/main/generate-pw#readme) /
212
- [API usage](https://github.com/adamlui/js-utils/tree/main/generate-pw#-api-usage) /
213
- [CLI usage](https://github.com/adamlui/js-utils/tree/main/generate-pw#-command-line-usage) /
199
+ <br>[Install](https://docs.js-utils.com/generate-pw/#-installation) /
200
+ [Readme](https://docs.js-utils.com/generate-pw/#readme) /
201
+ [API usage](https://docs.js-utils.com/generate-pw/#-api-usage) /
202
+ [CLI usage](https://docs.js-utils.com/generate-pw/#-command-line-usage) /
214
203
  [Discuss](https://js-utils.com/discussions)
215
204
 
216
205
  <br>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/geolocate",
3
- "version": "1.0.4",
3
+ "version": "2.0.1",
4
4
  "description": "Fetch IP geolocation data from the CLI.",
5
5
  "author": {
6
6
  "name": "Adam Lui",
@@ -47,9 +47,9 @@
47
47
  "url": "https://github.com/adamlui/js-utils/issues"
48
48
  },
49
49
  "dependencies": {
50
- "generate-ip": "^2.2.4"
50
+ "generate-ip": "^2.2.6"
51
51
  },
52
52
  "devDependencies": {
53
- "@adamlui/minify.js": "^1.5.3"
53
+ "@adamlui/minify.js": "^1.5.4"
54
54
  }
55
55
  }