Skip to main content
Module

x/slack_bolt/deps.ts>WebClient#paginate

TypeScript framework to build Slack apps in a flash with the latest platform features. Deno port of @slack/bolt
Latest
method WebClient.prototype.paginate
Re-export
import { WebClient } from "https://deno.land/x/slack_bolt@1.0.0/deps.ts";

Iterate over the result pages of a cursor-paginated Web API method. This method can return two types of values, depending on which arguments are used. When up to two parameters are used, the return value is an async iterator which can be used as the iterable in a for-await-of loop. When three or four parameters are used, the return value is a promise that resolves at the end of iteration. The third parameter, shouldStop, is a function that is called with each page and can end iteration by returning true. The fourth parameter, reduce, is a function that is called with three arguments: accumulator, page, and index. The accumulator is a value of any type you choose, but it will contain undefined when reduce is called for the first time. The page argument and index arguments are exactly what they say they are. The reduce function's return value will be passed in as accumulator the next time its called, and the returned promise will resolve to the last value of accumulator.

The for-await-of syntax is part of ES2018. It is available natively in Node starting with v10.0.0. You may be able to use it in earlier JavaScript runtimes by transpiling your source with a tool like Babel. However, the transpiled code will likely sacrifice performance.

Parameters

method: string
optional
options: WebAPICallOptions
  • options

Parameters

method: string
options: WebAPICallOptions
shouldStop: PaginatePredicate

Returns

Promise<void>

Type Parameters

R extends PageReducer
A extends PageAccumulator<R>

Parameters

method: string
options: WebAPICallOptions
shouldStop: PaginatePredicate
optional
reduce: PageReducer<A>

Returns

Promise<A>