import { Paginator } from "@aws-sdk/types" ; import { ListComponentVersionsCommand , ListComponentVersionsCommandInput , ListComponentVersionsCommandOutput , } from "../commands/ListComponentVersionsCommand" ; import { GreengrassV2 } from "../GreengrassV2" ; import { GreengrassV2Client } from "../GreengrassV2Client" ; import { GreengrassV2PaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListComponentVersionsCommandOutput > => { return await client . send ( new ListComponentVersionsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListComponentVersionsCommandOutput > => { return await client . listComponentVersions ( input , ... args ) ; } ; export async function * paginateListComponentVersions ( 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 GreengrassV2 ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof GreengrassV2Client ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected GreengrassV2 | GreengrassV2Client" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }