How to use the asynciterator.ArrayIterator function in asynciterator

To help you get started, we’ve selected a few asynciterator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openplannerteam / planner.js / src / planner / public-transport / JourneyExtractorDefault.ts View on Github external
public async extractJourneys(
    profilesByStop: IProfilesByStop,
    query: IResolvedQuery,
  ): Promise> {
    const filteredProfilesByStop: IProfilesByStop = ProfileUtil.filterInfinity(profilesByStop);

    const departureLocation: ILocation = query.from[0];
    const arrivalLocation: ILocation = query.to[0];

    const paths: IPath[] = [];

    const departureLocationProfiles: IProfile[] = filteredProfilesByStop[departureLocation.id];

    // Can't find departure stop;
    if (!departureLocationProfiles) {
      return new ArrayIterator(paths);
    }

    for (const profile of departureLocationProfiles) {

      for (let amountOfTransfers = 0; amountOfTransfers < profile.transferProfiles.length; amountOfTransfers++) {
        const transferProfile: ITransferProfile = profile.transferProfiles[amountOfTransfers];

        if (this.checkBestArrivalTime(transferProfile, departureLocation, arrivalLocation)) {
          try {
            paths.push(await this.extractJourney(
              departureLocation,
              arrivalLocation,
              transferProfile,
              amountOfTransfers,
              filteredProfilesByStop,
            ));
github openplannerteam / planner.js / src / planner / public-transport / JourneyExtractorDefault.ts View on Github external
filteredProfilesByStop,
            ));

            this.setBestArrivalTime(
              departureLocation,
              arrivalLocation,
              transferProfile.arrivalTime,
            );
          } catch (e) {
            console.warn(e);
          }
        }
      }

    }
    return new ArrayIterator(paths.reverse());
  }
github openplannerteam / planner.js / src / planner / public-transport / JourneyExtractorProfile.ts View on Github external
this.setBestArrivalTime(
              departureLocation,
              arrivalLocation,
              transferProfile.arrivalTime,
            );

          } catch (e) {
            if (this.eventBus) {
              this.eventBus.emit(EventType.Warning, (e));
            }
          }
        }
      }
    }

    return new ArrayIterator(paths.reverse());
  }
github Callidon / sparql-engine / src / operators / modifiers / construct-operator.ts View on Github external
_createTransformer (bindings: Bindings): AsyncIterator {
    return new ArrayIterator(compact(this._templates.map(t => bindings.bound(t))))
  }
}
github Callidon / sparql-engine / src / operators / modifiers / construct-operator.js View on Github external
_createTransformer (bindings) {
    return new ArrayIterator(compact(this._templates.map(t => applyBindings(t, bindings))))
  }
}
github openplannerteam / planner.js / src / planner / road / RoadPlannerPathfindingExperimental.ts View on Github external
for (const to of toLocations) {

                    const newPath = await this.getPathBetweenLocations(
                        from,
                        to,
                        profile,
                    );

                    if (newPath) {
                        paths.push(newPath);
                    }
                }
            }
        }

        return new ArrayIterator(paths);
    }
github openplannerteam / planner.js / src / planner / public-transport / CSAProfile.ts View on Github external
const queryState: IQueryState = {
      query,
      profilesByStop: {},
      earliestArrivalByTrip: {},
      durationToTargetByStop: {},
      gtfsTripByConnection: {},
      initialReachableStops: [],
      footpathQueue,
      connectionsIterator: mergedIterator,
    };

    const hasInitialReachableStops: boolean = await this.initDurationToTargetByStop(queryState);
    const hasFinalReachableStops: boolean = await this.initInitialReachableStops(queryState);

    if (!hasInitialReachableStops || !hasFinalReachableStops) {
      return Promise.resolve(new ArrayIterator([]));
    }

    const self = this;

    return new Promise((resolve, reject) => {
      let isDone: boolean = false;

      const done = () => {
        if (!isDone) {
          queryState.connectionsIterator.close();

          self.journeyExtractor.extractJourneys(queryState.profilesByStop, queryState.query)
            .then((resultIterator) => {
              resolve(resultIterator);
            });
github comunica / comunica / packages / actor-query-operation-construct / lib / BindingsToQuadsIterator.ts View on Github external
public _createTransformer(bindings: Bindings): AsyncIterator {
    return new ArrayIterator(BindingsToQuadsIterator.bindTemplate(
      bindings, this.template, this.blankNodeCounter++));
  }
github openplannerteam / planner.js / src / planner / road / RoadPlannerPathfinding.ts View on Github external
for (const to of toLocations) {

                    const newPath = await this.getPathBetweenLocations(
                        from,
                        to,
                        profile,
                    );

                    if (newPath) {
                        paths.push(newPath);
                    }
                }
            }
        }

        return new ArrayIterator(paths);
    }
github openplannerteam / planner.js / src / fetcher / connections / lazy / ConnectionsIteratorLazy.ts View on Github external
const parsePageConnections = (page: IHydraPage) => {
      const connectionsParser = new ConnectionsPageParser(page.documentIri, page.triples);

      const connections = connectionsParser.getConnections(travelMode);

      if (options.backward) {
        connections.reverse();
      }

      return new ArrayIterator(connections);
    };