Class Paginator (5.0.0)

Package

@google-cloud/paginator

Methods

extend(Class, methodNames)

extend(Class: Function, methodNames: string | string[]): void;

Cache the original method, then overwrite it on the Class's prototype.

Parameters
NameDescription
Class Function

The parent class of the methods to extend.

methodNames string | string[]

Name(s) of the methods to extend.

Returns
TypeDescription
void

parseArguments_(args)

parseArguments_(args: any[]): ParsedArguments;

Parse a pseudo-array arguments for a query and callback.

Parameter
NameDescription
args any[]

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

Returns
TypeDescription
ParsedArguments

run_(parsedArguments, originalMethod)

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.

Parameters
NameDescription
parsedArguments ParsedArguments

Parsed arguments from the original method call.

originalMethod Function

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

Returns
TypeDescription
any

runAsStream_(parsedArguments, originalMethod)

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.

Parameters
NameDescription
parsedArguments ParsedArguments
originalMethod Function

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

Returns
TypeDescription
ResourceStream<T>
Type Parameter
NameDescription
T

streamify(methodName)

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
NameDescription
methodName string

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

Returns
TypeDescription
(this: { [index: string]: Function; }, ...args: any[]) => ResourceStream<T>
Type Parameter
NameDescription
T