MCPcopy
hub / github.com/slackapi/node-slack-sdk / generatePages

Method generatePages

packages/web-api/src/WebClient.ts:217–235  ·  view source on GitHub ↗
(this: WebClient)

Source from the content-addressed store, hash-verified

215 })();
216
217 async function* generatePages(this: WebClient): AsyncIterableIterator<WebAPICallResult> {
218 // when result is undefined, that signals that the first of potentially many calls has not yet been made
219 let result: WebAPICallResult | undefined = undefined;
220 // paginationOptions stores pagination options not already stored in the options argument
221 let paginationOptions: methods.CursorPaginationEnabled | undefined = {
222 limit: pageSize,
223 };
224 if (options !== undefined && options.cursor !== undefined) {
225 paginationOptions.cursor = options.cursor as string;
226 }
227
228 // NOTE: test for the situation where you're resuming a pagination using and existing cursor
229
230 while (result === undefined || paginationOptions !== undefined) {
231 result = await this.apiCall(method, Object.assign(options !== undefined ? options : {}, paginationOptions));
232 yield result;
233 paginationOptions = paginationOptionsForNextPage(result, pageSize);
234 }
235 }
236
237 if (shouldStop === undefined) {
238 return generatePages.call(this);

Callers

nothing calls this directly

Calls 2

apiCallMethod · 0.95

Tested by

no test coverage detected