New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

search-google-geocode

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

search-google-geocode - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

parser/index.js

108

communicator/request.js

@@ -25,15 +25,17 @@ /**

Searcher.prototype.geocode = function (address, callback, options) {
address = (address).toString();
address = this._parseAddress(address);
if (!address.length) {
return callback(
new CommunicationError("Address parameter is mandatory.")
new CommunicationError(util.format(
'Address parameter is mandatory. Input value is \'%s\'',
address
))
);
}
options = _.extend(
{ address: address},
(options || {})
);
options = _.extend({}, (options || {}));
options = _.extend(options, { address: address});
this._useOptions(options);
this._send(callback);

@@ -46,15 +48,19 @@ };

Searcher.prototype.reverseGeocode = function (lat, lng, callback, options) {
lat = parseFloat(lat);
lng = parseFloat(lng);
lat = this._parseCoordinate(lat);
lng = this._parseCoordinate(lng);
if (!lat || !lng) {
return callback(
new CommunicationError("Geographical coordinates are mandatory.")
new CommunicationError(util.format(
'Geographical coordinates are mandatory. Input values: latitude is \'%s\', longitude is \'%s\'',
lat,
lng
))
);
}
options = _.extend(
{ latlng: util.format(GEO_COORDS_FORMAT, lat, lng) },
(options || {})
);
options = _.extend({}, (options || {}));
options = _.extend(options, {
latlng: util.format(GEO_COORDS_FORMAT, lat, lng)
});
this._useOptions(options);

@@ -76,10 +82,16 @@

return callback(error);
} else if(response.statusCode != 200) {
error = new CommunicationError(util.format(
'Response status code is \'%s\'',
response.statusCode
));
callback(error);
} else {
callback(null, JSON.parse(body));
}
});
}).end();
} catch (error) {
return callback(error);
}
}
};

@@ -95,5 +107,5 @@ /**

this._checkUriWithError();
return this.uri;
}
};

@@ -105,3 +117,3 @@ /**

this.uri = config['uri'];
}
};

@@ -113,3 +125,3 @@ /**

return (this.uri && this.uri.length);
}
};

@@ -124,3 +136,3 @@ /**

return true;
}
};

@@ -131,5 +143,5 @@ /**

Searcher.prototype._useOptions = function (options) {
this.options = _.extend({}, this.defaultOptions);
this.options = _.extend({}, this._defaultOptions);
_.extend(this.options, (options || {}));
}
};

@@ -140,14 +152,13 @@ /**

Searcher.prototype._initDefaultOptions = function () {
this.defaultOptions = _.extend(
/**
* The 'sensor' Parameter
* The Google Maps API previously required that you include the sensor parameter to indicate
* whether your application used a sensor to determine the user's location.
* This parameter is no longer required.
*/
//{ sensor: false},
{},
/**
* The 'sensor' Parameter
* The Google Maps API previously required that you include the sensor parameter to indicate
* whether your application used a sensor to determine the user's location.
* This parameter is no longer required.
*/
this._defaultOptions = _.extend(
{}, //{ sensor: false},
config['options'] || {}
);
}
};

@@ -159,4 +170,29 @@ /**

return this.options;
}
};
module.exports = new Searcher();
/**
* @access protected
*/
Searcher.prototype._parseAddress = function (str) {
str = _.isEmpty(str)
? EMPTY_ADDRESS_VALUE
: (str).toString();
return str;
};
/**
* @access protected
*/
Searcher.prototype._parseCoordinate = function (crd) {
if (crd) {
crd = parseFloat((crd).toString().replace(',','.'));
}
if (!_.isNumber(crd)) {
crd = EMPTY_COORDINATE_VALUE;
}
return crd;
};
module.exports = Searcher;
var _ = require('underscore');
var Searcher = require('./communicator/request');
var Parser = require('./communicator/parser');
var Parser = require('./parser');

@@ -9,9 +9,8 @@ /**

*/
function CommunicationWrapper() {}
function SearchWrapper() {}
CommunicationWrapper.prototype.extendCallback = function (callback) {
return function (error, data) {
(error)
? Parser.emit('parse_error', error)
: Parser.emit('parse_data', data);
SearchWrapper.prototype.extendCallback = function (callback) {
return function (error, data) {
error = Parser.parseError(error);
data = Parser.parseData(data);

@@ -22,3 +21,3 @@ if (_.isFunction(callback)) {

}
}
};

@@ -28,6 +27,7 @@ /**

*/
CommunicationWrapper.prototype.geocode = function (address, callback, options) {
SearchWrapper.prototype.geocode = function (address, callback, options) {
var extendedCallback = this.extendCallback(callback);
Searcher.geocode(address, extendedCallback, options);
}
var searcher = new Searcher();
searcher.geocode(address, extendedCallback, options);
};

@@ -37,7 +37,8 @@ /**

*/
CommunicationWrapper.prototype.reverseGeocode = function (lat, lng, callback, options) {
SearchWrapper.prototype.reverseGeocode = function (lat, lng, callback, options) {
var extendedCallback = this.extendCallback(callback);
Searcher.reverseGeocode(lat, lng, extendedCallback, options);
}
var searcher = new Searcher();
searcher.reverseGeocode(lat, lng, extendedCallback, options);
};
module.exports = new CommunicationWrapper();
module.exports = new SearchWrapper();
{
"name": "search-google-geocode",
"version": "0.0.9",
"version": "0.0.10",
"description": "Public search geographical location or address using Google Geocoding API: [reverse] geocoding.",

@@ -10,4 +10,4 @@ "main": "index.js",

"dependencies": {
"underscore": "^1.6.0",
"request": "^2.36.0"
"request": "^2.40.0",
"underscore": "^1.6.0"
},

@@ -18,9 +18,10 @@ "keywords": [

"google",
"geocoder"
"geocoder",
"reverse"
],
"repository": {
"type": "git",
"url": "git://github.com/kolegm/google-geocoder.git"
"url": "git://github.com/kolegm/search-google-geocode.git"
},
"author": {
"author": {
"name": "Oleg Kravchuk",

@@ -27,0 +28,0 @@ "email": "kolegm.real@gmail.com"

@@ -1,2 +0,2 @@

##google-geocoder
##search-google-geocoder

@@ -18,3 +18,3 @@ ### General

### Installation
>npm install google-geocoder [-S]
>npm install search-google-geocode [-S]

@@ -24,3 +24,3 @@ ### Usage example

// initialize geocoder instance
var geocoder = require('google-geocoder');
var geocoder = require('search-google-geocode');

@@ -27,0 +27,0 @@ // request parameters

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc