import { Paginator } from "@aws-sdk/types" ; import { ListApplicationComponentsCommand , ListApplicationComponentsCommandInput , ListApplicationComponentsCommandOutput , } from "../commands/ListApplicationComponentsCommand" ; import { MigrationHubStrategy } from "../MigrationHubStrategy" ; import { MigrationHubStrategyClient } from "../MigrationHubStrategyClient" ; import { MigrationHubStrategyPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListApplicationComponentsCommandOutput > => { return await client . send ( new ListApplicationComponentsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListApplicationComponentsCommandOutput > => { return await client . listApplicationComponents ( input , ... args ) ; } ; export async function * paginateListApplicationComponents ( 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 MigrationHubStrategy ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof MigrationHubStrategyClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected MigrationHubStrategy | MigrationHubStrategyClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }