import { Paginator } from "@aws-sdk/types" ; import { GetServersCommand , GetServersCommandInput , GetServersCommandOutput } from "../commands/GetServersCommand" ; import { SMS } from "../SMS" ; import { SMSClient } from "../SMSClient" ; import { SMSPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < GetServersCommandOutput > => { return await client . send ( new GetServersCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < GetServersCommandOutput > => { return await client . getServers ( input , ... args ) ; } ; export async function * paginateGetServers ( 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 SMS ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof SMSClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected SMS | SMSClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }