import { Paginator } from "@aws-sdk/types" ; import { ListBrokersCommand , ListBrokersCommandInput , ListBrokersCommandOutput } from "../commands/ListBrokersCommand" ; import { Mq } from "../Mq" ; import { MqClient } from "../MqClient" ; import { MqPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListBrokersCommandOutput > => { return await client . send ( new ListBrokersCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListBrokersCommandOutput > => { return await client . listBrokers ( input , ... args ) ; } ; export async function * paginateListBrokers ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . NextToken = token ; input [ "MaxResults" ] = config . pageSize ; if ( config . client instanceof Mq ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof MqClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected Mq | MqClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }