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

geobatch

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geobatch - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

dist/errors.js

25

CHANGELOG.md

@@ -0,1 +1,26 @@

## 1.3.0 (2016-06-28)
#### Bug Fixes
* **geocoder:**
* require api key or client id / private key option ([6790293d](https://github.com/ubilabs/node-geobatch/commit/6790293d9180d24f744f50792600ce77737d7d5a))
* increase queries per second when authenticated ([3acceafe](https://github.com/ubilabs/node-geobatch/commit/3acceafe479cd6617e355f0506d285108c09fb4a))
* return correct error messages ([90f09bbc](https://github.com/ubilabs/node-geobatch/commit/90f09bbc5f7040ad1e1148f71007ce99e726f162))
* **npm-scripts:** remove `./node_modules/.bin/` from modules call ([bab003df](https://github.com/ubilabs/node-geobatch/commit/bab003df3c0d22a8e891d960e8cf44e020349264))
* **test:** use babel-core as mocha compilers plugin for testing ([54063f16](https://github.com/ubilabs/node-geobatch/commit/54063f1609e34c2fc25580cb77ba31486656a674))
* **tests:** fix rebase bug ([d5a58e14](https://github.com/ubilabs/node-geobatch/commit/d5a58e14ee0943b5fefec7f4756bd11d4cb6338a))
#### Features
* **GeoBatch:** make geocode accept streams ([0a032e74](https://github.com/ubilabs/node-geobatch/commit/0a032e74b3f1655ce7f5bec09461efdc46a3cc42))
* **geobatch:** take accessor function for address ([7588f2ca](https://github.com/ubilabs/node-geobatch/commit/7588f2ca9e3eb23c40506b658a8be6ff910adaa1))
* **geocode stream:** handle stats if input is stream ([f2cdbd89](https://github.com/ubilabs/node-geobatch/commit/f2cdbd892bd48c1294237a18ec56ff0dbaa8187c))
* **geocoder:**
* allow authentication via api key ([c175b492](https://github.com/ubilabs/node-geobatch/commit/c175b492ac2578a145f8441db760de37d748cde6))
* return full geocoding result ([ec20a890](https://github.com/ubilabs/node-geobatch/commit/ec20a8908cfec55c8ec50dfe11b2265649bebee2))
* **geocodestream:** add full input and full result to output stream ([9bd0630c](https://github.com/ubilabs/node-geobatch/commit/9bd0630cd2910695725f0aa954d0871ef2b5622e))
## 1.2.0 (2015-10-13)

@@ -2,0 +27,0 @@

64

dist/array-stream.js

@@ -1,17 +0,6 @@

'use strict';
"use strict";
Object.defineProperty(exports, '__esModule', {
value: true
});
var stream = require("stream"),
util = require("util");
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var stream = require('stream');
/**

@@ -21,36 +10,23 @@ * Create a stream from an array

*/
function ArrayStream(values) {
stream.Readable.call(this, { objectMode: true });
var ArrayStream = (function (_stream$Readable) {
_inherits(ArrayStream, _stream$Readable);
this.values = values;
this.currentIndex = 0;
}
util.inherits(ArrayStream, stream.Readable);
function ArrayStream(values) {
_classCallCheck(this, ArrayStream);
_get(Object.getPrototypeOf(ArrayStream.prototype), 'constructor', this).call(this, { objectMode: true });
this.values = values;
this.currentIndex = 0;
/**
* The _read function for the addresses stream.
*/
/* eslint-disable no-underscore-dangle */
ArrayStream.prototype._read = function () {
/* eslint-enable no-underscore-dangle */
if (this.currentIndex === this.values.length) {
return this.push(null);
}
/**
* The _read function for the addresses stream.
*/
/* eslint-disable no-underscore-dangle */
this.push(this.values[this.currentIndex++]);
};
_createClass(ArrayStream, [{
key: '_read',
value: function _read() {
/* eslint-enable no-underscore-dangle */
if (this.currentIndex === this.values.length) {
return this.push(null);
}
this.push(this.values[this.currentIndex++]);
}
}]);
return ArrayStream;
})(stream.Readable);
exports['default'] = ArrayStream;
module.exports = exports['default'];
module.exports = ArrayStream;

@@ -9,3 +9,3 @@ 'use strict';

var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };

@@ -12,0 +12,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

@@ -27,3 +27,36 @@ /* eslint-disable one-var */

var _errors = require('./errors');
var _errors2 = _interopRequireDefault(_errors);
var defaults = {
clientId: null,
privateKey: null,
apiKey: null
};
/**
* Validate a Geocoder options object
* This function throws an exception if the options are invalid
* @param {Object} options The options object to be validated
*/
function validateOptions(options) {
if ((options.clientId || options.privateKey) && options.apiKey) {
throw new Error('Can only specify credentials or API key');
}
if (options.clientId && !options.privateKey) {
throw new Error('Missing privateKey');
}
if (!options.clientId && options.privateKey) {
throw new Error('Missing clientId');
}
if (!options.apiKey && !(options.clientId && options.privateKey)) {
throw new Error('Must either provide credentials or API key');
}
}
/**
* Geocoder instance

@@ -47,16 +80,7 @@ * @type {Class}

options.clientId = options.clientId || null;
options.privateKey = options.privateKey || null;
options = Object.assign({}, defaults, options);
validateOptions(options);
if (options.clientId && !options.privateKey) {
throw new Error('Missing privateKey');
}
if (!options.clientId && options.privateKey) {
throw new Error('Missing clientId');
}
this.timeBetweenRequests = options.clientId && options.privateKey ? 100 : 200;
this.timeBetweenRequests = 20;
this.maxRequests = 20;
this.lastGeocode = new Date();

@@ -66,3 +90,7 @@ this.currentRequests = 0;

this.cache = new GeoCache(options.cacheFile);
this.geocoder = geocoder.init(options);
this.geocoder = geocoder.init({
clientId: options.clientId,
privateKey: options.privateKey,
key: options.apiKey
});
}

@@ -114,7 +142,13 @@

this.geocoder.geocode(address.replace('\'', ''), function (error, response) {
var geoCodeParams = {
address: address.replace('\'', '')
};
this.geocoder.geocode(geoCodeParams, function (error, response) {
_this2.currentRequests--;
if (error) {
return reject(new Error('Wrong clientId or privateKey'));
var errorMessage = _errors2['default'][error.code] || 'Google Maps API error: ' + error.code;
return reject(new Error(errorMessage));
}

@@ -121,0 +155,0 @@

@@ -50,2 +50,3 @@ /* eslint-disable one-var */

privateKey: null,
apiKey: null,
accessor: function accessor(address) {

@@ -62,2 +63,4 @@ return address;

var privateKey = _ref$privateKey === undefined ? null : _ref$privateKey;
var _ref$apiKey = _ref.apiKey;
var apiKey = _ref$apiKey === undefined ? null : _ref$apiKey;
var _ref$accessor = _ref.accessor;

@@ -71,3 +74,3 @@ var accessor = _ref$accessor === undefined ? function (address) {

this.geocoder = new Geocoder({ cacheFile: cacheFile, clientId: clientId, privateKey: privateKey });
this.geocoder = new Geocoder({ cacheFile: cacheFile, clientId: clientId, privateKey: privateKey, apiKey: apiKey });
this.GeocodeStream = GeocodeStream;

@@ -74,0 +77,0 @@ this.accessor = accessor;

@@ -17,2 +17,8 @@ 'use strict';

var defaults = {
clientId: null,
privateKey: null,
key: null
};
var GoogleGeocoder = (function () {

@@ -32,10 +38,6 @@ function GoogleGeocoder() {

value: function init() {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? { clientId: null, privateKey: null } : arguments[0];
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var clientId = _ref.clientId;
var privateKey = _ref.privateKey;
_googlemaps2['default'].config('google-client-id', clientId);
_googlemaps2['default'].config('google-private-key', privateKey);
return _googlemaps2['default'];
options = Object.assign({}, defaults, options);
return new _googlemaps2['default'](options);
}

@@ -42,0 +44,0 @@ }]);

{
"name": "geobatch",
"description": "Batch geocode addresses from multiple sources.",
"version": "1.2.0",
"version": "1.3.0",
"author": {

@@ -36,3 +36,3 @@ "name": "Robert Katzki",

"flat-file-db": "^0.1.4",
"googlemaps": "^0.1.20",
"googlemaps": "^1.6.0",
"into-stream": "^2.0.0"

@@ -39,0 +39,0 @@ },

@@ -128,2 +128,3 @@ # node-geobatch

privateKey: 'myPrivateKey',
apiKey: 'myApiKey',
cacheFile: 'myGeocache.db',

@@ -136,3 +137,4 @@ accessor: myAccessorFunction

Type `String`. The Google Maps Client ID, if you are using Google for Work. If this is passed in, the `privateKey` is also required. Default is `null`.
Type `String`. The Google Maps Client ID, if you are using Google for Work. If this is passed in, the `privateKey` is also required.
You must provide either a `clientId` and `privateKey`, or an `apiKey`. Default is `null`.

@@ -143,2 +145,8 @@ #### `privateKey`

#### `apiKey`
Type `String`. The Google Maps API key. If this is passed, neither `clientId` nor `privateKey` may be set.
You must provide either a `clientId` and `privateKey`, or an `apiKey`.
Default is `null`.
#### `cacheFile`

@@ -145,0 +153,0 @@

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