You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-geocode

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-geocode - npm Package Compare versions

Comparing version

to
0.0.7

.babelrc

118

lib/index.js

@@ -1,6 +0,27 @@

"use strict";
let handleUrl = (() => {
var _ref = _asyncToGenerator(function* (url) {
const response = yield fetch(url).catch(function (error) {
return Promise.reject(new Error("Error fetching data"));
});
Object.defineProperty(exports, "__esModule", {
value: true
});
const json = yield response.json().catch(function () {
log("Error parsing server response");
return Promise.reject(new Error("Error parsing server response"));
});
if (json.status === "OK") {
log(json);
return json;
}
log(`Server returned status code ${json.status}`, true);
return Promise.reject(new Error(`Server returned status code ${json.status}`));
});
return function handleUrl(_x) {
return _ref.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
/**

@@ -13,9 +34,7 @@ * React Geocode Module

var DEBUG = false;
var API_KEY = null;
var GOOGLE_API = "https://maps.google.com/maps/api/geocode/json";
let DEBUG = false;
let API_KEY = null;
const GOOGLE_API = "https://maps.google.com/maps/api/geocode/json";
function log(message) {
var warn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
function log(message, warn = false) {
if (DEBUG) {

@@ -30,21 +49,3 @@ if (warn) {

async function handleUrl(url) {
var response = await fetch(url).catch(function (error) {
return Promise.reject(new Error("Error fetching data"));
});
var json = await response.json().catch(function () {
log("Error parsing server response");
return Promise.reject(new Error("Error parsing server response"));
});
if (json.status === "OK") {
log(json);
return json;
}
log("Server returned status code " + json.status, true);
return Promise.reject(new Error("Server returned status code " + json.status));
}
exports.default = {
export default {
/**

@@ -55,7 +56,6 @@ *

*/
setApiKey: function setApiKey(apiKey) {
setApiKey(apiKey) {
API_KEY = apiKey;
},
/**

@@ -66,9 +66,6 @@ *

*/
enableDebug: function enableDebug() {
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
enableDebug(flag = true) {
DEBUG = flag;
},
/**

@@ -82,20 +79,21 @@ *

*/
fromLatLng: async function fromLatLng(lat, lng, apiKey) {
if (!lat || !lng) {
log("Provided coordinates are invalid", true);
return Promise.reject(new Error("Provided coordinates are invalid"));
}
fromLatLng(lat, lng, apiKey) {
return _asyncToGenerator(function* () {
if (!lat || !lng) {
log("Provided coordinates are invalid", true);
return Promise.reject(new Error("Provided coordinates are invalid"));
}
var latLng = lat + "," + lng;
var url = GOOGLE_API + "?latlng=" + encodeURI(latLng);
const latLng = `${lat},${lng}`;
let url = `${GOOGLE_API}?latlng=${encodeURI(latLng)}`;
if (apiKey || API_KEY) {
API_KEY = apiKey || API_KEY;
url += "&key=" + API_KEY;
}
if (apiKey || API_KEY) {
API_KEY = apiKey || API_KEY;
url += `&key=${API_KEY}`;
}
return handleUrl(url);
return handleUrl(url);
})();
},
/**

@@ -108,17 +106,19 @@ *

*/
fromAddress: async function fromAddress(address, apiKey) {
if (!address) {
log("Provided address is invalid", true);
return Promise.reject(new Error("Provided address is invalid"));
}
fromAddress(address, apiKey) {
return _asyncToGenerator(function* () {
if (!address) {
log("Provided address is invalid", true);
return Promise.reject(new Error("Provided address is invalid"));
}
var url = GOOGLE_API + "?address=" + encodeURI(address);
let url = `${GOOGLE_API}?address=${encodeURI(address)}`;
if (apiKey || API_KEY) {
API_KEY = apiKey || API_KEY;
url += "&key=" + API_KEY;
}
if (apiKey || API_KEY) {
API_KEY = apiKey || API_KEY;
url += `&key=${API_KEY}`;
}
return handleUrl(url);
return handleUrl(url);
})();
}
};
{
"name": "react-geocode",
"version": "0.0.6",
"version": "0.0.7",
"description":

@@ -8,3 +8,3 @@ "A React module to transform a description of a location (i.e. street address, town name, etc.) into geographic coordinates (i.e. latitude and longitude) and vice versa.",

"scripts": {
"build": "babel src --presets babel-preset-es2015 --out-dir lib",
"build": "babel src --presets stage-3 --out-dir lib",
"prepublish": "npm run build"

@@ -32,5 +32,5 @@ },

"devDependencies": {
"babel-cli": "6",
"babel-preset-es2015": "6"
"babel-cli": "^6.26.0",
"babel-preset-stage-3": "^6.24.1"
}
}

Sorry, the diff of this file is not supported yet