Class Paginator (5.0.1)

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
Name Description
Class Function

The parent class of the methods to extend.

methodNames string | string[]

Name(s) of the methods to extend.

Returns
Type Description
void

parseArguments_(args)

parseArguments_(args: any[]): ParsedArguments;

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

Parameter
Name Description
args any[]

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

Returns
Type Description
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
Name Description
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
Type Description
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
Name Description
parsedArguments ParsedArguments
originalMethod Function

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

Returns
Type Description
ResourceStream<T>
Type Parameter
Name Description
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
Name Description
methodName string

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

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