How to use the asynciterator.EmptyIterator 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 comunica / comunica / packages / actor-rdf-resolve-quad-pattern-federated / lib / FederatedQuadSource.ts View on Github external
return new PromiseProxyIterator(async () => {
        let output: IActorRdfResolveQuadPatternOutput;
        if (this.isSourceEmpty(source, pattern)) {
          output = { data: new EmptyIterator(), metadata: () => Promise.resolve({ totalItems: 0 }) };
        } else {
          output = await this.mediatorResolveQuadPattern.mediate({ pattern, context });
        }
        if (output.metadata) {
          output.metadata().then((subMetadata: {[id: string]: any}) => {
            if ((!subMetadata.totalItems && subMetadata.totalItems !== 0) || !isFinite(subMetadata.totalItems)) {
              metadata.totalItems = Infinity;
              remainingSources = 0; // We're already at infinite, so ignore any later metadata
              checkEmitMetadata(Infinity, source, pattern, subMetadata);
            } else {
              metadata.totalItems += subMetadata.totalItems;
              remainingSources--;
              checkEmitMetadata(subMetadata.totalItems, source, pattern, subMetadata);
            }
          });
        } else {
github openplannerteam / planner.js / src / fetcher / connections / prefetch / ConnectionsStore.ts View on Github external
public getIterator(iteratorOptions: IConnectionsIteratorOptions): AsyncIterator {
    const { backward } = iteratorOptions;
    let { lowerBoundDate, upperBoundDate } = iteratorOptions;

    if (this.hasFinishedPrimary && this.store.length === 0) {
      return new EmptyIterator();
    }

    const firstConnection = this.store[0];
    const firstDepartureTime = firstConnection && firstConnection.departureTime;

    const lastConnection = this.store[this.store.length - 1];
    const lastDepartureTime = lastConnection && lastConnection.departureTime;

    if (lowerBoundDate && lowerBoundDate < firstDepartureTime) {
      throw new Error("Must supply a lowerBoundDate after the first prefetched connection");
    }

    if (backward) {

      if (!upperBoundDate) {
        throw new Error("Must supply upperBoundDate when iterating backward");
github openplannerteam / planner.js / src / planner / public-transport / JourneyExtractorEarliestArrival.ts View on Github external
exitLocation,
        exitConnection.travelMode,
        { average: duration },
        departureTime,
        arrivalTime,
        undefined,
        enterConnection.id,
        exitConnection.id,
      );

      path.addStep(step);
      currentStopId = enterConnection.departureStop;
    }

    if (!path.steps.length) {
      return new EmptyIterator();
    }

    path.reverse();

    return new SingletonIterator(path);
  }