import { Paginator } from "@aws-sdk/types" ; import { Cloud9 } from "../Cloud9" ; import { Cloud9Client } from "../Cloud9Client" ; import { ListEnvironmentsCommand , ListEnvironmentsCommandInput , ListEnvironmentsCommandOutput , } from "../commands/ListEnvironmentsCommand" ; import { Cloud9PaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListEnvironmentsCommandOutput > => { return await client . send ( new ListEnvironmentsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListEnvironmentsCommandOutput > => { return await client . listEnvironments ( input , ... args ) ; } ; export async function * paginateListEnvironments ( 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 Cloud9 ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof Cloud9Client ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected Cloud9 | Cloud9Client" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }