@google-cloud/paginator

  • Version 5.0.0
  • Published
  • 50 kB
  • 2 dependencies
  • Apache-2.0 license

Install

npm i @google-cloud/paginator
yarn add @google-cloud/paginator
pnpm add @google-cloud/paginator

Overview

A result paging utility used by Google node.js modules

Index

Variables

variable paginator

const paginator: Paginator;

    Classes

    class Paginator

    class Paginator {}

      method extend

      extend: (Class: Function, methodNames: string | string[]) => void;
      • Cache the original method, then overwrite it on the Class's prototype.

        Parameter Class

        The parent class of the methods to extend.

        Parameter methodNames

        Name(s) of the methods to extend.

      method parseArguments_

      parseArguments_: (args: any[]) => ParsedArguments;
      • Parse a pseudo-array arguments for a query and callback.

        Parameter args

        The original arguments pseduo-array that the original method received.

      method run_

      run_: (parsedArguments: ParsedArguments, originalMethod: Function) => any;
      • This simply checks to see if autoPaginate is set or not, if it's true then we buffer all results, otherwise simply call the original method.

        Parameter parsedArguments

        Parsed arguments from the original method call.

        Parameter

        {object=|string=} parsedArguments.query - Query object. This is most commonly an object, but to make the API more simple, it can also be a string in some places.

        Parameter

        {function=} parsedArguments.callback - Callback function.

        Parameter

        {boolean} parsedArguments.autoPaginate - Auto-pagination enabled.

        Parameter

        {boolean} parsedArguments.maxApiCalls - Maximum API calls to make.

        Parameter

        {number} parsedArguments.maxResults - Maximum results to return.

        Parameter originalMethod

        The cached method that accepts a callback and returns nextQuery to receive more results.

      method runAsStream_

      runAsStream_: <T = any>(
      parsedArguments: ParsedArguments,
      originalMethod: Function
      ) => ResourceStream<T>;
      • This method simply calls the nextQuery recursively, emitting results to a stream. The stream ends when nextQuery is null.

        maxResults will act as a cap for how many results are fetched and emitted to the stream.

        Parameter

        {object=|string=} parsedArguments.query - Query object. This is most commonly an object, but to make the API more simple, it can also be a string in some places.

        Parameter

        {function=} parsedArguments.callback - Callback function.

        Parameter

        {boolean} parsedArguments.autoPaginate - Auto-pagination enabled.

        Parameter

        {boolean} parsedArguments.maxApiCalls - Maximum API calls to make.

        Parameter

        {number} parsedArguments.maxResults - Maximum results to return.

        Parameter originalMethod

        The cached method that accepts a callback and returns nextQuery to receive more results. {stream} - Readable object stream.

      method streamify

      streamify: <T = any>(
      methodName: string
      ) => (this: { [index: string]: Function }, ...args: any[]) => ResourceStream<T>;
      • Wraps paginated API calls in a readable object stream.

        This method simply calls the nextQuery recursively, emitting results to a stream. The stream ends when nextQuery is null.

        maxResults will act as a cap for how many results are fetched and emitted to the stream.

        Parameter methodName

        Name of the method to streamify. {function} - Wrapped function.

      class ResourceStream

      class ResourceStream<T> extends Transform implements ResourceEvents<T> {}

        constructor

        constructor(args: ParsedArguments, requestFn: Function);

          method end

          end: (
          ...args: any[]
          ) => ReturnType<Writable['end']> extends Writable ? this : void;

            Interfaces

            interface ParsedArguments

            interface ParsedArguments extends TransformOptions {}

              property autoPaginate

              autoPaginate?: boolean;
              • Auto-pagination enabled.

              property callback

              callback?: Function;
              • Callback function.

              property maxApiCalls

              maxApiCalls?: number;
              • Maximum API calls to make.

              property maxResults

              maxResults?: number;
              • Maximum results to return.

              property pageSize

              pageSize?: number;

                property query

                query?: ParsedArguments;
                • Query object. This is most commonly an object, but to make the API more simple, it can also be a string in some places.

                property streamOptions

                streamOptions?: ParsedArguments;

                  Package Files (2)

                  Dependencies (2)

                  Dev Dependencies (16)

                  Peer Dependencies (0)

                  No peer dependencies.

                  Badge

                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@google-cloud/paginator.

                  • Markdown
                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@google-cloud/paginator)
                  • HTML
                    <a href="https://www.jsdocs.io/package/@google-cloud/paginator"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>