import { Paginator } from "@aws-sdk/types" ; import { ListApplicationsCommand , ListApplicationsCommandInput , ListApplicationsCommandOutput , } from "../commands/ListApplicationsCommand" ; import { IoTFleetHub } from "../IoTFleetHub" ; import { IoTFleetHubClient } from "../IoTFleetHubClient" ; import { IoTFleetHubPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListApplicationsCommandOutput > => { return await client . send ( new ListApplicationsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListApplicationsCommandOutput > => { return await client . listApplications ( input , ... args ) ; } ; export async function * paginateListApplications ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . nextToken = token ; if ( config . client instanceof IoTFleetHub ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof IoTFleetHubClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected IoTFleetHub | IoTFleetHubClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }