get-lat-long 0.0.3 → 1.0.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/lib/index.js DELETED
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env -S node --experimental-vm-modules
2
- "use strict";
3
-
4
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
9
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
- var data = require("../data/data.json");
11
- function binarySearchCity(city_name) {
12
- var l = 0,
13
- r = data.length - 1;
14
- while (l <= r) {
15
- var mid = l + parseInt((r - l) / 2);
16
- if (data[mid][1].startsWith(city_name)) return data[mid];
17
- if (city_name < data[mid][1]) r = mid - 1;else l = mid + 1;
18
- }
19
- return;
20
- }
21
- function findByCity(query_city) {
22
- console.time("Searching");
23
- // TC - 1.692ms, 1.56ms, 1.556ms, 1.7ms, 1.568ms, 1.56ms
24
- // const found = data.find((element) => element[1].startsWith(query_city));
25
- // TC - 0.084ms, 0.078ms, 0.08ms, 0.081ms, 0.088ms, 0.076ms
26
- var found = binarySearchCity(query_city);
27
- console.timeEnd("Searching");
28
- if (!found) return console.log("No matches found");
29
- var _found = _slicedToArray(found, 6),
30
- city = _found[0],
31
- city_ls = _found[1],
32
- lat = _found[2],
33
- lng = _found[3],
34
- country = _found[4],
35
- population = _found[5];
36
- console.log({
37
- city: city,
38
- city_ls: city_ls,
39
- lat: lat,
40
- lng: lng,
41
- country: country,
42
- population: population
43
- });
44
- }
45
- var args = process.argv.slice(2);
46
- if (args.length < 1 || args.length > 1) {
47
- console.error("Invalid params provided");
48
- process.exit(1);
49
- }
50
- var _args = _slicedToArray(args, 1),
51
- query_city = _args[0];
52
- findByCity(query_city);
package/src/index.js DELETED
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env -S node --experimental-vm-modules
2
- "use strict";
3
-
4
- const data = require("../data/data.json");
5
-
6
- function binarySearchCity(city_name) {
7
- let l = 0,
8
- r = data.length - 1;
9
-
10
- while (l <= r) {
11
- const mid = l + parseInt((r - l) / 2);
12
- if (data[mid][1].startsWith(city_name)) return data[mid];
13
- if (city_name < data[mid][1]) r = mid - 1;
14
- else l = mid + 1;
15
- }
16
-
17
- return;
18
- }
19
-
20
- function findByCity(query_city) {
21
- console.time("Searching");
22
- // TC - 1.692ms, 1.56ms, 1.556ms, 1.7ms, 1.568ms, 1.56ms
23
- // const found = data.find((element) => element[1].startsWith(query_city));
24
- // TC - 0.084ms, 0.078ms, 0.08ms, 0.081ms, 0.088ms, 0.076ms
25
- const found = binarySearchCity(query_city);
26
- console.timeEnd("Searching");
27
- if (!found) return console.log("No matches found");
28
-
29
- const [city, city_ls, lat, lng, country, population] = found;
30
- console.log({ city, city_ls, lat, lng, country, population });
31
- }
32
-
33
- const args = process.argv.slice(2);
34
- if (args.length < 1 || args.length > 1) {
35
- console.error("Invalid params provided");
36
- process.exit(1);
37
- }
38
- const [query_city] = args;
39
- findByCity(query_city);