async *genTripsChunk() {    
    const places = await this.getPlaces();
    const endpoints = this.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 this.getDirections(trip); 
        const duration = trip.duration.value;        
        const route = trip.steps;
        trip = {
          duration: duration,
          route: this.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 *genTripsChunk() {    
    const places = await this.getPlaces();
    const endpoints = this.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 this.getDirections(trip); 
        const duration = trip.duration.value;        
        const route = trip.steps;
        trip = {
          duration: duration,
          route: this.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 * genTripsChunk ( ) { const places = await this . getPlaces ( ) ; const endpoints = this . 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 this . getDirections ( trip ) ; const duration = trip . duration . value ; const route = trip . steps ; trip = { duration : duration , route : this . 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