async function *genTripsChunk() {    
  const places = await getPlaces();
  const endpoints = getTripsEndpoints(places);    
  
  // generate the trips in sets of 5
  while (endpoints.length > 0) {
    let chunk = endpoints.splice(0, 5);      
    let chunk_runtime = 0;
    chunk = chunk.map(async(trip) => {
      const mode = trip.mode;
      trip = await getDirections(trip); 
      const duration = trip.duration.value;        
      const route = trip.steps;
      trip = {
        duration: duration,
        route: formatRoute(route),
        mode: mode
      }
      // Set the total layer runtime to equal longest trip in set
      if (duration > chunk_runtime) chunk_runtime = duration;
      return trip
    });      
    chunk = await Promise.all(chunk);
    chunk = {
      data: chunk,
      runtime: chunk_runtime
    }
    yield chunk;
  }
}
// have to wait for all calls to complete
have to wait for all calls to complete
have to wait for all calls to complete
async function *genTripsChunk() {    
  const places = await getPlaces();
  const endpoints = getTripsEndpoints(places);    
  while (endpoints.length > 0) {
    let chunk = endpoints.splice(0, 5);      
    let chunk_runtime = 0;
    chunk = chunk.map(async(trip) => {
      const mode = trip.mode;
      trip = await getDirections(trip); 
      const duration = trip.duration.value;        
      const route = trip.steps;
      trip = {
        duration: duration,
        route: formatRoute(route),
        mode: mode
      }
      if (duration > chunk_runtime) chunk_runtime = duration;
      return trip
    });      
    chunk = await Promise.all(chunk);
    chunk = {
      data: chunk,
      runtime: chunk_runtime
    }
    yield chunk;
  }
}
async function * genTripsChunk ( ) { const places = await getPlaces ( ) ; const endpoints = getTripsEndpoints ( places ) ; while ( endpoints . length > 0 ) { let chunk = endpoints . splice ( 0 , 5 ) ; let chunk_runtime = 0 ; chunk = chunk . map ( async ( trip ) => { const mode = trip . mode ; trip = await getDirections ( trip ) ; const duration = trip . duration . value ; const route = trip . steps ; trip = { duration : duration , route : formatRoute ( route ) , mode : mode } if ( duration > chunk_runtime ) chunk_runtime = duration ; return trip } ) ; chunk = await Promise . all ( chunk ) ; chunk = { data : chunk , runtime : chunk_runtime } yield chunk ; } }
have to wait for all calls to complete
have to wait for all calls to complete
// generate the trips in sets of 5 // Set the total layer runtime to equal longest trip in set