Comparing version 0.9.0 to 0.10.0
@@ -387,3 +387,3 @@ ## `MapboxClient` | ||
var mapboxClient = new MapboxClient('ACCESSTOKEN'); | ||
mapboxClient.directions( | ||
mapboxClient.getDirections( | ||
[ | ||
@@ -390,0 +390,0 @@ { latitude: 33.6, longitude: -95.4431 }, |
@@ -7,3 +7,3 @@ // We keep all of the constants that declare endpoints in one | ||
module.exports.API_GEOCODER_REVERSE = '/geocoding/v5/{dataset}/{longitude},{latitude}.json'; | ||
module.exports.API_DIRECTIONS = '/v4/directions/{profile}/{encodedWaypoints}.json'; | ||
module.exports.API_DIRECTIONS = '/v4/directions/{profile}/{encodedWaypoints}.json{?alternatives,instructions,geometry,steps}'; | ||
module.exports.API_DISTANCE = '/distances/v1/mapbox/{profile}'; | ||
@@ -10,0 +10,0 @@ module.exports.API_SURFACE = '/v4/surface/{mapid}.json{?layer,fields,points,geojson,interpolate,encoded_polyline}'; |
@@ -43,3 +43,3 @@ 'use strict'; | ||
* var mapboxClient = new MapboxClient('ACCESSTOKEN'); | ||
* mapboxClient.directions( | ||
* mapboxClient.getDirections( | ||
* [ | ||
@@ -82,2 +82,3 @@ * { latitude: 33.6, longitude: -95.4431 }, | ||
alternatives = true, | ||
steps = true, | ||
geometry = 'geojson', | ||
@@ -91,7 +92,12 @@ instructions = 'text'; | ||
if (options.instructions) { | ||
assert(typeof options.instructions === 'string', 'instructions option must be string'); | ||
instructions = options.instructions; | ||
if (typeof options.alternatives !== 'undefined') { | ||
assert(typeof options.alternatives === 'boolean', 'alternatives option must be boolean'); | ||
alternatives = options.alternatives; | ||
} | ||
if (typeof options.steps !== 'undefined') { | ||
assert(typeof options.steps === 'boolean', 'steps option must be boolean'); | ||
steps = options.steps; | ||
} | ||
if (options.geometry) { | ||
@@ -102,2 +108,7 @@ assert(typeof options.geometry === 'string', 'geometry option must be string'); | ||
if (options.instructions) { | ||
assert(typeof options.instructions === 'string', 'instructions option must be string'); | ||
instructions = options.instructions; | ||
} | ||
this.client({ | ||
@@ -110,3 +121,4 @@ path: constants.API_DIRECTIONS, | ||
geometry: geometry, | ||
alternatives: alternatives | ||
alternatives: alternatives, | ||
steps: steps | ||
}, | ||
@@ -113,0 +125,0 @@ callback: callback |
{ | ||
"name": "mapbox", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "interface to mapbox services", | ||
@@ -5,0 +5,0 @@ "main": "lib/mapbox.js", |
@@ -42,5 +42,36 @@ /* eslint no-shadow: 0 */ | ||
t.test('assert options', function(t) { | ||
var client = new MapboxClient(process.env.MapboxAccessToken); | ||
t.ok(client); | ||
var tester = { client: function(opts) { | ||
var params = opts.params; | ||
t.equals(params.profile, 'mapbox.walking', 'profile as walking is set'); | ||
t.equals(params.geometry, 'polyline', 'geometry as polyline is set'); | ||
t.equals(params.instructions, 'html', 'instructions as HTML is set'); | ||
t.notOk(params.alternatives, 'alternatives option is set to false'); | ||
t.notOk(params.steps, 'steps option is set to false'); | ||
opts.callback(); | ||
}}; | ||
client.getDirections.apply(tester, [[ | ||
{ latitude: 33.6875431, longitude: -95.4431142 }, | ||
{ latitude: 33.6875431, longitude: -95.4831142 } | ||
], { | ||
profile: 'mapbox.walking', | ||
alternatives: false, | ||
steps: false, | ||
geometry: 'polyline', | ||
instructions: 'html' | ||
}, function(err) { | ||
t.ifError(err); | ||
t.end(); | ||
}]); | ||
}); | ||
t.test('all options', function(t) { | ||
var client = new MapboxClient(process.env.MapboxAccessToken); | ||
t.ok(client); | ||
client.getDirections([ | ||
@@ -51,5 +82,6 @@ { latitude: 33.6875431, longitude: -95.4431142 }, | ||
profile: 'mapbox.walking', | ||
instructions: 'html', | ||
alternatives: false, | ||
geometry: 'polyline' | ||
steps: false, | ||
geometry: 'polyline', | ||
instructions: 'html' | ||
}, function(err, results) { | ||
@@ -56,0 +88,0 @@ t.ifError(err); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
93
280997
45
5824
5