@@ -66,7 +66,7 @@ function extractSegment(
6666 const seg = {
6767 duration,
6868 distance,
69- path : path && path . slice ( begin_shape_index , end_shape_index ) ,
69+ path : path ? .slice ( begin_shape_index , end_shape_index ) ,
7070 instructions : instruction
7171 } ;
7272 if ( rough ) {
@@ -95,8 +95,8 @@ function extractDirections(result, leg) {
9595 const { directions } = result ;
9696 result . path = util . decode ( leg . shape , { factor : 1e6 } ) ;
9797 const route = {
98- duration : ( leg . summary && leg . summary . time ) || 0 ,
99- distance : Math . round ( ( ( leg . summary && leg . summary . length ) || 0 ) * result . unitMultiplier )
98+ duration : leg . summary ?. time || 0 ,
99+ distance : Math . round ( ( leg . summary ?. length || 0 ) * result . unitMultiplier )
100100 } ;
101101 if ( result . fullPath ) {
102102 route . path = result . path ;
@@ -138,8 +138,8 @@ function directDistance(locations, units) {
138138 ) ;
139139}
140140
141- function getStatus ( err , response ) {
142- let st = response && response . status_code ;
141+ function getStatus ( _err , response ) {
142+ let st = response ? .status_code ;
143143 if ( ! response ) {
144144 return ;
145145 }
@@ -152,9 +152,9 @@ function getStatus(err, response) {
152152 // no route
153153 return status . empty ;
154154 }
155- st = response . trip && response . trip . status ;
155+ st = response . trip ? .status ;
156156 if ( st === 0 ) {
157- if ( response . trip . legs && response . trip . legs . length ) {
157+ if ( response . trip . legs ? .length ) {
158158 const { length, time } = response . trip . summary ;
159159 const distance = directDistance ( response . trip . locations , response . trip . units ) ;
160160 // make sure points are not too far from roads
@@ -229,8 +229,8 @@ function init(options) {
229229 }
230230
231231 function processResponse ( response , query ) {
232- const trip = response && response . trip ;
233- if ( trip && trip . legs && trip . legs . length ) {
232+ const trip = response ? .trip ;
233+ if ( trip ? .legs ? .length ) {
234234 const directions = {
235235 query,
236236 provider : options . name ,
0 commit comments