import { Paginator } from "@aws-sdk/types" ; import { ListClosedWorkflowExecutionsCommand , ListClosedWorkflowExecutionsCommandInput , ListClosedWorkflowExecutionsCommandOutput , } from "../commands/ListClosedWorkflowExecutionsCommand" ; import { SWF } from "../SWF" ; import { SWFClient } from "../SWFClient" ; import { SWFPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListClosedWorkflowExecutionsCommandOutput > => { return await client . send ( new ListClosedWorkflowExecutionsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListClosedWorkflowExecutionsCommandOutput > => { return await client . listClosedWorkflowExecutions ( input , ... args ) ; } ; export async function * paginateListClosedWorkflowExecutions ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . nextPageToken = token ; input [ "maximumPageSize" ] = config . pageSize ; if ( config . client instanceof SWF ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof SWFClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected SWF | SWFClient" ) ; } yield page ; token = page . nextPageToken ; hasNext = ! ! token ; } return undefined ; }