Socket
Socket
Sign inDemoInstall

mapbox

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox - npm Package Compare versions

Comparing version 0.8.2 to 0.9.0

beauty.js

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## 0.9.0
- Adds a `precision` option to geocodeForward and geocodeReverse methods:
this allows you to customize how much decimal precision is provided
wth proximity parameters and the location of geocodeReverse requests,
potentially increasing cache-friendliness.
## 0.8.2

@@ -2,0 +9,0 @@

4

lib/callbackify.js

@@ -21,3 +21,5 @@ 'use strict';

if (typeof callback === 'function') {
callback(response.error || response.entity);
var err = response.error || response.entity;
if (typeof err !== 'object') err = new Error(err);
callback(err);
}

@@ -24,0 +26,0 @@

@@ -5,4 +5,4 @@ // We keep all of the constants that declare endpoints in one

module.exports.DEFAULT_ENDPOINT = 'https://api.mapbox.com';
module.exports.API_GEOCODER_FORWARD = '/v4/geocode/{dataset}/{query}.json';
module.exports.API_GEOCODER_REVERSE = '/v4/geocode/{dataset}/{longitude},{latitude}.json';
module.exports.API_GEOCODER_FORWARD = '/geocoding/v5/{dataset}/{query}.json{?proximity}';
module.exports.API_GEOCODER_REVERSE = '/geocoding/v5/{dataset}/{longitude},{latitude}.json';
module.exports.API_DIRECTIONS = '/v4/directions/{profile}/{encodedWaypoints}.json';

@@ -22,1 +22,2 @@ module.exports.API_DISTANCE = '/distances/v1/mapbox/{profile}';

module.exports.API_TILESTATS_ATTRIBUTE = '/tilestats/v1/{owner}/{tileset}/{layer}/{attribute}';
module.exports.API_STATIC = '/v4/{mapid}{+overlay}/{+xyz}/{width}x{height}{+retina}{.format}';
'use strict';
var invariant = require('invariant');
var assertLocation = require('./assert_location');

@@ -17,5 +17,3 @@ /**

return waypoints.map(function(location) {
invariant(typeof location.latitude === 'number' &&
typeof location.longitude === 'number',
'location must be an object with numeric latitude & longitude properties');
assertLocation(location);
return location.longitude + ',' + location.latitude;

@@ -22,0 +20,0 @@ }).join(';');

'use strict';
var atob = require('atob');
/**

@@ -18,10 +20,14 @@ * Access tokens actually are data, and using them we can derive

var mod = data.length % 4;
if (mod === 2) data += '==';
if (mod === 3) data += '=';
if (mod === 1 || mod > 3) return null;
// window.atob does not require padding
if (!process.browser) {
var mod = data.length % 4;
if (mod === 2) data += '==';
if (mod === 3) data += '=';
if (mod === 1 || mod > 3) return null;
} else {
data = data.replace(/=/g, '');
}
try {
data = (new Buffer(data, 'base64')).toString('utf8');
return JSON.parse(data).u;
return JSON.parse(atob(data)).u;
} catch(err) {

@@ -28,0 +34,0 @@ return null;

'use strict';
var invariant = require('invariant');
var assert = require('assert');
var constants = require('./constants');

@@ -24,3 +24,3 @@ var client = require('./client');

invariant(typeof accessToken === 'string',
assert(typeof accessToken === 'string',
'accessToken required to instantiate Mapbox client');

@@ -31,9 +31,9 @@

if (options !== undefined) {
invariant(typeof options === 'object', 'options must be an object');
assert(typeof options === 'object', 'options must be an object');
if (options.endpoint) {
invariant(typeof options.endpoint === 'string', 'endpoint must be a string');
assert(typeof options.endpoint === 'string', 'endpoint must be a string');
endpoint = options.endpoint;
}
if (options.account) {
invariant(typeof options.account === 'string', 'account must be a string');
assert(typeof options.account === 'string', 'account must be a string');
this.owner = options.account;

@@ -48,4 +48,6 @@ }

this.accessToken = accessToken;
this.endpoint = endpoint;
this.owner = this.owner || getUser(accessToken);
invariant(!!this.owner, 'could not determine account from provided accessToken');
assert(!!this.owner, 'could not determine account from provided accessToken');

@@ -52,0 +54,0 @@ }

'use strict';
var invariant = require('invariant'),
var assert = require('assert'),
geojsonhint = require('geojsonhint/object'),

@@ -43,3 +43,3 @@ hat = require('hat'),

Datasets.prototype.listDatasets = function(callback) {
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof callback === 'function', 'callback must be a function');

@@ -86,4 +86,4 @@ this.client({

invariant(typeof options === 'object', 'options must be an object');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof options === 'object', 'options must be an object');
assert(typeof callback === 'function', 'callback must be a function');

@@ -123,4 +123,4 @@ this.client({

Datasets.prototype.readDataset = function(dataset, callback) {
invariant(typeof dataset === 'string', 'dataset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof dataset === 'string', 'dataset must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -164,6 +164,6 @@ this.client({

Datasets.prototype.updateDataset = function(dataset, options, callback) {
invariant(typeof dataset === 'string', 'dataset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
invariant(typeof options === 'object', 'options must be an object');
invariant(!!options.name || !!options.description, 'options must include a name or a description');
assert(typeof dataset === 'string', 'dataset must be a string');
assert(typeof callback === 'function', 'callback must be a function');
assert(typeof options === 'object', 'options must be an object');
assert(!!options.name || !!options.description, 'options must include a name or a description');

@@ -197,4 +197,4 @@ this.client({

Datasets.prototype.deleteDataset = function(dataset, callback) {
invariant(typeof dataset === 'string', 'dataset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof dataset === 'string', 'dataset must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -244,4 +244,4 @@ this.client({

Datasets.prototype.listFeatures = function(dataset, callback) {
invariant(typeof dataset === 'string', 'dataset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof dataset === 'string', 'dataset must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -333,8 +333,8 @@ this.client({

Datasets.prototype.insertFeature = function(feature, dataset, callback) {
invariant(typeof dataset === 'string', 'dataset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
invariant(geojsonhint.hint(feature).length === 0, 'feature must be valid GeoJSON');
assert(typeof dataset === 'string', 'dataset must be a string');
assert(typeof callback === 'function', 'callback must be a function');
assert(geojsonhint.hint(feature).length === 0, 'feature must be valid GeoJSON');
var id = feature.id || hat();
invariant(typeof id === 'string', 'The GeoJSON feature\'s id must be a string');
assert(typeof id === 'string', 'The GeoJSON feature\'s id must be a string');

@@ -381,5 +381,5 @@ this.client({

Datasets.prototype.readFeature = function(id, dataset, callback) {
invariant(typeof id === 'string', 'id must be a string');
invariant(typeof dataset === 'string', 'dataset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof id === 'string', 'id must be a string');
assert(typeof dataset === 'string', 'dataset must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -413,5 +413,5 @@ this.client({

Datasets.prototype.deleteFeature = function(id, dataset, callback) {
invariant(typeof id === 'string', 'id must be a string');
invariant(typeof dataset === 'string', 'dataset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof id === 'string', 'id must be a string');
assert(typeof dataset === 'string', 'dataset must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -511,5 +511,5 @@ this.client({

Datasets.prototype.bulkFeatureUpdate = function(update, dataset, callback) {
invariant(typeof update === 'object', 'update must be an object');
invariant(typeof dataset === 'string', 'dataset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof update === 'object', 'update must be an object');
assert(typeof dataset === 'string', 'dataset must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -519,7 +519,7 @@ var inserts = update.put || [];

invariant(
assert(
geojsonhint.hint({type: 'FeatureCollection', features: inserts}).length === 0,
'update.put must be an array of valid GeoJSON features'
);
invariant(
assert(
inserts.every(function(feature) { return feature.id; }),

@@ -529,3 +529,3 @@ 'inserted GeoJSON features must include ids'

invariant(
assert(
deletes.every(function(id) { return typeof id === 'string'; }),

@@ -532,0 +532,0 @@ 'update.delete must be an array of strings'

'use strict';
var invariant = require('invariant'),
var assert = require('assert'),
formatPoints = require('../format_points'),

@@ -73,5 +73,5 @@ makeService = require('../make_service'),

// typecheck arguments
invariant(Array.isArray(waypoints), 'waypoints must be an array');
invariant(typeof options === 'object', 'options must be an object');
invariant(typeof callback === 'function', 'callback must be a function');
assert(Array.isArray(waypoints), 'waypoints must be an array');
assert(typeof options === 'object', 'options must be an object');
assert(typeof callback === 'function', 'callback must be a function');

@@ -86,3 +86,3 @@ var encodedWaypoints = formatPoints(waypoints);

if (options.profile) {
invariant(typeof options.profile === 'string', 'profile option must be string');
assert(typeof options.profile === 'string', 'profile option must be string');
profile = options.profile;

@@ -92,3 +92,3 @@ }

if (options.instructions) {
invariant(typeof options.instructions === 'string', 'instructions option must be string');
assert(typeof options.instructions === 'string', 'instructions option must be string');
instructions = options.instructions;

@@ -98,3 +98,3 @@ }

if (options.geometry) {
invariant(typeof options.geometry === 'string', 'geometry option must be string');
assert(typeof options.geometry === 'string', 'geometry option must be string');
geometry = options.geometry;

@@ -101,0 +101,0 @@ }

'use strict';
var invariant = require('invariant'),
var assert = require('assert'),
makeService = require('../make_service'),

@@ -70,3 +70,3 @@ constants = require('../constants');

// typecheck arguments
invariant(Array.isArray(waypoints), 'waypoints must be an array');
assert(Array.isArray(waypoints), 'waypoints must be an array');

@@ -76,3 +76,3 @@ var profile = 'driving';

if (options.profile) {
invariant(typeof options.profile === 'string', 'profile option must be string');
assert(typeof options.profile === 'string', 'profile option must be string');
profile = options.profile;

@@ -79,0 +79,0 @@ }

'use strict';
var invariant = require('invariant'),
var assert = require('assert'),
makeService = require('../make_service'),

@@ -9,2 +9,5 @@ constants = require('../constants');

var REVERSE_GEOCODER_PRECISION = 5;
var FORWARD_GEOCODER_PROXIMITY_PRECISION = 3;
/**

@@ -49,5 +52,5 @@ * Search for a location with a string, using the

// typecheck arguments
invariant(typeof query === 'string', 'query must be a string');
invariant(typeof options === 'object', 'options must be an object');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof query === 'string', 'query must be a string');
assert(typeof options === 'object', 'options must be an object');
assert(typeof callback === 'function', 'callback must be a function');

@@ -59,11 +62,17 @@ var queryOptions = {

var precision = FORWARD_GEOCODER_PROXIMITY_PRECISION;
if (options.precision) {
assert(typeof options.precision === 'number', 'precision option must be number');
precision = options.precision;
}
if (options.proximity) {
invariant(typeof options.proximity.latitude === 'number' &&
assert(typeof options.proximity.latitude === 'number' &&
typeof options.proximity.longitude === 'number',
'proximity must be an object with numeric latitude & longitude properties');
queryOptions.proximity = options.proximity.longitude + ',' + options.proximity.latitude;
queryOptions.proximity = roundTo(options.proximity.longitude, precision) + ',' + roundTo(options.proximity.latitude, precision);
}
if (options.dataset) {
invariant(typeof options.dataset === 'string', 'dataset option must be string');
assert(typeof options.dataset === 'string', 'dataset option must be string');
queryOptions.dataset = options.dataset;

@@ -111,7 +120,7 @@ }

// typecheck arguments
invariant(typeof location === 'object', 'location must be an object');
invariant(typeof options === 'object', 'options must be an object');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof location === 'object', 'location must be an object');
assert(typeof options === 'object', 'options must be an object');
assert(typeof callback === 'function', 'callback must be a function');
invariant(typeof location.latitude === 'number' &&
assert(typeof location.latitude === 'number' &&
typeof location.longitude === 'number',

@@ -122,11 +131,17 @@ 'location must be an object with numeric latitude & longitude properties');

if (options.dataset) {
invariant(typeof options.dataset === 'string', 'dataset option must be string');
assert(typeof options.dataset === 'string', 'dataset option must be string');
dataset = options.dataset;
}
var precision = REVERSE_GEOCODER_PRECISION;
if (options.precision) {
assert(typeof options.precision === 'number', 'precision option must be number');
precision = options.precision;
}
this.client({
path: constants.API_GEOCODER_REVERSE,
params: {
longitude: location.longitude,
latitude: location.latitude,
longitude: roundTo(location.longitude, precision),
latitude: roundTo(location.latitude, precision),
dataset: dataset

@@ -138,2 +153,7 @@ },

function roundTo(value, places) {
var mult = Math.pow(10, places);
return Math.round(value * mult) / mult;
}
module.exports = MapboxGeocoder;
'use strict';
var invariant = require('invariant'),
var assert = require('assert'),
geojsonhint = require('geojsonhint/object'),

@@ -77,5 +77,5 @@ makeService = require('../make_service'),

// typecheck arguments
invariant(geojsonhint.hint(trace).length === 0, 'trace must be valid GeoJSON');
invariant(typeof options === 'object', 'options must be an object');
invariant(typeof callback === 'function', 'callback must be a function');
assert(geojsonhint.hint(trace).length === 0, 'trace must be valid GeoJSON');
assert(typeof options === 'object', 'options must be an object');
assert(typeof callback === 'function', 'callback must be a function');

@@ -88,3 +88,3 @@ var profile = 'mapbox.driving',

if (options.gps_precision !== undefined) {
invariant(typeof options.gps_precision === 'number', 'gps_precision must be a number');
assert(typeof options.gps_precision === 'number', 'gps_precision must be a number');
gps_precision = options.gps_precision;

@@ -94,3 +94,3 @@ }

if (options.profile) {
invariant(typeof options.profile === 'string', 'profile option must be string');
assert(typeof options.profile === 'string', 'profile option must be string');
profile = options.profile;

@@ -100,3 +100,3 @@ }

if (options.geometry) {
invariant(typeof options.geometry === 'string', 'geometry option must be string');
assert(typeof options.geometry === 'string', 'geometry option must be string');
geometry = options.geometry;

@@ -103,0 +103,0 @@ }

'use strict';
var invariant = require('invariant'),
var assert = require('assert'),
formatPoints = require('../format_points'),

@@ -50,8 +50,8 @@ makeService = require('../make_service'),

// typecheck arguments
invariant(typeof mapid === 'string', 'mapid must be a string');
invariant(typeof layer === 'string', 'layer must be a string');
invariant(Array.isArray(fields), 'fields must be an array of strings');
invariant(Array.isArray(path) || typeof path === 'string', 'path must be an array of objects or a string');
invariant(typeof options === 'object', 'options must be an object');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof mapid === 'string', 'mapid must be a string');
assert(typeof layer === 'string', 'layer must be a string');
assert(Array.isArray(fields), 'fields must be an array of strings');
assert(Array.isArray(path) || typeof path === 'string', 'path must be an array of objects or a string');
assert(typeof options === 'object', 'options must be an object');
assert(typeof callback === 'function', 'callback must be a function');

@@ -62,3 +62,3 @@ var interpolate = true,

if (options.interpolate !== undefined) {
invariant(typeof options.interpolate === 'boolean', 'interpolate must be a boolean');
assert(typeof options.interpolate === 'boolean', 'interpolate must be a boolean');
interpolate = options.interpolate;

@@ -68,3 +68,3 @@ }

if (options.geojson !== undefined) {
invariant(typeof options.geojson === 'boolean', 'geojson option must be boolean');
assert(typeof options.geojson === 'boolean', 'geojson option must be boolean');
geojson = options.geojson;

@@ -88,3 +88,3 @@ }

if (options.zoom !== undefined) {
invariant(typeof options.zoom === 'number', 'zoom must be a number');
assert(typeof options.zoom === 'number', 'zoom must be a number');
surfaceOptions.z = options.zoom;

@@ -91,0 +91,0 @@ }

'use strict';
var invariant = require('invariant'),
var assert = require('assert'),
makeService = require('../make_service'),

@@ -19,6 +19,6 @@ constants = require('../constants');

Tilestats.prototype.createTilestats = function(tileset, layers, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
invariant(Array.isArray(layers), 'layers must be an array');
invariant(layers.every(function(layer) {
assert(typeof tileset === 'string', 'tileset must be a string');
assert(typeof callback === 'function', 'callback must be a function');
assert(Array.isArray(layers), 'layers must be an array');
assert(layers.every(function(layer) {
return typeof layer === 'string';

@@ -51,4 +51,4 @@ }), 'layers must be an array of strings');

Tilestats.prototype.deleteTilestats = function(tileset, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof tileset === 'string', 'tileset must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -102,4 +102,4 @@ var owner = tileset.split('.')[0];

Tilestats.prototype.getTilestats = function(tileset, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof tileset === 'string', 'tileset must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -140,6 +140,6 @@ var owner = tileset.split('.')[0];

Tilestats.prototype.updateTilestatsLayer = function(tileset, layer, geometries, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
invariant(typeof layer === 'string', 'layer must be a string');
invariant(typeof geometries === 'object', 'geometries must be an object');
assert(typeof tileset === 'string', 'tileset must be a string');
assert(typeof callback === 'function', 'callback must be a function');
assert(typeof layer === 'string', 'layer must be a string');
assert(typeof geometries === 'object', 'geometries must be an object');

@@ -179,7 +179,7 @@ var owner = tileset.split('.')[0];

Tilestats.prototype.updateTilestatsAttribute = function(tileset, layer, attribute, stats, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
invariant(typeof layer === 'string', 'layer must be a string');
invariant(typeof attribute === 'string', 'attribute must be a string');
invariant(typeof stats === 'object', 'stats must be an object');
assert(typeof tileset === 'string', 'tileset must be a string');
assert(typeof callback === 'function', 'callback must be a function');
assert(typeof layer === 'string', 'layer must be a string');
assert(typeof attribute === 'string', 'attribute must be a string');
assert(typeof stats === 'object', 'stats must be an object');

@@ -232,6 +232,6 @@ var owner = tileset.split('.')[0];

Tilestats.prototype.getTilestatsAttribute = function(tileset, layer, attribute, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
invariant(typeof layer === 'string', 'layer must be a string');
invariant(typeof attribute === 'string', 'attribute must be a string');
assert(typeof tileset === 'string', 'tileset must be a string');
assert(typeof callback === 'function', 'callback must be a function');
assert(typeof layer === 'string', 'layer must be a string');
assert(typeof attribute === 'string', 'attribute must be a string');

@@ -238,0 +238,0 @@ var owner = tileset.split('.')[0];

'use strict';
var invariant = require('invariant'),
var assert = require('assert'),
makeService = require('../make_service'),

@@ -45,3 +45,3 @@ constants = require('../constants');

Uploads.prototype.listUploads = function(callback) {
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof callback === 'function', 'callback must be a function');

@@ -94,3 +94,3 @@ this.client({

Uploads.prototype.createUploadCredentials = function(callback) {
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof callback === 'function', 'callback must be a function');

@@ -147,4 +147,4 @@ this.client({

Uploads.prototype.createUpload = function(options, callback) {
invariant(typeof options === 'object', 'options must be an object');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof options === 'object', 'options must be an object');
assert(typeof callback === 'function', 'callback must be a function');

@@ -184,4 +184,4 @@ this.client({

Uploads.prototype.readUpload = function(upload, callback) {
invariant(typeof upload === 'string', 'upload must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof upload === 'string', 'upload must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -211,4 +211,4 @@ this.client({

Uploads.prototype.deleteUpload = function(upload, callback) {
invariant(typeof upload === 'string', 'upload must be a string');
invariant(typeof callback === 'function', 'callback must be a function');
assert(typeof upload === 'string', 'upload must be a string');
assert(typeof callback === 'function', 'callback must be a function');

@@ -215,0 +215,0 @@ this.client({

{
"name": "mapbox",
"version": "0.8.2",
"version": "0.9.0",
"description": "interface to mapbox services",

@@ -9,3 +9,5 @@ "main": "lib/mapbox.js",

"test": "tap --coverage test/browser.js test/*.js",
"browser-test": "browserify -t envify -t brfs test/browser.js test/*.js | smokestack | tap-status",
"browser-test": "browserify -t envify -t brfs test/*.js test/helpers/close.js | smokestack | tap-status",
"browser-test-ff": "browserify -t envify -t brfs test/*.js test/helpers/close.js | smokestack -b firefox | tap-status",
"browser-test-build": "echo '<script>' > test_bundle.html && browserify -t envify -t brfs test/directions.js >> test_bundle.html && echo '</script>' >> test_bundle.html",
"docs": "documentation . --format=md > API.md",

@@ -16,2 +18,6 @@ "build": "npm run build-dist && npm run build-min",

},
"browser": {
"atob": "./lib/atob.js",
"tap": "tape"
},
"repository": {

@@ -36,2 +42,4 @@ "type": "git",

"brfs": "^1.4.1",
"browser-process-hrtime": "^0.1.2",
"browser-stdout": "1.3.0",
"browserify": "^11.0.0",

@@ -42,14 +50,13 @@ "documentation": "^2.1.0-alpha2",

"geojson-random": "^0.2.2",
"polyline": "^0.1.0",
"smokestack": "^3.3.0",
"tap": "^1.3.1",
"browser-process-hrtime": "^0.1.2",
"browser-stdout": "1.3.0",
"tap-status": "^1.0.1",
"tape": "^4.2.0",
"uglifyjs": "^2.4.10"
},
"dependencies": {
"atob": "^1.1.2",
"geojsonhint": "^1.1.0",
"hat": "0.0.3",
"invariant": "^2.1.0",
"polyline": "^0.1.0",
"rest": "^1.3.1",

@@ -56,0 +63,0 @@ "xtend": "^4.0.0"

@@ -14,2 +14,8 @@ /* eslint no-shadow: 0 */

test('DatasetClient', function(datasetClient) {
if (process.browser) {
datasetClient.pass('skipping dataset api in browser');
return datasetClient.end();
}
var testDatasets = [];

@@ -16,0 +22,0 @@ var testFeature;

@@ -77,3 +77,2 @@ /* eslint no-shadow: 0 */

t.ifError(err);
console.log(results);
t.ok(Array.isArray(results.durations), 'returns an array');

@@ -80,0 +79,0 @@ t.equal(results.durations.length, 5, 'array has correct dimension');

@@ -23,3 +23,3 @@ /* eslint no-shadow: 0 */

client.geocodeForward('foo', 1);
}, /callback/);
}, /options/);
t.end();

@@ -63,2 +63,43 @@ });

t.test('options.proximity rounding', function(t) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var tester = { client: function(opts) {
opts.params.proximity.split(',').forEach(function(coord, i) {
t.ok(coord.toString().split('.')[1].length <= 3, 'proximity coordinate [' + i + '] precision <= 3');
});
t.ok(opts.params.proximity, 'proximity is set')
opts.callback();
}};
t.ok(client);
client.geocodeForward.apply(tester, ['Paris', {
proximity: { latitude: 33.6875431, longitude: -95.4431142 }
}, function(err, results) {
t.ifError(err);
t.end();
}]);
});
t.test('options.proximity rounding, precision = 1', function(t) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var tester = { client: function(opts) {
opts.params.proximity.split(',').forEach(function(coord, i) {
t.ok(coord.toString().split('.')[1].length <= 1, 'proximity coordinate [' + i + '] precision <= 1');
});
t.ok(opts.params.proximity, 'proximity is set')
opts.callback();
}};
t.ok(client);
client.geocodeForward.apply(tester, ['Paris', {
proximity: { latitude: 33.6875431, longitude: -95.4431142 },
precision: 1
}, function(err, results) {
t.ifError(err);
t.end();
}]);
});
t.end();

@@ -73,12 +114,12 @@ });

client.geocodeReverse(null);
}, /location/);
}, /options/, 'null string');
t.throws(function() {
client.geocodeReverse(1, function() {});
}, /location/);
}, /location/, 'number');
t.throws(function() {
client.geocodeReverse('foo', 1, function() {});
}, /options/);
}, /location/, 'bad options');
t.throws(function() {
client.geocodeReverse('foo', 1);
}, /callback/);
}, /location/, 'bad options 2');
t.end();

@@ -110,3 +151,49 @@ });

t.test('reverse coordinate rounding', function(t) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var tester = { client: function(opts) {
[opts.params.longitude, opts.params.latitude].forEach(function(coord, i) {
t.ok(coord.toString().split('.')[1].length <= 5, 'reverse coordinate [' + i + '] precision <= 5');
});
t.ok(opts.params.longitude, 'longitude is set')
t.ok(opts.params.latitude, 'latitude is set')
opts.callback();
}};
t.ok(client);
client.geocodeReverse.apply(tester, [{
latitude: 33.6875431,
longitude: -95.4431142
}, function(err, results) {
t.ifError(err);
t.end();
}]);
});
t.test('reverse coordinate precision = 2', function(t) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var tester = { client: function(opts) {
[opts.params.longitude, opts.params.latitude].forEach(function(coord, i) {
t.ok(coord.toString().split('.')[1].length <= 2, 'reverse coordinate [' + i + '] precision <= 2');
});
t.ok(opts.params.longitude, 'longitude is set')
t.ok(opts.params.latitude, 'latitude is set')
opts.callback();
}};
t.ok(client);
client.geocodeReverse.apply(tester, [{
latitude: 33.6875431,
longitude: -95.4431142
}, {
precision: 2
}, function(err, results) {
t.ifError(err);
t.end();
}]);
});
t.end();
});

@@ -29,5 +29,3 @@ /* eslint no-shadow: 0 */

t.test('bogus token', function(assert) {
var token = 'sk.eyJ1Ijoid29yYmx5IiwiYSI6ImQwNTg3OGU2MWI5NTI5MjIyNmI1YzNhNWE4ZGFlMmFiIn0==.-47f43O4Cz5-vEd0gXzJ3w';
assert.notOk(getUser(token), 'bad length success');
token = 'sk.eyJ1Ijoid29yYmx5IiwiYSI6ImQwNTg3OGU2MWI5NTI5MjIyNmI1YzNhNWE4ZGFlMmFiI12.-47f43O4Cz5-vEd0gXzJ3w';
var token = 'sk.eyJ1Ijoid29yYmx5IiwiYSI6ImQwNTg3OGU2MWI5NTI5MjIyNmI1YzNhNWE4ZGFlMmFiI12.-47f43O4Cz5-vEd0gXzJ3w';
assert.notOk(getUser(token), 'cannot parse success');

@@ -34,0 +32,0 @@ token = 'notvalidatall';

@@ -28,3 +28,3 @@ /* eslint no-shadow: 0 */

t.notOk(client);
}, /accessToken required to instantiate MapboxClient/);
}, /accessToken required to instantiate Mapbox client/);
var client = new MapboxClient(deadToken);

@@ -31,0 +31,0 @@ t.ok(client);

@@ -12,2 +12,8 @@ /* eslint no-shadow: 0 */

test('UploadClient', function(uploadClient) {
if (process.browser) {
uploadClient.pass('skipping dataset api in browser');
return uploadClient.end();
}
var testStagedFiles = [];

@@ -14,0 +20,0 @@ var testUploads = [];

Sorry, the diff of this file is not supported yet

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