Socket
Socket
Sign inDemoInstall

googlemaps

Package Overview
Dependencies
2
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.6 to 0.1.7

test/encodedpolyline-test.js

626

lib/googlemaps.js
var qs = require('querystring'),
request = require('request');
request = require('request'),
crypto = require('crypto'),
url = require('url'),
waitress = require('waitress'),
util = require('util'),
config;
var proxy;
// this is deprecated
exports.setProxy = function(uri) {
proxy = uri;
config('proxy', uri);
};
var _config = {
'google-client-id': null,
'stagger-time': 200,
'encode-polylines': true,
'proxy': null,
set 'google-private-key'(privateKey) {
if (privateKey){
// Google private keys are URL friendly base64, needs to be replaced with base64 valid characters
this.googlePrivateKey = privateKey.replace(/-/g,'+').replace(/_/g,'/');
this.googlePrivateKey = new Buffer(this.googlePrivateKey, 'base64');
} else {
this.googlePrivateKey = null;
}
},
get 'google-private-key'() {
return this.googlePrivateKey || null;
}
};
exports.config = config = function(key, value) {
if (arguments.length === 1) {
if (typeof key === 'object' && key !== null) {
var settings = key;
for (var key in settings) {
config(key, settings[key]);
}
} else {
return _config[key];
}
} else {
_config[key] = value;
}
};
// http://code.google.com/apis/maps/documentation/places/
exports.places = function(latlng, radius, key, callback, sensor, types, lang, name) {
var args = {
location: latlng,
radius: radius,
key: key
};
if (types) args.types = types;
if (lang) args.lang = lang;
if (name) args.name = name;
args.sensor = sensor || 'false';
var args = {
location: latlng,
radius: radius,
key: key
};
if (types) args.types = types;
if (lang) args.lang = lang;
if (name) args.name = name;
args.sensor = sensor || 'false';
var path = '/maps/api/place/search/json?' + qs.stringify(args);
makeRequest(path, true, returnObjectFromJSON(callback));
var path = '/maps/api/place/search/json';
return makeRequest(path, args, true, returnObjectFromJSON(callback));
};
exports.placeDetails = function(referenceId, key, callback, sensor, lang) {
var args = {
reference: referenceId,
key: key
};
if (lang) args.lang = lang;
args.sensor = sensor || 'false';
var path = '/maps/api/place/details/json?' + qs.stringify(args);
makeRequest(path, true, returnObjectFromJSON(callback));
var args = {
reference: referenceId,
key: key
};
if (lang) args.lang = lang;
args.sensor = sensor || 'false';
var path = '/maps/api/place/details/json';
return makeRequest(path, args, true, returnObjectFromJSON(callback));
};
// http://code.google.com/apis/maps/documentation/geocoding/
exports.geocode = function(address , callback , sensor , bounds , region , language){
var args = {
'address': address
};
if(bounds){ args.bounds = bounds; }
if(region){ args.region = region; }
if(language){ args.language = language; }
args.sensor = sensor || 'false';
exports.geocode = function(address, callback, sensor, bounds, region, language) {
var args = {
'address': address
};
if (bounds) args.bounds = bounds;
if (region) args.region = region;
if (language) args.language = language;
args.sensor = sensor || 'false';
var path = '/maps/api/geocode/json?' + qs.stringify(args);
makeRequest(path, false, returnObjectFromJSON(callback));
var path = '/maps/api/geocode/json';
return makeRequest(path, args, false, returnObjectFromJSON(callback));
};
// http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding
exports.reverseGeocode = function(latlng , callback , sensor , language ){
var args = {
'latlng': latlng
};
if(language){ args.language = language; }
args.sensor = sensor || 'false';
var path = '/maps/api/geocode/json?' + qs.stringify(args);
makeRequest(path, false, returnObjectFromJSON(callback));
exports.reverseGeocode = function(latlng, callback, sensor, language ) {
var args = {
'latlng': latlng
};
if (language) args.language = language;
args.sensor = sensor || 'false';
var path = '/maps/api/geocode/json';
return makeRequest(path, args, false, returnObjectFromJSON(callback));
};
// http://code.google.com/apis/maps/documentation/distancematrix/
exports.distance = function(origins, destinations, callback, sensor, mode, alternatives, avoid, units, language){
var args = {
'origins': origins,
'destinations': destinations
};
args.sensor = sensor || 'false';
if(mode){ args.mode = mode; }
if(avoid){ args.avoid = avoid; }
if(units){ args.units = units; }
if(language){ args.language = language; }
var path = '/maps/api/distancematrix/json?' + qs.stringify(args);
makeRequest(path, false, returnObjectFromJSON(callback));
exports.distance = function(origins, destinations, callback, sensor, mode, alternatives, avoid, units, language) {
var args = {
'origins': origins,
'destinations': destinations
};
if (mode) args.mode = mode;
if (avoid) args.avoid = avoid;
if (units) args.units = units;
if (language) args.language = language;
args.sensor = sensor || 'false';
var path = '/maps/api/distancematrix/json';
return makeRequest(path, args, false, returnObjectFromJSON(callback));
};
// http://code.google.com/apis/maps/documentation/directions/
exports.directions = function(origin, destination, callback, sensor, mode, waypoints, alternatives, avoid, units, language) {
var args = {
'origin': origin,
'destination': destination
};
if (mode) args.mode = mode;
if (waypoints) args.waypoints = waypoints;
if (alternatives) args.alternatives = alternatives;
if (avoid) args.avoid = avoid;
if (units) args.units = units;
if (language) args.language = language;
args.sensor = sensor || 'false';
// http://code.google.com/apis/maps/documentation/directions/
exports.directions = function(origin , destination , callback , sensor , mode , waypoints , alternatives , avoid , units , language){
var args = {
'origin': origin,
'destination': destination
};
args.sensor = sensor || 'false';
if(mode){ args.mode = mode; }
if(waypoints){ args.waypoints = waypoints; }
if(alternatives){ args.alternatives = alternatives; }
if(avoid){ args.avoid = avoid; }
if(units){ args.units = units; }
if(language){ args.language = language; }
var path = '/maps/api/directions/json?' + qs.stringify(args);
makeRequest(path, false, returnObjectFromJSON(callback));
var path = '/maps/api/directions/json';
return makeRequest(path, args, false, returnObjectFromJSON(callback));
};

@@ -102,114 +142,196 @@

// http://code.google.com/apis/maps/documentation/elevation/#Locations
exports.elevationFromLocations = function(locations , callback , sensor){
var args = {
'locations': locations
};
args.sensor = sensor || 'false';
var path = '/maps/api/elevation/json?' + qs.stringify(args);
makeRequest(path, false, returnObjectFromJSON(callback));
exports.elevationFromLocations = function(locations, callback, sensor) {
if (config('encode-polylines')){
locations = 'enc:' + createEncodedPolyline(locations);
}
var args = {
'locations': locations
};
args.sensor = sensor || 'false';
var path = '/maps/api/elevation/json';
return makeRequest(path, args, false, returnObjectFromJSON(callback));
};
// http://code.google.com/apis/maps/documentation/elevation/#Paths
exports.elevationFromPath = function(path , samples , callback , sensor){
var args = {
'path': path,
'samples': samples
};
args.sensor = sensor || 'false';
var reqPath = '/maps/api/elevation/json?' + qs.stringify(args);
makeRequest(reqPath, false, returnObjectFromJSON(callback));
exports.elevationFromPath = function(path, samples, callback, sensor) {
if (config('encode-polylines')){
path = 'enc:' + createEncodedPolyline(path);
}
var args = {
'path': path,
'samples': samples
};
args.sensor = sensor || 'false';
var reqPath = '/maps/api/elevation/json';
var maxlen = 1500;
var count = (path.length < maxlen ? 1 : Math.ceil(path.length/maxlen));
if (count === 1) {
makeRequest(reqPath, args, false, returnObjectFromJSON(callback));
} else {
var done = waitress(count, function(err, results) {
results = results.sort(function(a, b) {
return a.n - b.n;
}).map(function(v) {
return v.results;
});
var status = "OK";
var aggregated = [];
results.forEach(function(result) {
aggregated = aggregated.concat(result.results);
if (result.status !== "OK") {
status = result.status;
}
});
results = {
results: aggregated,
status: status
};
callback(null, results);
});
path = path.split("|");
var pieceSize = Math.ceil(path.length / count);
var n = 0;
while (path.length) {
var smallerPath = path.splice(0, pieceSize);
// google will throttle us if we launch all the
// requests together, so we have to stagger them.
(function(n, path, samples) {
path = path.join("|");
var cb = function(err, results) {
if (err) return done(err);
done(null, { n: n, results: results });
};
setTimeout(function() {
exports.elevationFromPath(path, samples, cb, sensor);
}, Math.floor(Math.random() * config('stagger-time')));
})(++n, smallerPath, smallerPath.length);
}
}
};
// http://code.google.com/apis/maps/documentation/staticmaps
exports.staticMap = function(center , zoom , size , callback , sensor ,
maptype , markers, styles, paths){
var args = {
'center': center,
'zoom': zoom,
'size': size
};
var i , k;
exports.staticMap = function(center, zoom, size, callback, sensor ,
maptype, markers, styles, paths) {
var args = {
'center': center,
'zoom': zoom,
'size': size
};
var i, k;
if(maptype){ args.maptype = maptype; }
if(markers){
args.markers = [];
for(i=0; i < markers.length; i++) {
var marker = '';
if(markers[i].size) { marker += '|size:' + markers[i].size; }
if(markers[i].color) { marker += '|color:' + markers[i].color; }
if(markers[i].label) { marker += '|label:' + markers[i].label; }
if(markers[i].icon) { marker += '|icon:' + markers[i].icon; }
if(markers[i].shadow) { marker += '|shadow:' + markers[i].shadow; }
if(markers[i].location){ marker += '|' + markers[i].location; }
args.markers[i] = marker;
}
}
if(styles){
args.style = [];
for(i=0; i < styles.length; i++) {
var new_style = '';
if(styles[i].feature){ new_style += '|feature:' + styles[i].feature; }
if(styles[i].element){ new_style += '|element:' + styles[i].element; }
var rules = styles[i].rules;
if(rules){
for(k in rules) {
var rule = rules[k];
new_style += '|' + k + ':' + rule;
}
}
args.style[i] = new_style;
}
}
if(paths){
args.path = [];
for(i=0; i < paths.length; i++) {
var new_path = '';
if(paths[i].weight) { new_path += '|weight:' + paths[i].weight; }
if(paths[i].color) { new_path += '|color:' + paths[i].color; }
if(paths[i].fillcolor){ new_path += '|fillcolor:' + paths[i].fillcolor; }
var points = paths[i].points;
if (maptype) args.maptype = maptype;
if (markers) {
args.markers = [];
for (i = 0; i < markers.length; i++) {
var marker = '';
if (markers[i].size) marker += '|size:' + markers[i].size;
if (markers[i].color) marker += '|color:' + markers[i].color;
if (markers[i].label) marker += '|label:' + markers[i].label;
if (markers[i].icon) marker += '|icon:' + markers[i].icon;
if (markers[i].shadow) marker += '|shadow:' + markers[i].shadow;
if (markers[i].location) marker += '|' + markers[i].location;
args.markers[i] = marker;
}
}
if (styles) {
args.style = [];
for (i = 0; i < styles.length; i++) {
var new_style = '';
if (styles[i].feature) new_style += '|feature:' + styles[i].feature;
if (styles[i].element) new_style += '|element:' + styles[i].element;
if(points){
for(k=0; k < points.length; k++) {
new_path += '|' + points[k];
}
}
args.path[i] = new_path.replace(/^\|/, '');
}
}
args.sensor = sensor || 'false';
var rules = styles[i].rules;
var path = '/maps/api/staticmap?' + qs.stringify(args);
if (rules) {
for (k in rules) {
var rule = rules[k];
new_style += '|' + k + ':' + rule;
}
}
args.style[i] = new_style;
}
}
if (paths) {
args.path = [];
for (i = 0; i < paths.length; i++) {
var new_path = '';
if (paths[i].weight) new_path += '|weight:' + paths[i].weight;
if (paths[i].color) new_path += '|color:' + paths[i].color;
if (paths[i].fillcolor) new_path += '|fillcolor:' + paths[i].fillcolor;
if( typeof( callback ) === 'function' ){
makeRequest( path , false , callback , 'binary' );
}
var points = paths[i].points;
return 'http://maps.googleapis.com' + path;
if (points) {
if (config('encode-polylines')){
new_path += '|enc:' + createEncodedPolyline(points);
} else {
for (k = 0; k < points.length; k++) {
new_path += '|' + points[k];
}
}
}
args.path[i] = new_path.replace(/^\|/, '');
}
}
args.sensor = sensor || 'false';
var path = '/maps/api/staticmap';
return makeRequest(path, args, false, callback, 'binary');
};
// http://code.google.com/apis/maps/documentation/streetview
exports.streetView = function(size, location, callback, sensor,
heading, fov, pitch) {
var args = {
'size': size,
'location': location
};
if (heading) {
heading = parseInt(heading);
if (heading >= 0 && heading <= 360) {
args.heading = heading;
}
}
if (fov) {
fov = parseInt(fov);
if (fov >= 0 && fov <= 120) {
args.fov = fov;
}
}
if (pitch) {
pitch = parseInt(pitch);
if (pitch >= -90 && pitch <= 90) {
args.pitch = pitch;
}
}
args.sensor = sensor || 'false';
var path = '/maps/api/streetview';
return makeRequest(path, args, false, callback, 'binary');
};
// Helper function to check and convert an array of points, be it strings/numbers/etc
// into the format used by Google Maps for representing lists of latitude/longitude pairs
exports.checkAndConvertArrayOfPoints = function(input){
switch(typeof(input)){
case 'object':
if(input instanceof Array){
var output = [];
for(var i = 0; i < input.length; i++){
output.push(exports.checkAndConvertPoint(input[i]));
}
return output.join('|');
}
break;
case 'string':
return input;
}
throw(new Error("Unrecognized input: checkAndConvertArrayOfPoints accepts Arrays and Strings"));
exports.checkAndConvertArrayOfPoints = function(input) {
switch (typeof input) {
case 'object':
if (input instanceof Array) {
var output = [];
for (var i = 0; i < input.length; i++) {
output.push(exports.checkAndConvertPoint(input[i]));
}
return output.join('|');
}
break;
case 'string':
return input;
}
throw(new Error("Unrecognized input: checkAndConvertArrayOfPoints accepts Arrays and Strings"));
};

@@ -219,44 +341,140 @@

// into the format used by Google Maps for representing latitude/longitude pairs
exports.checkAndConvertPoint = function(input){
switch(typeof(input)){
case 'object':
if(input instanceof Array){
return input[0].toString() + ',' + input[1].toString();
}
break;
case 'string':
return input;
}
throw(new Error("Unrecognized input: checkAndConvertPoint accepts Arrays of Numbers and Strings"));
exports.checkAndConvertPoint = function(input) {
switch (typeof input) {
case 'object':
if (input instanceof Array) {
return input[0].toString() + ',' + input[1].toString();
}
break;
case 'string':
return input;
}
throw(new Error("Unrecognized input: checkAndConvertPoint accepts Arrays of Numbers and Strings"));
};
// Wraps the callback function to convert the output to a javascript object
var returnObjectFromJSON = function(callback){
return function(err, jsonString){
callback(err , JSON.parse(jsonString));
};
var returnObjectFromJSON = function(callback) {
if (typeof callback === 'function') {
return function(err, jsonString) {
try {
callback(err, JSON.parse(jsonString));
} catch (e) {
callback(e);
}
};
}
return false;
};
// Algorithm pull from Google's definition of an encoded polyline
//
// https://developers.google.com/maps/documentation/utilities/polylinealgorithm
function createEncodedPolyline(points) {
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 11
//
var i, dlat, dlng;
var plat = 0;
var plng = 0;
var encoded_points = "";
if(typeof points === 'string'){
points = points.split('|');
}
for(i = 0; i < points.length; i++) {
var point = points[i].split(',');
var lat = point[0];
var lng = point[1];
var late5 = Math.round(lat * 1e5);
var lnge5 = Math.round(lng * 1e5);
dlat = late5 - plat;
dlng = lnge5 - plng;
plat = late5;
plng = lnge5;
encoded_points += encodeSignedNumber(dlat) + encodeSignedNumber(dlng);
}
return encoded_points;
}
exports.createEncodedPolyline = createEncodedPolyline;
function encodeNumber(num) {
var encodeString = "";
var nextValue, finalValue;
while (num >= 0x20) {
nextValue = (0x20 | (num & 0x1f)) + 63;
encodeString += (String.fromCharCode(nextValue));
num >>= 5;
}
finalValue = num + 63;
encodeString += (String.fromCharCode(finalValue));
return encodeString;
}
function encodeSignedNumber(num) {
var sgn_num = num << 1;
if (num < 0) {
sgn_num = ~(sgn_num);
}
return(encodeNumber(sgn_num));
}
function buildUrl(path, args) {
if (config('google-client-id') && config('google-private-key')) {
args.client = config('google-client-id');
path = path + "?" + qs.stringify(args);
// Create signer object passing in the key, telling it the key is in base64 format
var signer = crypto.createHmac('sha1', config('google-private-key'));
// Get the signature, telling it to return the sig in base64 format
var signature = signer.update(path).digest('base64');
signature = signature.replace(/\+/g,'-').replace(/\//g,'_');
path += "&signature=" + signature;
return path;
} else {
return path + "?" + qs.stringify(args);
}
}
// Makes the request to Google Maps API.
// If secure is true, uses https. Otherwise http is used.
var makeRequest = function(path, secure, callback, encoding){
var options = {
uri: (secure ? 'https' : 'http') + '://maps.googleapis.com' + path
};
if( encoding ) {
options.encoding = encoding;
}
if( proxy ) {
options.proxy = proxy;
}
var makeRequest = function(path, args, secure, callback, encoding) {
var maxlen = 2048;
request(options, function (error, res, data) {
if( error ) {
return callback(error);
}
if (res.statusCode === 200) {
return callback(null, data);
}
return callback(new Error("Response status code: " + res.statusCode), data);
});
var path = buildUrl(path, args);
if (path.length > maxlen) {
throw new Error("Request too long for google to handle (2048 characters).");
}
var options = {
uri: (secure ? 'https' : 'http') + '://maps.googleapis.com' + path
};
if (encoding) options.encoding = encoding;
if (config('proxy')) options.proxy = config('proxy');
if (typeof callback === 'function') {
request(options, function (error, res, data) {
if (error) {
return callback(error);
}
if (res.statusCode === 200) {
return callback(null, data);
}
return callback(new Error("Response status code: " + res.statusCode), data);
});
}
return options.uri;
};
// vim: set expandtab sw=2:
{
"name": "googlemaps",
"version": "0.1.6",
"version": "0.1.7",
"main": "./lib/googlemaps",
"description": "A simple way to query the Google Maps API from Node.js",
"author": "Colin <moshen.colin@gmail.com>",
"author": {
"name": "Colin Kennedy",
"email": "moshen.colin@gmail.com",
"url": "http://moshen.net"
},
"keywords": [
"map",
"geo",
"geocode",
"google",

@@ -25,3 +28,4 @@ "api"

"dependencies": {
"request": "~2.2.9"
"request": "~2.2.9",
"waitress": ">=0.0.2"
},

@@ -28,0 +32,0 @@ "scripts": {

# Google Maps API for Node.js
A simple way to query the Google Maps API from Node.js
This was a quick hack to work with Node.js. Criticism/Suggestions/Patches/PullReq's welcome.
This has become a fairly complete api. Criticism/Suggestions/Patches/PullReq's welcome.

@@ -25,2 +25,3 @@ # Installation

* [Static Maps](http://code.google.com/apis/maps/documentation/staticmaps/)
* [Street View](http://code.google.com/apis/maps/documentation/streetview/)

@@ -84,2 +85,20 @@ TODO:

# Configuration
To set the configuration you call `gm.config(key, value)` or `gm.config({key: value, .....})`
### Useful Configuration Options
`proxy` - set a proxy for http requests
`stagger-time` - defaults to 200ms - stagger async call times when multiple requests are required
`encode-polylines` - defaults to true - encodes polylines to the shorter Google format.
`google-client-id` - used for setting business specific parameters
`google-private-key`- used for setting business specific parameters
-------------
All the googlemaps functions follow this scheme:

@@ -100,2 +119,5 @@ function(required, callback, optional)

[![JoshSmith](https://secure.gravatar.com/avatar/b07d5a5f2e75633b2085142250a6762b?s=50)](https://github.com/JoshSmith)
[![grobot](https://secure.gravatar.com/avatar/ba3313effc329919b09bca67827bdf10?s=50)](https://github.com/grobot)
[![regality](https://secure.gravatar.com/avatar/fe513a9e239cebde58187721d67b7505?s=50)](https://github.com/regality)
[![spatical](https://secure.gravatar.com/avatar/a7c5765a4a4dfbf697f728bd75223641?s=50)](https://github.com/spatical)
var vows = require('vows'),
assert = require('assert'),
gm = require('../lib/googlemaps');
assert = require('assert'),
gm = require('../lib/googlemaps');
vows.describe('directions').addBatch({
'Simple Directions (From: Madison, Wi To: Chicago, Il)': {
topic: function(){
gm.directions('Madison , Wi, USA', 'Chicago, Il, USA' , this.callback , 'false');
},
'returns as a valid request': function(err, result){
assert.ifError(err);
assert.equal(result.status, 'OK');
},
'returns expected lat/lng for Chicago': function(err, result){
assert.equal(result.routes[0].legs[0].steps[0].end_location.lat , 43.07330000000001);
assert.equal(result.routes[0].legs[0].steps[0].end_location.lng , -89.40240000000001);
}
}
'Simple Directions (From: Madison, Wi To: Chicago, Il)': {
topic: function(){
gm.directions('Madison , Wi, USA', 'Chicago, Il, USA' , this.callback , 'false');
},
'returns as a valid request': function(err, result){
assert.ifError(err);
assert.equal(result.status, 'OK');
},
'returns expected lat/lng for Chicago': function(err, result){
assert.equal(result.routes[0].legs[0].steps[0].end_location.lat , 43.07330000000001);
assert.equal(result.routes[0].legs[0].steps[0].end_location.lng , -89.40240000000001);
}
}
}).export(module);

@@ -450,1 +450,3 @@

*/
// vim: set expandtab sw=2:
var vows = require('vows'),
assert = require('assert'),
gm = require('../lib/googlemaps');
assert = require('assert'),
gm = require('../lib/googlemaps');
vows.describe('elevationFromLocations').addBatch({
'Simple elevationFromLocations request (41.850033,-87.6500523)': {
topic: function(){
gm.elevationFromLocations('41.850033,-87.6500523', this.callback, 'false');
},
'returns as a valid request': function(err, result){
assert.equal(result.status , 'OK');
},
'returns the expected elevation for Chicago': function(err, result){
assert.equal(result.results[0].elevation , 178.6981048583984);
}
}
'Simple elevationFromLocations request (41.850033,-87.6500523)': {
topic: function(){
gm.elevationFromLocations('41.850033,-87.6500523', this.callback, 'false');
},
'returns as a valid request': function(err, result){
assert.equal(result.status , 'OK');
},
'returns the expected elevation for Chicago': function(err, result){
assert.notEqual(result.results, false);
assert.notEqual(result.results.length, 0);
assert.equal(Math.round(result.results[0].elevation) , 179);
}
}
}).export(module);

@@ -35,18 +37,76 @@

vows.describe('elevationFromPath').addBatch({
'Simple elevationFromPath request (43.07333,-89.4026|41.850033,-87.6500523)': {
topic: function(){
gm.elevationFromPath('43.07333,-89.4026|41.850033,-87.6500523', '10', this.callback, 'false');
},
'returns as a valid request': function(err, result){
assert.equal(result.status , 'OK');
},
'returns the expected number of samples': function(err, result){
assert.equal(result.results.length , 10);
},
'returns the expected elevation for Chicago': function(err, result){
assert.equal(result.results[9].elevation , 178.6981048583984);
}
}
'Simple elevationFromPath request (43.07333,-89.4026|41.850033,-87.6500523)': {
topic: function(){
gm.elevationFromPath('43.07333,-89.4026|41.850033,-87.6500523', '10', this.callback, 'false');
},
'returns as a valid request': function(err, result){
assert.equal(result.status , 'OK');
},
'returns the expected number of samples': function(err, result){
assert.notEqual(result.results, false);
assert.equal(result.results.length , 10);
},
'returns the expected elevation for Chicago': function(err, result){
if (err) throw err;
if (!result || !result.results || !result.results.length) return;
assert.equal(Math.round(result.results[9].elevation) , 179);
}
}
}).export(module);
var tooLongForGoogle =
"42.233167,-71.475141|42.231813,-71.477802|42.2325,-71.479332|42.235003,-71.478509|42.23663,-71.476585|42.236069,-71.474188|42.234782,-71.47375|42.233651,-71.472736|42.232583,-71.472161|42.231611,-71.472123|" +
"42.230551,-71.474505|42.229304,-71.475523|42.229743,-71.476897|42.231129,-71.477775|42.232236,-71.476559|42.233133,-71.475043|42.234393,-71.473395|42.234427,-71.473494|42.225212,-71.477197|42.226611,-71.475798|" +
"42.228311,-71.477173|42.22915,-71.474977|42.230248,-71.474195|42.23108,-71.472386|42.230825,-71.470825|42.231444,-71.47051|42.232913,-71.46921|42.233814,-71.469197|42.23422,-71.470424|42.233816,-71.470748|" +
"42.235371,-71.472166|42.236272,-71.470456|42.236755,-71.4681|42.236183,-71.467932|42.237428,-71.466962|42.237873,-71.468046|42.23749,-71.469098|42.238301,-71.469905|42.238501,-71.468992|42.241302,-71.466047|" +
"42.241781,-71.463884|42.242639,-71.464208|42.242581,-71.463527|42.243371,-71.463655|42.242612,-71.465419|42.243769,-71.466919|42.245152,-71.464597|42.245775,-71.465785|42.247161,-71.464966|42.24657,-71.458931|" +
"42.240585,-71.46088|42.233432,-71.466855|42.230899,-71.470731|42.246102,-71.475639|42.244165,-71.470279|42.244167,-71.470182|42.241075,-71.486544|42.233428,-71.482075|42.231093,-71.478445|42.232469,-71.476415|" +
"42.232469,-71.476415|42.237965,-71.493087|42.231532,-71.487405|42.230937,-71.484958|42.22623,-71.477746|42.223808,-71.471448|42.22388,-71.471451|42.244642,-71.468811|42.244642,-71.46879|42.24462,-71.46879|" +
"42.244685,-71.468811|42.244663,-71.469197|42.244384,-71.469541|42.244127,-71.469884|42.244148,-71.470506|42.244792,-71.470206|42.245371,-71.470013|42.245994,-71.470184|42.246594,-71.47027|42.247067,-71.469798|" +
"42.247474,-71.468961|42.247732,-71.46806|42.247646,-71.467352|42.247174,-71.467073|42.24668,-71.466794|42.24653,-71.466343|42.247024,-71.466|42.247496,-71.465356|42.247303,-71.464713|42.247195,-71.463919|" +
"42.247109,-71.463189|42.247024,-71.46246|42.246959,-71.461794|42.246959,-71.462181|42.247024,-71.462867|42.247109,-71.463597|42.247174,-71.464305|42.24726,-71.46497|42.247388,-71.465571|42.247517,-71.466172|" +
"42.24741,-71.466515|42.247152,-71.466665|42.246959,-71.466751|42.24668,-71.466751|42.246122,-71.466644|42.245436,-71.466537|42.244728,-71.466515|42.244041,-71.466622|42.243762,-71.466773|42.243783,-71.466944|" +
"42.243719,-71.467052|42.243655,-71.467137|42.243633,-71.467245|42.24359,-71.46733|42.243569,-71.467373|42.243526,-71.467416|42.24344,-71.467309|42.243311,-71.466794|42.242968,-71.466172|42.242775,-71.465871|" +
"42.242453,-71.4657|42.24211,-71.465721|42.241917,-71.465914|42.241724,-71.466193|42.241423,-71.466515|42.241209,-71.467052|42.241101,-71.467566|42.240908,-71.46791|42.240801,-71.468232|42.240736,-71.468554|" +
"42.240672,-71.468875|42.240629,-71.46924|42.240694,-71.469584|42.240822,-71.469841|42.240908,-71.47012|42.241037,-71.470377|42.241209,-71.470656|42.24138,-71.470957|42.241616,-71.470935|42.241917,-71.470957|" +
"42.242303,-71.471021|42.242968,-71.470935|42.243612,-71.471171|42.244148,-71.471107|42.244277,-71.470914|42.244277,-71.470592|42.244277,-71.470592|42.24447,-71.470292|42.244771,-71.470099|42.245049,-71.46997|" +
"42.245371,-71.469948|42.2458,-71.470034|42.246251,-71.470099|42.246745,-71.470034|42.247174,-71.469498|42.247474,-71.46879|42.24771,-71.468039|42.247667,-71.467502|42.247303,-71.46733|42.247024,-71.467137|" +
"42.246809,-71.466837|42.246788,-71.466472|42.24726,-71.466172|42.247474,-71.465271|42.247109,-71.464906|42.247045,-71.464262|42.246981,-71.463618|42.246938,-71.462996|42.246873,-71.462417|42.246809,-71.461945|" +
"42.246852,-71.462417|42.246916,-71.463039|42.247002,-71.463661|42.247088,-71.464283|42.247152,-71.464863|42.247303,-71.465421|42.24741,-71.465957|42.247453,-71.466408|42.247388,-71.46673|42.24726,-71.466923|" +
"42.247088,-71.467052|42.246852,-71.467073|42.246444,-71.467052|42.245886,-71.46703|42.245286,-71.467159|42.244599,-71.467352|42.24447,-71.467438|42.24447,-71.467545|42.244406,-71.467652|42.244277,-71.467738|" +
"42.244148,-71.467824|42.24402,-71.467888|42.243869,-71.46791|42.243719,-71.467867|42.243526,-71.467588|42.243354,-71.467245|42.243161,-71.46688|42.242968,-71.466515|42.241874,-71.465828|42.241638,-71.466022|" +
"42.241466,-71.466472|42.241209,-71.466966|42.24093,-71.467395|42.240672,-71.467781|42.240479,-71.468124|42.240372,-71.468403|42.240264,-71.468661|42.2402,-71.468897|42.240157,-71.469133|42.240136,-71.469412|" +
"42.240093,-71.469734|42.240114,-71.470013|42.240243,-71.47027|42.240372,-71.47042|42.240479,-71.470592|42.240651,-71.470764|42.240844,-71.470978|42.240994,-71.471214|42.24123,-71.471107|42.241466,-71.471021|" +
"42.241702,-71.471043|42.242024,-71.471064|42.242668,-71.471128|42.243161,-71.471407|42.243505,-71.471386|42.243805,-71.471021|42.243912,-71.470571|42.243912,-71.470571|42.243934,-71.470034|42.244298,-71.469691|" +
"42.245607,-71.470206|42.246144,-71.470356|42.246723,-71.47042|42.247303,-71.470077|42.24771,-71.46939|42.247989,-71.468554|42.248096,-71.46776|42.248096,-71.467116|42.247732,-71.466923|42.247431,-71.466644|" +
"42.247195,-71.4663|42.247603,-71.465979|42.248011,-71.465206|42.247624,-71.46482|42.247496,-71.464155|42.24741,-71.46349|42.247303,-71.462846|42.247217,-71.462224|42.247109,-71.461816|42.247152,-71.462352|" +
"42.247195,-71.462975|42.24726,-71.463618|42.247303,-71.464198|42.247345,-71.464777|42.247431,-71.465335|42.247517,-71.465871|42.247453,-71.466215|42.247281,-71.4663|42.247131,-71.466429|42.246959,-71.466537|" +
"42.246723,-71.466601|42.246401,-71.466601|42.2458,-71.466579|42.245286,-71.466687|42.244685,-71.466923|42.244599,-71.467545|42.244663,-71.467996|42.244685,-71.468296|42.244749,-71.468489|42.244813,-71.468639|42.244835,-71.46879|" +
"42.244728,-71.468854|42.244642,-71.468897|42.245711,-71.476375|42.242756,-71.476454|42.239633,-71.477592|42.238147,-71.479715|42.234442,-71.481121|42.230937,-71.484958|42.226311,-71.487297|42.226384,-71.487251|" +
"42.238,-71.493169|42.246158,-71.475746|42.247805,-71.47455|42.252054,-71.471273|42.253871,-71.468872|42.255494,-71.467092|42.256845,-71.461229|42.256808,-71.461276|42.244771,-71.46894|42.244771,-71.468961|" +
"42.244706,-71.469047|42.244384,-71.46939|42.243805,-71.470356|42.244663,-71.469905|42.244899,-71.469734|42.245092,-71.469669|42.245178,-71.469669|42.246294,-71.469862|42.247152,-71.469777|42.247581,-71.468489|" +
"42.247646,-71.468232|42.247624,-71.467373|42.247174,-71.466665|42.247131,-71.466601|42.246873,-71.466472|42.246766,-71.466451|42.246594,-71.466193|42.24653,-71.46615|42.245564,-71.465571|42.245564,-71.465571|" +
"42.245522,-71.465571|42.245178,-71.465421|42.244921,-71.465528|42.244706,-71.465657|42.244105,-71.465828|42.242861,-71.46615|42.242839,-71.467373|42.242925,-71.46718|42.242947,-71.467094|42.243054,-71.467094|" +
"42.242453,-71.465764|42.242281,-71.465399|42.242217,-71.465399|42.242067,-71.465399|42.242024,-71.465421|42.242002,-71.465442|42.241852,-71.465592|42.241638,-71.465807|42.241294,-71.466408|42.241123,-71.466472|" +
"42.240801,-71.466601|42.240543,-71.467288|42.240071,-71.468296|42.2399,-71.468596|42.239943,-71.46894|42.239943,-71.469069|42.239814,-71.469197|42.239728,-71.469584|42.239749,-71.469777|42.239792,-71.469884|" +
"42.240243,-71.470485|42.241359,-71.471879|42.244341,-71.470785|42.244427,-71.470463|42.244427,-71.469455|42.244728,-71.468897|42.24462,-71.468704";
var tooLongCount = tooLongForGoogle.split("|").length;
vows.describe('elevationFromPath when path is too long').addBatch({
'Simple elevationFromPath request (43.07333,-89.4026|41.850033,-87.6500523)': {
topic: function(){
gm.config('encode-polylines', false);
gm.elevationFromPath(tooLongForGoogle, tooLongCount, this.callback, 'false');
},
'returns as a valid request': function(err, result){
assert.equal(result.status , 'OK');
},
'returns the expected number of samples': function(err, result){
assert.equal(result.results.length , tooLongCount);
gm.config('encode-polylines', true);
}
}
}).export(module);
/* Elevation from path query results

@@ -129,1 +189,3 @@ {

*/
// vim: set expandtab sw=2:
var vows = require('vows'),
assert = require('assert'),
gm = require('../lib/googlemaps');
assert = require('assert'),
gm = require('../lib/googlemaps');
vows.describe('geocode').addBatch({
'Simple geocode (Chicago)': {
topic: function(){
gm.geocode('Chicago , Il , USA', this.callback, 'false');
},
'returns as a valid request': function(err, result){
assert.equal(result.status , 'OK');
},
'returns the expected lat/lng for Chicago': function(err, result){
assert.equal(result.results[0].geometry.location.lat , 41.8781136);
assert.equal(result.results[0].geometry.location.lng , -87.6297982);
}
}
'Simple geocode (Chicago)': {
topic: function(){
gm.geocode('Chicago , Il , USA', this.callback, 'false');
},
'returns as a valid request': function(err, result){
assert.equal(result.status , 'OK');
},
'returns the expected lat/lng for Chicago': function(err, result){
assert.equal(result.results[0].geometry.location.lat , 41.8781136);
assert.equal(result.results[0].geometry.location.lng , -87.6297982);
},
'Business Parameters URL': {
topic: function(options){
// Using the signature example clientID and private key for testing,
// http://code.google.com/apis/maps/documentation/business/webservices.html#signature_examples
gm.config('google-client-id','clientID')
gm.config('google-private-key', 'vNIXE0xscrmjlyV-12Nj_BvUPaw=');
return gm.geocode('Chicago , Il , USA', false, false);
},
'returns the expected street view URL': function(result){
assert.equal(result , "http://maps.googleapis.com/maps/api/geocode/json?address=Chicago%20%2C%20Il%20%2C%20USA&sensor=false&client=clientID&signature=m9bKYBws8BKuAO2mRf0sZWKlyPQ=");
gm.config('google-client-id', null);
gm.config('google-private-key', null);
}
}
}
}).export(module);

@@ -95,2 +111,4 @@

}
*/
*/
// vim: set expandtab sw=2:
var vows = require('vows'),
assert = require('assert'),
gm = require('../lib/googlemaps');
assert = require('assert'),
gm = require('../lib/googlemaps');
vows.describe('reverseGeocode').addBatch({
'Simple reverse geocode (41.850033 , -87.6500523)': {
topic: function(){
gm.reverseGeocode('41.850033,-87.6500523' , this.callback , 'false' , 'en')
},
'returns as a valid request': function(err, result){
assert.equal(result.status , 'OK');
},
// For some reason the location of "Chicago" is constantly changing
// according to Google. I thought that it would be a constant I could
// rely on for these tests. If I have to change it one more time,
// I'm going to just comment them all out.
'returns expected name (Pilsen)': function(err, result){
var locality = result.results[0].address_components.filter(function(el) {
return el.types.indexOf('locality') !== -1;
})[0];
assert.equal(locality.long_name , 'Chicago')
}
}
'Simple reverse geocode (41.850033 , -87.6500523)': {
topic: function(){
gm.reverseGeocode('41.850033,-87.6500523' , this.callback , 'false' , 'en')
},
'returns as a valid request': function(err, result){
if (err) throw err;
assert.equal(result.status , 'OK');
},
// For some reason the location of "Chicago" is constantly changing
// according to Google. I thought that it would be a constant I could
// rely on for these tests. If I have to change it one more time,
// I'm going to just comment them all out.
'returns expected name (Pilsen)': function(err, result){
var locality = result.results[0].address_components.filter(function(el) {
return el.types.indexOf('locality') !== -1;
})[0];
assert.equal(locality.long_name , 'Chicago')
}
}
}).export(module);

@@ -1019,1 +1020,3 @@

*/
// vim: set expandtab sw=2:
var vows = require('vows'),
assert = require('assert'),
crypto = require('crypto'),
gm = require('../lib/googlemaps');
assert = require('assert'),
crypto = require('crypto'),
gm = require('../lib/googlemaps');
vows.describe('staticmaps').addBatch({
'Complex static map (Lock Haven, PA)': {
topic: {
'markers': [
{ 'location': '300 W Main St Lock Haven, PA' },
{ 'location': '444 W Main St Lock Haven, PA',
'color' : 'red',
'label' : 'A',
'shadow' : 'false',
'icon' : 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe%7C996600'
}
],
'Complex static map (Lock Haven, PA)': {
topic: {
'markers': [
{ 'location': '300 W Main St Lock Haven, PA' },
{ 'location': '444 W Main St Lock Haven, PA',
'color' : 'red',
'label' : 'A',
'shadow' : 'false',
'icon' : 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe%7C996600'
}
],
'styles': [
{ 'feature': 'road', 'element': 'all', 'rules':
{ 'hue': '0x00ff00' }
}
],
'styles': [
{ 'feature': 'road', 'element': 'all', 'rules':
{ 'hue': '0x00ff00' }
}
],
'paths': [
{ 'color': '0x0000ff', 'weight': '5', 'points':
[ '41.139817,-77.454439', '41.138621,-77.451596' ]
}
]
'paths': [
{ 'color': '0x0000ff', 'weight': '5', 'points':
[ '41.139817,-77.454439', '41.138621,-77.451596' ]
}
]
},
'URL': {
topic: function(options){
return gm.staticMap('444 W Main St Lock Haven PA', 15, '500x400',
false, false, 'roadmap', options.markers, options.styles, options.paths);
},
'returns the expected static map URL': function(result){
assert.equal(result , "http://maps.googleapis.com/maps/api/staticmap?center=444%20W%20Main%20St%20" +
"Lock%20Haven%20PA&zoom=15&size=500x400&maptype=roadmap&markers=%7C300%20W%2" +
"0Main%20St%20Lock%20Haven%2C%20PA&markers=%7Ccolor%3Ared%7Clabel%3AA%7Cicon" +
"%3Ahttp%3A%2F%2Fchart.apis.google.com%2Fchart%3Fchst%3Dd_map_pin_icon%26chl" +
"d%3Dcafe%257C996600%7Cshadow%3Afalse%7C444%20W%20Main%20St%20Lock%20Haven%2" +
"C%20PA&style=%7Cfeature%3Aroad%7Celement%3Aall%7Chue%3A0x00ff00&path=weight" +
"%3A5%7Ccolor%3A0x0000ff%7C41.139817%2C-77.454439%7C41.138621%2C-77.451596&s" +
"ensor=false");
}
},
'URL': {
topic: function(options){
gm.config('encode-polylines', false);
return gm.staticMap('444 W Main St Lock Haven PA', 15, '500x400',
false, false, 'roadmap', options.markers, options.styles, options.paths);
},
'returns the expected static map URL': function(result){
assert.equal(result , "http://maps.googleapis.com/maps/api/staticmap?center=444%20W%20Main%20St%20" +
"Lock%20Haven%20PA&zoom=15&size=500x400&maptype=roadmap&markers=%7C300%20W%2" +
"0Main%20St%20Lock%20Haven%2C%20PA&markers=%7Ccolor%3Ared%7Clabel%3AA%7Cicon" +
"%3Ahttp%3A%2F%2Fchart.apis.google.com%2Fchart%3Fchst%3Dd_map_pin_icon%26chl" +
"d%3Dcafe%257C996600%7Cshadow%3Afalse%7C444%20W%20Main%20St%20Lock%20Haven%2" +
"C%20PA&style=%7Cfeature%3Aroad%7Celement%3Aall%7Chue%3A0x00ff00&path=weight" +
"%3A5%7Ccolor%3A0x0000ff%7C41.139817%2C-77.454439%7C41.138621%2C-77.451596&s" +
"ensor=false");
}
},
'PNG data': {
topic: function(options){
gm.staticMap('444 W Main St Lock Haven PA', 15, '500x400', this.callback, false, 'roadmap', options.markers, options.styles, options.paths);
},
'returns the expected static map PNG data': function(err, data){
var md5 = crypto.createHash('md5');
md5.update(data);
assert.equal(md5.digest('hex') , 'b601ca9a90ec103b95e13595b7e04e71');
}
}
}
'PNG data': {
topic: function(options){
gm.staticMap('444 W Main St Lock Haven PA', 15, '500x400', this.callback, false, 'roadmap', options.markers, options.styles, options.paths);
},
'returns the expected static map PNG data': function(err, data){
var pos = data.indexOf('PNG');
assert.notEqual(pos, -1);
}
}
}
}).export(module);
// vim: set expandtab sw=2:
var vows = require('vows'),
assert = require('assert'),
gm = require('../lib/googlemaps');
assert = require('assert'),
gm = require('../lib/googlemaps');
//vows.describe().addBatch({
//
//
//}).export(module);
vows.describe('checkAndConvertPoint').addBatch({
'Using a lat/lng point as a string': {
topic: gm.checkAndConvertPoint('41.874929479660025,-87.62077331542969'),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969');
}
},
'Using a lat/lng point as an array of numbers': {
topic: gm.checkAndConvertPoint([41.874929479660025, -87.62077331542969]),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969');
}
},
'Using a lat/lng point as a mixed array': {
topic: gm.checkAndConvertPoint([41.874929479660025, ['-87.62077331542969']]),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969');
}
},
'Using incorrect lat/lng input (an object)': {
topic: function(){
try{
return [gm.checkAndConvertPoint({'lat': 41.874929479660025, 'lng': -87.62077331542969}), false];
}catch(e){
return [e, true];
}
},
'an exception was caught': function(result){
assert.ok(result[1]);
},
'exception caught is an Error': function(result){
assert.instanceOf(result[0], Error);
},
'error thrown was checkAndConvertPoint\'s error': function(result){
assert.ok(result[0].message.search('checkAndConvertPoint') > 0);
}
}
'Using a lat/lng point as a string': {
topic: gm.checkAndConvertPoint('41.874929479660025,-87.62077331542969'),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969');
}
},
'Using a lat/lng point as an array of numbers': {
topic: gm.checkAndConvertPoint([41.874929479660025, -87.62077331542969]),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969');
}
},
'Using a lat/lng point as a mixed array': {
topic: gm.checkAndConvertPoint([41.874929479660025, ['-87.62077331542969']]),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969');
}
},
'Using incorrect lat/lng input (an object)': {
topic: function(){
try{
return [gm.checkAndConvertPoint({'lat': 41.874929479660025, 'lng': -87.62077331542969}), false];
}catch(e){
return [e, true];
}
},
'an exception was caught': function(result){
assert.ok(result[1]);
},
'exception caught is an Error': function(result){
assert.instanceOf(result[0], Error);
},
'error thrown was checkAndConvertPoint\'s error': function(result){
assert.ok(result[0].message.search('checkAndConvertPoint') > 0);
}
}
}).export(module);

@@ -50,38 +50,40 @@

vows.describe('checkAndConvertArrayOfPoints').addBatch({
'Using a list of lat/lng points as a string': {
topic: gm.checkAndConvertArrayOfPoints('41.874929479660025,-87.62077331542969|41.874929479660025,-87.62077331542969'),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969|41.874929479660025,-87.62077331542969');
}
},
'Using a list of lat/lng points as a matrix of numbers': {
topic: gm.checkAndConvertArrayOfPoints([[41.874929479660025, -87.62077331542969],[41.874929479660025, -87.62077331542969]]),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969|41.874929479660025,-87.62077331542969');
}
},
'Using a list of lat/lng points as a mixed array': {
topic: gm.checkAndConvertArrayOfPoints([['41.874929479660025', [-87.62077331542969]],[41.874929479660025, ['-87.62077331542969']]]),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969|41.874929479660025,-87.62077331542969');
}
},
'Using incorrect lat/lng input (an object)': {
topic: function(){
try{
return [gm.checkAndConvertArrayOfPoints({'lat': 41.874929479660025, 'lng': -87.62077331542969}), false];
}catch(e){
return [e, true];
}
},
'an exception was caught': function(result){
assert.ok(result[1]);
},
'exception caught is an Error': function(result){
assert.instanceOf(result[0], Error);
},
'error thrown was checkAndConvertArrayOfPoints\'s error': function(result){
assert.ok(result[0].message.search('checkAndConvertArrayOfPoints') > 0);
}
}
}).export(module);
'Using a list of lat/lng points as a string': {
topic: gm.checkAndConvertArrayOfPoints('41.874929479660025,-87.62077331542969|41.874929479660025,-87.62077331542969'),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969|41.874929479660025,-87.62077331542969');
}
},
'Using a list of lat/lng points as a matrix of numbers': {
topic: gm.checkAndConvertArrayOfPoints([[41.874929479660025, -87.62077331542969],[41.874929479660025, -87.62077331542969]]),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969|41.874929479660025,-87.62077331542969');
}
},
'Using a list of lat/lng points as a mixed array': {
topic: gm.checkAndConvertArrayOfPoints([['41.874929479660025', [-87.62077331542969]],[41.874929479660025, ['-87.62077331542969']]]),
'result is equal to expected string value': function(result){
assert.equal(result, '41.874929479660025,-87.62077331542969|41.874929479660025,-87.62077331542969');
}
},
'Using incorrect lat/lng input (an object)': {
topic: function(){
try{
return [gm.checkAndConvertArrayOfPoints({'lat': 41.874929479660025, 'lng': -87.62077331542969}), false];
}catch(e){
return [e, true];
}
},
'an exception was caught': function(result){
assert.ok(result[1]);
},
'exception caught is an Error': function(result){
assert.instanceOf(result[0], Error);
},
'error thrown was checkAndConvertArrayOfPoints\'s error': function(result){
assert.ok(result[0].message.search('checkAndConvertArrayOfPoints') > 0);
}
}
}).export(module);
// vim: set expandtab sw=2:
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc